<commit_before>// include node express lib
const express = require('express')
//include sequelize package
const Sequelize = require('sequelize')
//connect to database seqbulletinboard
const sequelize = new Sequelize('postgres://' + process.env.POSTGRES_USER + ':' + process.env.POSTGRES_PASSWORD + '@localhost/seqbulletinboard')
// include node body parsing middleware
const bodyParser = require('body-parser')
//include node html-entities lib
const Entities = require('html-entities').XmlEntities

// create app as instance of express
const app = express()
// create instance of entities, so I can use all it's functions
const entities = new Entities()

// Parse incoming request bodies in a middleware before your handlers, availabe under the req.body property
app.use(bodyParser.urlencoded({ extended: true }))

// serve static files in express
app.use(express.static(__dirname + '/static/'))

// set view engine to pug & set where the view engine is located
app.set('view engine', 'pug')
app.set('views', __dirname + '/views')

// make table messages in database seqbulletinboard with js instead of in psql
var Message = sequelize.define ('message', {
	name: 	Sequelize.STRING,
	title: 	Sequelize.STRING,
	body: 	Sequelize.STRING 
})

// when home is requested render localhost:8000
app.get('/', (request, response) => {
	console.log("About to render the leave a message page...");
	response.render('index')
})

// When submit button is clicked on leave a message/index.pug
app.post('/', (request, response) => {
	// when one of the fields is empty, stay on /index and display errormessage
	if(!request.body['name'] || !request.body['title'] || !request.body['body']){
		response.render('', {fieldEmptyError: true, errorMessage: 'You shall not pass!\nPlease, fill in all fields to leave your message.'})
	} else {
		//encode input user: replacing characters to its entity representations. Ignores UTF characters with no entity representation.
		//this because otherwise characters like ', ", ` in user's message crashes the client.query
		let title = entities.encode(request.body['title']);<commit_msg>changed path from practice seqbulletinboard to bulletinboard so I can pull request it in the master<commit_after>// include node express lib
const express = require('express')
//include sequelize package
const Sequelize = require('sequelize')
//connect to database bulletinboard
const sequelize = new Sequelize('postgres://' + process.env.POSTGRES_USER + ':' + process.env.POSTGRES_PASSWORD + '@localhost/bulletinboard')
// include node body parsing middleware
const bodyParser = require('body-parser')
//include node html-entities lib
const Entities = require('html-entities').XmlEntities

// create app as instance of express
const app = express()
// create instance of entities, so I can use all it's functions
const entities = new Entities()

// Parse incoming request bodies in a middleware before your handlers, availabe under the req.body property
app.use(bodyParser.urlencoded({ extended: true }))

// serve static files in express
app.use(express.static(__dirname + '/static/'))

// set view engine to pug & set where the view engine is located
app.set('view engine', 'pug')
app.set('views', __dirname + '/views')

// make table messages in database bulletinboard with js instead of in psql
var Message = sequelize.define ('message', {
	name: 	Sequelize.STRING,
	title: 	Sequelize.STRING,
	body: 	Sequelize.STRING 
})

// when home is requested render localhost:8000
app.get('/', (request, response) => {
	console.log("About to render the leave a message page...");
	response.render('index')
})

// When submit button is clicked on leave a message/index.pug
app.post('/', (request, response) => {
	// when one of the fields is empty, stay on /index and display errormessage
	if(!request.body['name'] || !request.body['title'] || !request.body['body']){
		response.render('', {fieldEmptyError: true, errorMessage: 'You shall not pass!\nPlease, fill in all fields to leave your message.'})
	} else {
		//encode input user: replacing characters to its entity representations. Ignores UTF characters with no entity representation.
		//this because otherwise characters like ', ", ` in user's message crashes the client.query
		let title = entities.encode(request.body['title']);
{'fraction_non_alphanumeric': 0.11984145488458849, 'fraction_numerical': 0.0018652366519002097, 'mean_word_length': 4.674603174603175, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4142611', 'n_tokens_mistral': 1202, 'n_tokens_neox': 1165, 'n_words': 458}