-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathindex.js
38 lines (32 loc) · 964 Bytes
/
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
const path = require('path');
const express = require('express');
const bodyParser = require('body-parser');
const session = require('express-session');
const cookieParser = require('cookie-parser');
const methodOverride = require('method-override');
const config = require('./config');
const routes = require('./routes/index.route');
const app = express();
app.use(bodyParser.json());
app.use(
bodyParser.urlencoded({
extended: true,
})
);
app.use(cookieParser());
app.use(
session({
secret: 'supersecretkeyyoushouldnotcommittogithub',
saveUninitialized: false,
resave: false
})
);
app.use(express.static(path.join(__dirname, 'public')));
app.use(methodOverride('_method'));
app.set('view engine', 'ejs');
app.set('views', path.join(__dirname, 'views'));
app.use('/', routes);
app.listen(config.port, () => {
console.log('Server is running on port ' + config.port);
console.log('Visit http://localhost:' + config.port + '/');
});