<commit_before>'use strict';

require('./lib/memory');

var express = require('express');
var util = require('util');
var utils = require('./utils');
var mongoose = require('mongoose');
var async = require('async');
var domain = require('domain');
var auth = require("connect-auth");
var formage_admin = require('formage-admin');
var config = require('./config');
formage_admin.forms.loadTypes(mongoose);



var app = module.exports = express();
app.set('show_only_published', process.env.SHOW_ONLY_PUBLISHED == '1');
utils.setShowOnlyPublished(app.settings.show_only_published);

var logout_handler = require("connect-auth/lib/events").redirectOnLogout("/");
var account = require('./routes/account');
var fb_bot_middleware = require('./routes/fb_bot/middleware');

// ########### Static parameters ###########
var IS_ADMIN = true;

var IS_PROCESS_CRON = (process.argv[2] === 'cron');
var IS_PROCESS_WEB = !IS_PROCESS_CRON;

var auth_middleware = auth({
    strategies: [
        account.SimpleAuthentication(),
        account.FbServerAuthentication(),
        auth.Facebook(config.fb_auth_params)
    ],
    trace: true,
    logoutHandler: logout_handler
});
// ########### Static parameters ###########


// Run some compilations
require('./tools/compile_dust_templates');



// ######### connect to DB #########
if (!mongoose.connection.host) {
    mongoose.connect(config.DB_URL, {safe: true}, function (db) { console.log("connected to db %s:%s/%s", mongoose.connection.host, mongoose.connection.port, mongoose.connection.name); });
    mongoose.connection.on('error', function (err) { console.error('db connection error: ', err); });
    mongoose.connection.on('disconnected', function (err) {
        console.error('DB disconnected', err);
        setTimeout(function () {mongoose.connect(config.DB_URL, function (err) { if (err) console.error(err); });}, 200);
    });
}
// ######### end connect to DB #########



// ######### settings #########

app.settings['x-powered-by'] = 'Empeeric';
app.set('views', __dirname + '/views');
app.set('public_folder', __dirname + '/public');
app.set('port', process.env.PORT || 8080);
app.set('facebook_app_id', config.fb_auth_params.appId);
app.set('facebook_secret', config.fb_auth_params.appSecret);
app.set('facebook_app_name', config.fb_auth_params.appName);

// TODO delete?
app.set('facebook_pages_admin_user', "<EMAIL>");
app.set('facebook_pages_admin_pass', "<PASSWORD>");
//

app.set('sendgrid_user', process.env.SENDGRID_USER || config.sendgrid_user);
app.set('sendgrid_key',process.env.SENDGRID_KEY || config.sendgrid_key);
app.set('root_path', config.ROOT_PATH);

// TODO delete?
app.set('url2png_api_key', process.env.url2png_api_key || 'P503113E58ED4A');
app.set('url2png_api_secret', process.env.url2png_api_key || '<KEY>');
//

app.set('send_mails', true);
app.set('view engine', 'jade');<commit_msg>CAHNGE PORT<commit_after>'use strict';

require('./lib/memory');

var express = require('express');
var util = require('util');
var utils = require('./utils');
var mongoose = require('mongoose');
var async = require('async');
var domain = require('domain');
var auth = require("connect-auth");
var formage_admin = require('formage-admin');
var config = require('./config');
formage_admin.forms.loadTypes(mongoose);



var app = module.exports = express();
app.set('show_only_published', process.env.SHOW_ONLY_PUBLISHED == '1');
utils.setShowOnlyPublished(app.settings.show_only_published);

var logout_handler = require("connect-auth/lib/events").redirectOnLogout("/");
var account = require('./routes/account');
var fb_bot_middleware = require('./routes/fb_bot/middleware');

// ########### Static parameters ###########
var IS_ADMIN = true;

var IS_PROCESS_CRON = (process.argv[2] === 'cron');
var IS_PROCESS_WEB = !IS_PROCESS_CRON;

var auth_middleware = auth({
    strategies: [
        account.SimpleAuthentication(),
        account.FbServerAuthentication(),
        auth.Facebook(config.fb_auth_params)
    ],
    trace: true,
    logoutHandler: logout_handler
});
// ########### Static parameters ###########


// Run some compilations
require('./tools/compile_dust_templates');



// ######### connect to DB #########
if (!mongoose.connection.host) {
    mongoose.connect(config.DB_URL, {safe: true}, function (db) { console.log("connected to db %s:%s/%s", mongoose.connection.host, mongoose.connection.port, mongoose.connection.name); });
    mongoose.connection.on('error', function (err) { console.error('db connection error: ', err); });
    mongoose.connection.on('disconnected', function (err) {
        console.error('DB disconnected', err);
        setTimeout(function () {mongoose.connect(config.DB_URL, function (err) { if (err) console.error(err); });}, 200);
    });
}
// ######### end connect to DB #########



// ######### settings #########

app.settings['x-powered-by'] = 'Empeeric';
app.set('views', __dirname + '/views');
app.set('public_folder', __dirname + '/public');
app.set('port', process.env.PORT || 80);
app.set('facebook_app_id', config.fb_auth_params.appId);
app.set('facebook_secret', config.fb_auth_params.appSecret);
app.set('facebook_app_name', config.fb_auth_params.appName);

// TODO delete?
app.set('facebook_pages_admin_user', "<EMAIL>");
app.set('facebook_pages_admin_pass', "<PASSWORD>");
//

app.set('sendgrid_user', process.env.SENDGRID_USER || config.sendgrid_user);
app.set('sendgrid_key',process.env.SENDGRID_KEY || config.sendgrid_key);
app.set('root_path', config.ROOT_PATH);

// TODO delete?
app.set('url2png_api_key', process.env.url2png_api_key || 'P503113E58ED4A');
app.set('url2png_api_secret', process.env.url2png_api_key || 'SF1BFA95A57BE4');
//

app.set('send_mails', true);
app.set('view engine', 'jade');
{'fraction_non_alphanumeric': 0.20233734519448804, 'fraction_numerical': 0.00837257980115123, 'mean_word_length': 5.545662100456621, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4339001', 'n_tokens_mistral': 1906, 'n_tokens_neox': 1887, 'n_words': 326}