<commit_before>const express = require('express');
const path = require('path');
const favicon = require('serve-favicon');
const logger = require('morgan');
const cookieParser = require('cookie-parser');
const bodyParser = require('body-parser');
const lessMiddleware = require('less-middleware');
const config = require('./config');
const controllers = require('./controllers');
const index = require('./routes/index');
const passport = require('passport');
const flash = require('connect-flash');
const session = require('express-session');

require('./config/passport')(passport);

config.mongoose.connection.on('open', () => {
  console.info('Connected to Mongo DB');
});

const app = express();

// view engine setup
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'hbs');

// uncomment after placing your favicon in /public
app.use(favicon(path.join(__dirname, 'public', 'favicon.ico')));
app.use(logger('dev'));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(cookieParser());
app.use(lessMiddleware(path.join(__dirname, 'public')));
app.use(express.static(path.join(__dirname, 'public')));

//this is for authentication
app.use(session({ secret: 'somethingsecret' }));
app.use(passport.initialize());
app.use(passport.session());
app.use(flash());
app.use(function(req, res, next) {
    res.locals.user = req.user; // This is the important line
    next();
});

// All the urls that start with api refer to endpoints
// their responses are usually json and not actual views
app.use('/api', controllers);
// the index views manages all the front end views, like
// forms, dashboards, etcs
app.use('/', index);

// catch 404 and forward to error handler
app.use(function(req, res, next) {
  const err = new Error('Not Found');
  err.status = 404;
  next(err);
});

// error handler
app.use(function(err, req, res) {<commit_msg>Fixed error on index.js / missing 404 page<commit_after>const express = require('express');
const path = require('path');
const favicon = require('serve-favicon');
const logger = require('morgan');
const cookieParser = require('cookie-parser');
const bodyParser = require('body-parser');
const lessMiddleware = require('less-middleware');
const config = require('./config');
const controllers = require('./controllers');
const index = require('./routes/index');
const passport = require('passport');
const flash = require('connect-flash');
const session = require('express-session');

require('./config/passport')(passport);

config.mongoose.connection.on('open', () => {
  console.info('Connected to Mongo DB');
});

const app = express();

// view engine setup
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'hbs');

// uncomment after placing your favicon in /public
app.use(favicon(path.join(__dirname, 'public', 'favicon.ico')));
app.use(logger('dev'));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(cookieParser());
app.use(lessMiddleware(path.join(__dirname, 'public')));
app.use(express.static(path.join(__dirname, 'public')));

//this is for authentication
app.use(session({ secret: 'somethingsecret' }));
app.use(passport.initialize());
app.use(passport.session());
app.use(flash());
app.use(function(req, res, next) {
    res.locals.user = req.user; // This is the important line
    next();
});

// All the urls that start with api refer to endpoints
// their responses are usually json and not actual views
app.use('/api', controllers);
// the index views manages all the front end views, like
// forms, dashboards, etcs
app.use('/', index);

// catch 404 and forward to error handler
app.use(function(req, res, next) {
  res.status = 404;
  next(res);
});

// error handler
app.use(function(err, req, res) {
{'fraction_non_alphanumeric': 0.17903353578030104, 'fraction_numerical': 0.003960918933192501, 'mean_word_length': 5.442176870748299, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '5224897', 'n_tokens_mistral': 1142, 'n_tokens_neox': 1120, 'n_words': 315}