Skip to content

Instantly share code, notes, and snippets.

@gemanor
Last active August 22, 2019 13:36
Show Gist options
  • Select an option

  • Save gemanor/bea8c5645fd32e757d80c7d2300de063 to your computer and use it in GitHub Desktop.

Select an option

Save gemanor/bea8c5645fd32e757d80c7d2300de063 to your computer and use it in GitHub Desktop.
index.js for social login demo
// Import the .env file and assign all vars as env. vars
require('dotenv').config();
// Import required packages
var express = require('express');
var partials = require('express-partials')
var passportConfig = require('./src/passport');
const routes = require('./src/routes');
// Create a new Express application.
var app = express();
// Configure view engine to render EJS templates.
app.set('views', __dirname + '/src/views');
app.set('view engine', 'ejs');
app.use(partials());
// Configure express application to work with cookies and session
app.use(require('cookie-parser')());
app.use(require('body-parser').urlencoded({ extended: true }));
app.use(require('express-session')({ secret: 'keyboard cat', resave: true, saveUninitialized: true }));
// Add all passport strategies to our app
passportConfig(app);
// Load all route configuration to the application
routes(app);
// Start a server listening on configured port or on 3001
app.listen(process.env['PORT'] || 3001, (...args) => {
console.log('App is listening', args)
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment