-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
executable file
·35 lines (31 loc) · 990 Bytes
/
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
#!/usr/bin/env node
var http = require('http');
var express = require('express');
var session = require('express-session');
var passport = require('passport');
var addUser = require('./app/middleware/addUser');
var controllers = require('./app/controllers');
var config = require('./app/config');
var db = require('./app/db');
var KnexSessionStore = require('connect-session-knex')(session);
var app = express();
module.exports = app;
app.use(express.static('./app/public'));
app.use(session({
secret: config.SESSION_KEY,
store: new KnexSessionStore({
knex: db.knex,
}),
resave: true,
saveUninitialized: false,
}));
app.use(passport.initialize());
app.use(passport.session());
app.use(addUser);
app.use(controllers);
app.set('views', './app/views');
var server = http.createServer(app);
server.listen(process.env.PORT || 3000, process.env.IP || '0.0.0.0', function(){
var addr = server.address();
console.log('Server listening at', addr.address + ':' + addr.port);
});