<commit_before>'use strict';

//==MODULES==
const express = require('express');
const bodyParser = require('body-parser');
const mongoose = require('mongoose');
const chalk = require('chalk');
const morgan = require('morgan');
const helmet = require('helmet');
const session = require('express-session');


//==Express Setup==
const app = express();
app.set('port', (process.env.PORT || 5000));


//===HTTP Headers===
app.use(helmet());


//===Morgan Logger Middleware===
app.use(morgan(':method :url :status - :response-time ms'));


//===Parsing===
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.text());
app.use(bodyParser.json({ type: 'application/vnd.api+json' }));


//===Static Files, CSS,Images,Fonts===
app.use(express.static('public'));


//===Trust First Proxy===
app.set('trust proxy', 1);


//===SESSIONS===
app.use(session({
	secret: 'sandbox',
	resave: false,
	saveUninitialized: true
	// cookie: { secure: true } //get https set for this
}));


//===MongoDB Connection with Mongoose==
mongoose.Promise = global.Promise; //use standard Promise instead of Mongo's promise library
mongoose.connect( process.env.MONGODB_URI || 'mongodb://localhost/zen',{
	useMongoClient: true
});
const db = mongoose.connection;

db.on('error', function(error) { // Show any mongoose errors
	console.log(chalk.red('Mongoose Error: '), error);
});


//===Routes===
require('./controller/html_routes.js')(app);
require('./controller/api_routes.js')(app);


//==Start Server==
let server = app.listen(app.get('port'), function() {
	console.log('Running on Port:', app.get('port'),'\n' );
});

module.exports = server; //for mocha<commit_msg>Session secret taken from enviroment variable<commit_after>'use strict';

//==MODULES==
const express = require('express');
const bodyParser = require('body-parser');
const mongoose = require('mongoose');
const chalk = require('chalk');
const morgan = require('morgan');
const helmet = require('helmet');
const session = require('express-session');


//==Express Setup==
const app = express();
app.set('port', (process.env.PORT || 5000));


//===HTTP Headers===
app.use(helmet());


//===Morgan Logger Middleware===
app.use(morgan(':method :url :status - :response-time ms'));


//===Parsing===
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.text());
app.use(bodyParser.json({ type: 'application/vnd.api+json' }));


//===Static Files, CSS,Images,Fonts===
app.use(express.static('public'));


//===Trust First Proxy===
app.set('trust proxy', 1);


//===SESSIONS===
let secret = undefined;

if (process.env.zenZecret){
	secret = process.env.zenSecret;
}else{
	secret = 'development-only';
}

app.use(session({
	secret: secret,
	resave: false,
	saveUninitialized: true
}));


//===MongoDB Connection with Mongoose==
mongoose.Promise = global.Promise; //use standard Promise instead of Mongo's promise library
mongoose.connect( process.env.MONGODB_URI || 'mongodb://localhost/zen',{
	useMongoClient: true
});
const db = mongoose.connection;

db.on('error', function(error) { // Show any mongoose errors
	console.log(chalk.red('Mongoose Error: '), error);
});


//===Routes===
require('./controller/html_routes.js')(app);
require('./controller/api_routes.js')(app);


//==Start Server==
let server = app.listen(app.get('port'), function() {
	console.log('Running on Port:', app.get('port'),'\n' );
});

module.exports = server; //for mocha
{'fraction_non_alphanumeric': 0.20990498128419235, 'fraction_numerical': 0.0028793550244745176, 'mean_word_length': 5.397790055248619, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '4167267', 'n_tokens_mistral': 1154, 'n_tokens_neox': 1133, 'n_words': 258}