<commit_before>// node module requires
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 exphbs = require('express-handlebars');
const defines = require('./defines');
const bcrypt = require('bcryptjs');

// adding for passport use
const methodOverride = require('method-override');
const session = require('express-session');
const passport = require('passport');
const LocalStrategy = require('passport-local');
const TwitterStrategy = require('passport-twitter');
const GoogleStrategy = require('passport-google-oauth').OAuth2Strategy;
const FacebookStrategy = require('passport-facebook');
const User = require('./models/user.js');

const passortHelpers = require('./helpers/passport-functions.js'); // contains our helper functions for our Passport and database work

const app = express();
const http = require('http').Server(app);
const io = require('socket.io')(http);
const sockets = require('./sockets.js');
const publicDirPath = __dirname + '/public';
const app_root_path = require('app-root-path').path;

// database requires
const mongo = require('mongoskin');
const Database = require('./database.js');
const database = Object.create(Database).init();
const db = mongo.db('mongodb://localhost:27017/fuse');
const userdb = db.collection('user');

const cronjobs = require('./cronjobs');
const userNotificationsManager = require('./user-notifications-manager.js');

// view engine setup - currently uses Handlebars
app.set('views', path.join(__dirname, 'views'));

var hbs = exphbs.create({
    helpers: require('./helpers/handlebars.js'),
    extname: '.hbs',
    layoutsDir: './views/',
    defaultLayout: 'layout'
});

app.engine('hbs', hbs.engine);
app.set('view engine', 'hbs');

//===============SOCKET RELATED=================
//

// TODO: rename to a more specific name that pertains to its purpose (for ex: chat-hub)
sockets(io);
// handle socket chat events for notifications
userNotificationsManager(io);

//===============MIDDLEWARE=================
// see: http://expressjs.com/guide/using-middleware.html

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

// added for passport usage
app.use(methodOverride('X-HTTP-Method-Override'));
app.use(session({secret: 'supernova', saveUninitialized: true, resave: true}));
app.use(passport.initialize());
app.use(passport.session());

// sockets middleware
// make the io object available on every req at `req.io`
app.use(function(req, res, next) {
    req.io = io;
    next();
});

// added for passport use
// Session-persisted message middleware
app.use(function(req, res, next){
  var err = req.session.error,
      msg = req.session.notice,
      success = req.session.success;

  delete req.session.error;
  delete req.session.success;
  delete req.session.notice;

  if (err) res.locals.error = err;
  if (msg) res.locals.notice = msg;
  if (success) res.locals.success = success;

  next();
});

app.use(lessMiddleware(path.join(publicDirPath)));
app.use(express.static(path.join(publicDirPath)));
app.use('/bower_components',  express.static(__dirname + '/bower_components'));

//===============PASSPORT=================
// Passport session setup.

passport.serializeUser(function(user, done) {
  // console.log("passport: serializing ", user);
  done(null, user);
});

passport.deserializeUser(function(obj, done) {
  // console.log("passport: deserializing ", obj);
  done(null, obj);
});

passport.use(new GoogleStrategy({
    'clientID'      : '403805483120-n9nfegk2jgdget7r6svcmahas1fqkjtr.apps.googleusercontent.com',
    'clientSecret'  : '<KEY>',
    'callbackURL'   : 'http://172.16.17.32/auth/google/callback'<commit_msg>Change Google login callback from raw IP address to fuse-chat.tk<commit_after>// node module requires
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 exphbs = require('express-handlebars');
const defines = require('./defines');
const bcrypt = require('bcryptjs');

// adding for passport use
const methodOverride = require('method-override');
const session = require('express-session');
const passport = require('passport');
const LocalStrategy = require('passport-local');
const TwitterStrategy = require('passport-twitter');
const GoogleStrategy = require('passport-google-oauth').OAuth2Strategy;
const FacebookStrategy = require('passport-facebook');
const User = require('./models/user.js');

const passortHelpers = require('./helpers/passport-functions.js'); // contains our helper functions for our Passport and database work

const app = express();
const http = require('http').Server(app);
const io = require('socket.io')(http);
const sockets = require('./sockets.js');
const publicDirPath = __dirname + '/public';
const app_root_path = require('app-root-path').path;

// database requires
const mongo = require('mongoskin');
const Database = require('./database.js');
const database = Object.create(Database).init();
const db = mongo.db('mongodb://localhost:27017/fuse');
const userdb = db.collection('user');

const cronjobs = require('./cronjobs');
const userNotificationsManager = require('./user-notifications-manager.js');

// view engine setup - currently uses Handlebars
app.set('views', path.join(__dirname, 'views'));

var hbs = exphbs.create({
    helpers: require('./helpers/handlebars.js'),
    extname: '.hbs',
    layoutsDir: './views/',
    defaultLayout: 'layout'
});

app.engine('hbs', hbs.engine);
app.set('view engine', 'hbs');

//===============SOCKET RELATED=================
//

// TODO: rename to a more specific name that pertains to its purpose (for ex: chat-hub)
sockets(io);
// handle socket chat events for notifications
userNotificationsManager(io);

//===============MIDDLEWARE=================
// see: http://expressjs.com/guide/using-middleware.html

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

// added for passport usage
app.use(methodOverride('X-HTTP-Method-Override'));
app.use(session({secret: 'supernova', saveUninitialized: true, resave: true}));
app.use(passport.initialize());
app.use(passport.session());

// sockets middleware
// make the io object available on every req at `req.io`
app.use(function(req, res, next) {
    req.io = io;
    next();
});

// added for passport use
// Session-persisted message middleware
app.use(function(req, res, next){
  var err = req.session.error,
      msg = req.session.notice,
      success = req.session.success;

  delete req.session.error;
  delete req.session.success;
  delete req.session.notice;

  if (err) res.locals.error = err;
  if (msg) res.locals.notice = msg;
  if (success) res.locals.success = success;

  next();
});

app.use(lessMiddleware(path.join(publicDirPath)));
app.use(express.static(path.join(publicDirPath)));
app.use('/bower_components',  express.static(__dirname + '/bower_components'));

//===============PASSPORT=================
// Passport session setup.

passport.serializeUser(function(user, done) {
  // console.log("passport: serializing ", user);
  done(null, user);
});

passport.deserializeUser(function(obj, done) {
  // console.log("passport: deserializing ", obj);
  done(null, obj);
});

passport.use(new GoogleStrategy({
    'clientID'      : '403805483120-n9nfegk2jgdget7r6svcmahas1fqkjtr.apps.googleusercontent.com',
    'clientSecret'  : '<KEY>',
    'callbackURL'   : 'http://fuse-chat.tk/auth/google/callback'
{'fraction_non_alphanumeric': 0.18288824199468423, 'fraction_numerical': 0.0069611441589672194, 'mean_word_length': 5.236779794790844, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 1, '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': '7157218', 'n_tokens_mistral': 2413, 'n_tokens_neox': 2358, 'n_words': 556}