-
Notifications
You must be signed in to change notification settings - Fork 2
/
server.js
33 lines (27 loc) · 1.03 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
require("dotenv").config();
const express = require('express');
const session = require("express-session");
const cookieParser = require("cookie-parser")
const flash = require('express-flash')
const path = require('path');
const passport = require("./config/passport.js");
// Sets up the Express App
const app = express();
const PORT = process.env.PORT || 8080;
// Requiring our models for syncing
const db = require('./models');
// Sets up the Express app to handle data parsing
app.use(express.urlencoded({ extended: true }));
app.use(express.json());
app.use(express.static('public'));
app.use(cookieParser());
app.use(session({ secret: "cheesy mcgee", cookie: { maxAge: 600000 }, resave: true, saveUninitialized: true }));
app.use(passport.initialize());
app.use(passport.session());
app.use(flash());
require('./routes/api-routes.js')(app);
require('./routes/html-routes.js')(app);
//add {force: true} to reset tablex
db.sequelize.sync().then(() => {
app.listen(PORT, () => console.log(`Server listening on: http://localhost:${PORT}`));
});