<commit_before>import bodyParser from 'body-parser';
import Express from 'express';
import fs from 'fs';
import mongoose from 'mongoose';
import morgan from 'morgan';
import path from 'path';
import winston from 'winston';
import config from './config';

import logInRoute from './routes/log-in-route';
import itemRoute from './routes/item-route';
import registrationRoute from './routes/registration-route';
import userRoute from './routes/user-route';

import accessChecker from './middlewares/access-checker';
import jsonChecker from './middlewares/json-checker';

const app = new Express();
const cfg = config();

// Configure logger
winston.configure({
    exitOnError: false,
    transports: [
        new (winston.transports.Console)({
            timestamp: () => Date.now()
        }),
        new (winston.transports.File)({
            timestamp: () => Date.now(),
            filename: 'logs/server.log'
        })
    ]
});

// Configure app
app.use(bodyParser.urlencoded({extended: false}));
app.use(bodyParser.json());
app.use(Express.static(path.resolve(__dirname, '../build/assets')));
// app.use(accessChecker(app));
app.use(jsonChecker);
app.set('logger', winston);

if(process.env.NODE_ENV !== 'production') {
    app.use(morgan('dev'));
}

// Connect to database
mongoose.promise = global.Promise;
mongoose.connect(cfg.DATABASE, {useMongoClient: true});

// Add routes
logInRoute(app);
itemRoute(app);
registrationRoute(app);
userRoute(app);

// Run app
app.listen(cfg.PORT, () => {
    if(!fs.existsSync('logs/server.log')) {
        fs.mkdir('logs');
        fs.writeFile('logs/server.log', '', (err) => {<commit_msg>Uncommented access checker MW<commit_after>import bodyParser from 'body-parser';
import Express from 'express';
import fs from 'fs';
import mongoose from 'mongoose';
import morgan from 'morgan';
import path from 'path';
import winston from 'winston';
import config from './config';

import logInRoute from './routes/log-in-route';
import itemRoute from './routes/item-route';
import registrationRoute from './routes/registration-route';
import userRoute from './routes/user-route';

import accessChecker from './middlewares/access-checker';
import jsonChecker from './middlewares/json-checker';

const app = new Express();
const cfg = config();

// Configure logger
winston.configure({
    exitOnError: false,
    transports: [
        new (winston.transports.Console)({
            timestamp: () => Date.now()
        }),
        new (winston.transports.File)({
            timestamp: () => Date.now(),
            filename: 'logs/server.log'
        })
    ]
});

// Configure app
app.use(bodyParser.urlencoded({extended: false}));
app.use(bodyParser.json());
app.use(Express.static(path.resolve(__dirname, '../build/assets')));
app.use(accessChecker(app));
app.use(jsonChecker);
app.set('logger', winston);

if(process.env.NODE_ENV !== 'production') {
    app.use(morgan('dev'));
}

// Connect to database
mongoose.promise = global.Promise;
mongoose.connect(cfg.DATABASE, {useMongoClient: true});

// Add routes
logInRoute(app);
itemRoute(app);
registrationRoute(app);
userRoute(app);

// Run app
app.listen(cfg.PORT, () => {
    if(!fs.existsSync('logs/server.log')) {
        fs.mkdir('logs');
        fs.writeFile('logs/server.log', '', (err) => {
{'fraction_non_alphanumeric': 0.16884300030367447, 'fraction_numerical': 0.0, 'mean_word_length': 3.9385307346326837, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '7171722', 'n_tokens_mistral': 1025, 'n_tokens_neox': 1031, 'n_words': 231}