-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
42 lines (31 loc) · 1.11 KB
/
index.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
const express = require('express');
const { create } = require('express-handlebars');
const session = require('express-session');
const userSession = require('./middleware/userSession');
const databaseConfig = require('./config/database');
const authController = require('./controllers/auth');
const homeController = require('./controllers/home');
const tripController = require('./controllers/trip');
start();
async function start() {
const app = express();
app.engine('.hbs', create({ extname: '.hbs' }).engine);
app.set('view engine', '.hbs');
app.use('/static', express.static('static'));
app.use(session({
secret: 'secret',
resave: false,
saveUninitialized: true,
cookie: { secure: 'auto' }
}));
app.use(express.urlencoded({ extended: true }));
app.use(userSession());
await databaseConfig(app);
app.use(authController);
app.use(homeController);
app.use(tripController);
app.get('*', (req, res) => {
res.render('404', { title: 'Page Not Found' });
});
app.listen(3000, () => console.log('Server is running on port 3000'));
}