text: 'use strict';
  
  const express = require('express');
  // const logger = require('morgan');
  const path = require('path');
  const cookieParser = require('cookie-parser');
  const bodyParser = require('body-parser');
  const next = require('./next');
  
  const routes = require('./server/routes/index.js');
  const mongoose = require('mongoose');
  const passport = require('passport');
  const session = require('express-session');
  const helmet = require('helmet');
  
  const app = express();
  require('dotenv').load();
  require('./server/config/passport')(passport);
  
  mongoose.connect(process.env.MONGO_URI);
  mongoose.Promise = global.Promise;
  
  // Put in place textbook middlewares for express.
  if (process.env.NODE_ENV !== 'production') {
      // app.use(logger('dev'));
  }
  
  app.use(helmet());
  app.disable('x-powered-by');
  
  app.use(session({
      secret: 'something',
      resave: false,
      saveUninitialized: true
  }));
  
  app.use(passport.initialize());
  app.use(passport.session());
  app.use(bodyParser.urlencoded({ extended: false }));
  app.use(express.json());
  // app.use(cookieParser());
  app.use('/', express.static(path.join(__dirname, 'public')));
  
  
  const start = async (port) => {
      // Couple Next.js with our express server.
      // app and handle from "next" will now be available as req.app and req.handle.
      await next(app);
      
      // Normal routing, if you need it.
      // Use your SSR logic here.
      // Even if you don't do explicit routing the pages inside app/pages
      // will still get rendered as per their normal route.
      routes(app, passport);
  
      app.listen(port);
  };
  
  // Start the express server.
  start(process.env.PORT);
  