require('dotenv').config();

const express = require('express');
const mongoose = require('./server/mongoose');
const bodyParser = require('body-parser');

const config = require('./server/_config.js');
const ErrorHandler = require('./server/controllers/ErrorHandler.js');

// ===== App Setup =====
const app = express();
// Might not need bodyParser.json()
app.use(bodyParser.json());
app.use(
  bodyParser.urlencoded({
    extended: true,
  })
);

// ===== Models =====
const Job = require('./server/models/Job.js');

// ===== Routes =====
const authRoute = require('./server/routes/authentication');
const userHandler = require('./server/routes/userHandler');

// ===== Server Setup =====
const PORT = process.env.PORT || 3001;

// ===== App Use Routes =====
//app.use(authRoute);
app.use('/api/v1', userHandler);

// ====== Error Handler Middleware =====
app.use(ErrorHandler);

module.exports = app.listen(PORT, () => {
  console.log('API listening on port ' + PORT);
});

@@ -54,24 +54,164 @@
 'express');%0A
+const LocalStrategy = require('passport-local').Strategy;%0Aconst passport = require('passport');%0Aconst session = require('express-session');%0A
 const mongoo
@@ -580,382 +580,1202 @@
 ,%0A  
-%7D)%0A);%0A%0A// ===== Models =====%0Aconst Job = require('./server/models/Job.js');%0A%0A// ===== Routes =====%0Aconst authRoute = require('./server/routes/authentication');%0Aconst userHandler = require('./server/routes/userHandler');%0A%0A// ===== Server Setup =====%0Aconst PORT = process.env.PORT %7C%7C 3001;%0A%0A// ===== App Use Routes =====%0A//app.use(authRoute);%0Aapp.use('/api/v1', userHandler);%0A
+session(%7B%0A    secret: 'supersecret',%0A    resave: true,%0A    saveUninitialized: true,%0A  %7D)%0A);%0A%0A// ===== Models =====%0Aconst Job = require('./server/models/Job.js');%0Aapp.use(passport.initialize());%0Aapp.use(passport.session());%0Apassport.use(User.createStrategy());%0A%0Apassport.serializeUser(User.serializeUser());%0Apassport.deserializeUser(User.deserializeUser());%0A%0A// ===== Routes =====%0Aconst authRoute = require('./server/routes/authentication');%0Aconst authController = require('./server/controllers/authController');%0Aconst userController = require('./server/controllers/userController');%0Aconst userHandler = require('./server/routes/userHandler');%0A%0A// ===== Server Setup =====%0Aconst PORT = process.env.PORT %7C%7C 3001;%0A%0A// ===== App Use Routes =====%0A//app.use(authRoute);%0Aapp.use('/api/v1', userHandler);%0A%0Aapp.get('/test-login/', authController.isLoggedIn, (req, res) =%3E %7B%0A  res.send(%60Logged in as $%7Breq.user.username%7D%60);%0A%7D);%0A%0Aapp.post(%0A  '/register/',%0A  userController.register,%0A  authController.login,%0A  (req, res) =%3E %7B%0A    res.json(%7B loggedIn: true %7D);%0A  %7D%0A);%0A%0Aapp.post('/login/', authController.login, (req, res) =%3E %7B%0A  res.send(%7B loggedIn: true %7D);%0A%7D);%0A%0Aapp.get('/logout/', authController.logout);
 %0A// 

Add passport and session