forked from zachgoll/express-session-authentication-starter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
56 lines (39 loc) · 1.22 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
const express = require('express');
const mongoose = require('mongoose');
const session = require('express-session');
var passport = require('passport');
var crypto = require('crypto');
var routes = require('./routes');
const connection = require('./config/database');
// Package documentation - https://www.npmjs.com/package/connect-mongo
const MongoStore = require('connect-mongo')(session);
// Need to require the entire Passport config module so app.js knows about it
require('./config/passport');
/**
* -------------- GENERAL SETUP ----------------
*/
// Gives us access to variables set in the .env file via `process.env.VARIABLE_NAME` syntax
require('dotenv').config();
// Create the Express application
var app = express();
app.use(express.json());
app.use(express.urlencoded({extended: true}));
/**
* -------------- SESSION SETUP ----------------
*/
// TODO
/**
* -------------- PASSPORT AUTHENTICATION ----------------
*/
app.use(passport.initialize());
app.use(passport.session());
/**
* -------------- ROUTES ----------------
*/
// Imports all of the routes from ./routes/index.js
app.use(routes);
/**
* -------------- SERVER ----------------
*/
// Server listens on http://localhost:3000
app.listen(3000);