<commit_before>var express = require('express');
var bodyParser = require('body-parser');
var path = require('path');
var favicon = require('serve-favicon');
var morgan_logger = require('morgan');
var cookieParser = require('cookie-parser');
var express_logger = require('./express_logger');

module.exports = function(config, logger) {
  var app = express();

  if (config.views_folder) {
    app.set('views', path.join(__dirname, config.views_folder));
    app.set('view engine', 'jade');
  }

  if (config.favicon_path) {
    app.use(favicon(__dirname + config.favicon_path));
  }

  app.use(express_logger.express_logger(logger));
  app.use(morgan_logger('dev'));
  app.use(bodyParser.json());
  app.use(bodyParser.urlencoded({ extended: false }));
  app.use(cookieParser());

  if (config.static_folder) {
    app.use(express.static(path.join(__dirname, config.static_folder)));
  }

  /*var routes = require('./routes/index');
  var users = require('./routes/users');
  app.use('/', routes);
  app.use('/users', users); */

  app.get('/ping', function(request, response){
    response.send(200, 'pong');
  });

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

  // error handlers


  if (config.is_production) { //production error handler - no stacktraces leaked to user
    app.use(function(err, req, res, next) {
      res.status(err.status || 500).json({
        message: err.message,
        error: {}
      });
    });
  } else { // development & test error handler - will print stacktrace
    app.use(function(err, req, res, next) {
      res.status(err.status || 500).json({
        message: err.message,
        error: err
      });
    });
  }<commit_msg>fixed depricated method<commit_after>var express = require('express');
var bodyParser = require('body-parser');
var path = require('path');
var favicon = require('serve-favicon');
var morgan_logger = require('morgan');
var cookieParser = require('cookie-parser');
var express_logger = require('./express_logger');

module.exports = function(config, logger) {
  var app = express();

  if (config.views_folder) {
    app.set('views', path.join(__dirname, config.views_folder));
    app.set('view engine', 'jade');
  }

  if (config.favicon_path) {
    app.use(favicon(__dirname + config.favicon_path));
  }

  app.use(express_logger.express_logger(logger));
  app.use(morgan_logger('dev'));
  app.use(bodyParser.json());
  app.use(bodyParser.urlencoded({ extended: false }));
  app.use(cookieParser());

  if (config.static_folder) {
    app.use(express.static(path.join(__dirname, config.static_folder)));
  }

  /*var routes = require('./routes/index');
  var users = require('./routes/users');
  app.use('/', routes);
  app.use('/users', users); */

  app.get('/ping', function(request, response){
    response.status(200).send('pong');
  });

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

  // error handlers


  if (config.is_production) { //production error handler - no stacktraces leaked to user
    app.use(function(err, req, res, next) {
      res.status(err.status || 500).json({
        message: err.message,
        error: {}
      });
    });
  } else { // development & test error handler - will print stacktrace
    app.use(function(err, req, res, next) {
      res.status(err.status || 500).json({
        message: err.message,
        error: err
      });
    });
  }
{'fraction_non_alphanumeric': 0.1723849372384937, 'fraction_numerical': 0.008368200836820083, 'mean_word_length': 3.510691823899371, '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': '5729524', 'n_tokens_mistral': 1174, 'n_tokens_neox': 1118, 'n_words': 245}