import compression from 'compression';
import Express from 'express';
import path from 'path';
import fs from 'fs';
import Raven from 'raven';
import bodyParser from 'body-parser';

import loadDotEnv from './config/env';

process.env.NODE_ENV = process.env.NODE_ENV || 'development';
const appDirectory = fs.realpathSync(process.cwd());

loadDotEnv(appDirectory);

if (process.env.RAVEN_DSN) {
  Raven.config(process.env.RAVEN_DSN, {
    captureUnhandledRejections: true,
  }).install();
}
// Any files that exist can be accessed directly.
// If the server has been compiled, the path will be different.
const buildFolder = path.basename(appDirectory) === 'build' ? path.join(appDirectory, '..', '..', 'build') : path.join(appDirectory, '..', 'build');

const app = Express();

if (Raven.installed) {
  // The Raven request handler must be the first middleware on the app
  app.use(Raven.requestHandler());
  // The error handler must be before any other error middleware
  app.use(Raven.errorHandler());
}
app.use(compression());
app.use(Express.static(buildFolder));
app.use(bodyParser.urlencoded({ extended: false }));

app.use(require('./controllers').default);

app.listen(process.env.PORT, () => {
  console.log(`Listening to port ${process.env.PORT}`);
});

@@ -147,36 +147,108 @@
 ort 
-bodyParser from 'body-parser
+session from 'express-session';%0Aimport bodyParser from 'body-parser';%0Aimport Passport from 'passport
 ';%0A%0A
@@ -1138,60 +1138,695 @@
 ));%0A
-app.use(bodyParser.urlencoded(%7B extended: false %7D));
+let sessionSecret = process.env.SESSION_SECRET;%0Aif (!sessionSecret) %7B%0A  if (process.env.NODE_ENV === 'production') %7B%0A    throw new Error('Missing environment variable: SESSION_SECRET. You should set this in the %60.env.production.local%60 file.');%0A  %7D else %7B%0A    sessionSecret = 'somesecrettoken';%0A  %7D%0A%7D%0Aapp.use(session(%7B%0A  secret: sessionSecret,%0A  resave: false,%0A  saveUninitialized: false,%0A%7D));%0Aapp.use(bodyParser.urlencoded(%7B extended: false %7D));%0A%0A// region Authentication%0Aapp.use(Passport.initialize());%0Aapp.use(Passport.session());%0APassport.serializeUser(function(user, done) %7B%0A  done(null, user);%0A%7D);%0APassport.deserializeUser(function(user, done) %7B%0A  done(null, user);%0A%7D);%0A// endregion
 %0A%0Aap

Revert "Disable session and Passport usage"