forked from infinity-machine/fitspace
-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
34 lines (30 loc) · 1.02 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
const express = require('express');
const path = require('path');
const { engine } = require('express-handlebars');
const PORT = process.env.PORT || 3333;
const db = require('./config/db_connection');
const session = require('express-session');
const SequelizeStore = require('connect-session-sequelize')(session.Store);
require('dotenv').config();
const { view_routes, auth_routes, post_routes } = require('./controllers/index');
const app = express();
app.use(express.static(path.join('browser')));
app.engine('hbs', engine({ extname: '.hbs' }));
app.set('view engine', 'hbs');
app.use(express.json());
app.use(express.urlencoded({ extended: false }));
app.use(session({
secret: process.env.SESSION_SECRET,
store: new SequelizeStore({ db }),
saveUninitialized: false,
resave: false,
cookie: {
// httpOnly: true
}
}));
app.use('/', view_routes);
app.use('/auth', auth_routes);
app.use('/posts', post_routes);
db.sync().then(() => {
app.listen(PORT, () => console.log(`LISTENING ON PORT ${PORT}`));
});