<commit_before>
/*!
 * Module dependencies.
 */

var express = require("express");
var i18n = require("i18n-2");
var mongoStore = require("connect-mongo")(express);
var helpers = require("view-helpers");
var pkg = require("../package");
var flash = require("connect-flash");
var env = process.env.NODE_ENV || "development";
var swig = require("swig");
var path = require("path");
var rootPath = path.resolve(__dirname + "../..");

/*!
 * Expose
 */

module.exports = function(app, passport) {
    // Add basic auth for staging
    if (env === "staging") {
        app.use(express.basicAuth(function(user, pass) {
            return "username" === user & "password" === pass;
        }));

        app.use(function (req, res, next) {
            if (req.remoteUser && req.user && !req.user._id) {
                delete req.user;
            }
            next();
        });
    }

    var CDN = require("express-cdn")(app, {
        publicDir: rootPath + "/public",
        viewsDir: rootPath + "/app/views",
        extensions: [".swig"],
        domain: process.env.S3_STATIC_BUCKET,
        bucket: process.env.S3_STATIC_BUCKET,
        key: process.env.S3_KEY,
        secret: process.env.S3_SECRET,
        ssl: false,
        production: env === "production"
    });

    app.set("showStackError", true);

    // use express favicon
    app.use(express.favicon());

    app.use(express.static(rootPath + "/public"));
    app.use(express.logger("dev"));

    app.engine("swig", swig.renderFile)

    // views config
    app.set("views", rootPath + "/app/views");
    app.set("view engine", "swig");

    app.set("view cache", false);
    swig.setDefaults({ cache: false });

    // bodyParser should be above methodOverride
    app.use(express.bodyParser());
    app.use(express.methodOverride());

    // cookieParser should be above session
    app.use(express.cookieParser());
    app.use(express.session({
        secret: pkg.name,
        store: new mongoStore({
            url: process.env.MONGODB_URL,
            collection: "sessions"
        })
    }));

    // Passport session<commit_msg>Use method-override module instead of deprecated connect methodOverride.<commit_after>
/*!
 * Module dependencies.
 */

var express = require("express");
var i18n = require("i18n-2");
var mongoStore = require("connect-mongo")(express);
var methodOverride = require("method-override");
var helpers = require("view-helpers");
var pkg = require("../package");
var flash = require("connect-flash");
var env = process.env.NODE_ENV || "development";
var swig = require("swig");
var path = require("path");
var rootPath = path.resolve(__dirname + "../..");

/*!
 * Expose
 */

module.exports = function(app, passport) {
    // Add basic auth for staging
    if (env === "staging") {
        app.use(express.basicAuth(function(user, pass) {
            return "username" === user & "password" === <PASSWORD>;
        }));

        app.use(function (req, res, next) {
            if (req.remoteUser && req.user && !req.user._id) {
                delete req.user;
            }
            next();
        });
    }

    var CDN = require("express-cdn")(app, {
        publicDir: rootPath + "/public",
        viewsDir: rootPath + "/app/views",
        extensions: [".swig"],
        domain: process.env.S3_STATIC_BUCKET,
        bucket: process.env.S3_STATIC_BUCKET,
        key: process.env.S3_KEY,
        secret: process.env.S3_SECRET,
        ssl: false,
        production: env === "production"
    });

    app.set("showStackError", true);

    // use express favicon
    app.use(express.favicon());

    app.use(express.static(rootPath + "/public"));
    app.use(express.logger("dev"));

    app.engine("swig", swig.renderFile)

    // views config
    app.set("views", rootPath + "/app/views");
    app.set("view engine", "swig");

    app.set("view cache", false);
    swig.setDefaults({ cache: false });

    // bodyParser should be above methodOverride
    //app.use(express.bodyParser());
    app.use(methodOverride());

    // cookieParser should be above session
    app.use(express.cookieParser());
    app.use(express.session({
        secret: pkg.name,
        store: new mongoStore({
            url: process.env.MONGODB_URL,
            collection: "sessions"
        })
    }));

    // Passport session
{'fraction_non_alphanumeric': 0.16473854696899584, 'fraction_numerical': 0.0041647385469689956, 'mean_word_length': 2.555098684210526, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, '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': '7273758', 'n_tokens_mistral': 1348, 'n_tokens_neox': 1306, 'n_words': 285}