-
Notifications
You must be signed in to change notification settings - Fork 2
/
app.js
37 lines (29 loc) · 981 Bytes
/
app.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
require('nocamel');
// global config
config = require('./config');
// set up express
const express = require('express');
const redis = require('redis');
const session = require('express-session');
const store = require('connect-redis')(session);
const app = express();
let redis_client = redis.createClient({ host: 'redis', port: 6379 });
app.set('view engine', 'twig');
app.set('views', './views');
app.use(express.urlencoded({ extended: true }));
app.use(express.static('./public'));
app.use(session({
store: new store({ client: redis_client }),
secret: 'whatever',
resave: false,
saveUninitialized: true
}));
// global database object
db = require('./models/init');
// each controller file
const home = require('./controllers/home');
// your routes
app.get('/', home.home); // routes url / to controllers/home.js home method
app.get('/home', home.home); // routes url /home to controllers/home.js home method
// start the app
app.listen(8000, () => {});