-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
48 lines (36 loc) · 1.11 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
47
48
require("dotenv").config();
const express = require('express');
const session = require('express-session');
const { engine } = require('express-handlebars');
const passport = require('passport');
const passportConfig = require('./config/passport');
const PORT = process.env.PORT || 3001;
const routes = require('./controllers');
const db = require('./config/connection');
// add api/hbc routes
const app = express();
app.engine('hbs', engine({
extname: '.hbs',
}));
app.set('view engine', 'hbs');
app.set('views', './views');
app.use(express.json());
app.use(express.urlencoded({ extended: true }));
app.use(express.static('public'));
app.use(session({
secret: process.env.SESSION_SECRET,
resave: false,
saveUninitialized: false,
}));
passportConfig(passport);
app.use(passport.session({
}));
app.use("/", [routes]);
// app.engine('hbs', engine({
// extname: '.hbs' // change the file extension from .handlebars to .hbs
// }));
// app.set('view engine', 'hbs');
// app.set('/'); // add routes in here when done
db.sync().then(() => {
app.listen(PORT, () => console.log('Server started on port %s', PORT));
});