-
Notifications
You must be signed in to change notification settings - Fork 2
/
server.js
46 lines (32 loc) · 1.08 KB
/
server.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
const express = require("express");
const passport = require('passport');
const passportSetup = require('./config/passport-setup');
const cookieSession = require('cookie-session');
var app = express();
// set up a cookie age and a key you wanna encrypt it with
app.use(cookieSession({
maxAge: 1 * 60 * 60 * 1000,
keys: ['iGotTheKeys']
}))
// initalize passport
app.use(passport.initialize());
app.use(passport.session());
const routes = require("./routes");
var PORT = process.env.PORT || 3001;
// Requiring our models for syncing
var db = require("./models");
// Sets up the Express app to handle data parsing
app.use(express.urlencoded({ extended: true }));
app.use(express.json());
// Static directory
if (process.env.NODE_ENV === "production") {
app.use(express.static("client/build"));
}
app.use(routes);
// Syncing our sequelize models and then starting our Express app
// =============================================================
db.sequelize.sync({ force: false }).then(function () {
app.listen(PORT, function () {
console.log("App listening on PORT " + PORT);
});
});