<commit_before>const express = require('express'),
	app = express(),
	bodyParser = require('body-parser'),
	morgan = require('morgan'),
	toml = require('toml'),
	fs = require('fs'),
	settings = toml.parse(fs.readFileSync('./settings.toml')),
	Database = require('./structures/Database'),
	mailTransport = require('./structures/mailTransport'),
	db = new Database(settings.mongo),
	raven = require('raven');

mailTransport.config({ from: settings.email.from });

if (process.env.NODE_ENV === 'production') {
	raven.disableConsoleAlerts();
	raven.config(settings.raven.url, {
		release: (require('./package.json')).version,
		autoBreadcrumbs: { 'http': true },
		captureUnhandledRejections: true
	}).install();
}

app.set('trust proxy', 'loopback');
app.set('env', 'production');
app.disable('x-powered-by');

app.locals.jwt_signingkey = fs.readFileSync(__dirname + '/jwt_signingkey.key');

app.use(raven.requestHandler());
app.use(raven.errorHandler());
app.use(morgan(':req[cf-connecting-ip] :method :url :status :response-time[0]ms', {
	skip: (req, res) => res.statusCode < 400 // Only log failed requests/responses
}));
// Parse data into req.body
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));

// In dev we need a way to get images
if (process.env.NODE_ENV === 'development') {
	app.use('/image', express.static('image', { index: false, extensions: ['jpg'] }));
	app.use((req, res, next) => {
		res.set('Access-Control-Allow-Origin', '*');
		res.set('Access-Control-Allow-Credentials', 'true');
		res.set('Access-Control-Allow-Methods', 'GET,HEAD,OPTIONS,POST,PUT');
		res.set('Access-Control-Allow-Headers', 'Access-Control-Allow-Headers, Origin,Accept, X-Requested-With, Content-Type, Access-Control-Request-Method, Access-Control-Request-Headers, Authorization');
		return next();
	});
}

// Load in the routes for express
let apiv1 = new (require('./api/v1/Router.js'))(settings, db, mailTransport);
app.use(apiv1.path, apiv1.router);

// Start the express server
app.listen(settings.port, error => {
	if (error)
		return console.log(error)
	console.log('Server online');
});
<commit_msg>Fix headers<commit_after>const express = require('express'),
	app = express(),
	bodyParser = require('body-parser'),
	morgan = require('morgan'),
	toml = require('toml'),
	fs = require('fs'),
	settings = toml.parse(fs.readFileSync('./settings.toml')),
	Database = require('./structures/Database'),
	mailTransport = require('./structures/mailTransport'),
	db = new Database(settings.mongo),
	raven = require('raven');

mailTransport.config({ from: settings.email.from });

if (process.env.NODE_ENV === 'production') {
	raven.disableConsoleAlerts();
	raven.config(settings.raven.url, {
		release: (require('./package.json')).version,
		autoBreadcrumbs: { 'http': true },
		captureUnhandledRejections: true
	}).install();
}

app.set('trust proxy', 'loopback');
app.set('env', 'production');
app.disable('x-powered-by');

app.locals.jwt_signingkey = fs.readFileSync(__dirname + '/jwt_signingkey.key');

app.use(raven.requestHandler());
app.use(raven.errorHandler());
app.use(morgan(':req[cf-connecting-ip] :method :url :status :response-time[0]ms', {
	skip: (req, res) => res.statusCode < 400 // Only log failed requests/responses
}));
// Parse data into req.body
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));

// In dev we need a way to get images
if (process.env.NODE_ENV === 'development')
	app.use('/image', express.static('image', { index: false, extensions: ['jpg'] }));

app.use((req, res, next) => {
	res.set('Access-Control-Allow-Origin', '*');
	res.set('Access-Control-Allow-Credentials', 'true');
	res.set('Access-Control-Allow-Methods', 'GET,OPTIONS,POST,PUT');
	res.set('Access-Control-Allow-Headers', 'Access-Control-Allow-Headers, Origin, Accept, X-Requested-With, Content-Type, Access-Control-Request-Method, Access-Control-Request-Headers, Authorization');
	return next();
});

// Load in the routes for express
let apiv1 = new (require('./api/v1/Router.js'))(settings, db, mailTransport);
app.use(apiv1.path, apiv1.router);

// Start the express server
app.listen(settings.port, error => {
	if (error)
		return console.log(error)
	console.log('Server online');
});

{'fraction_non_alphanumeric': 0.19448373408769448, 'fraction_numerical': 0.003771805752003772, 'mean_word_length': 5.4581430745814306, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, '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': '3537917', 'n_tokens_mistral': 1423, 'n_tokens_neox': 1403, 'n_words': 272}