-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathserver.js
executable file
·48 lines (36 loc) · 1.08 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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// do not require env.js in production
// environment variables are all set manually in production
if (process.env.NODE_ENV != "production"){
require('./env.js');
}
var koa = require('koa'),
path = require('path'),
config = require('config'),
serve = require('koa-static'),
koaPg = require('koa-pg'),
session = require('koa-session'),
bodyParser = require('koa-body-parser')
;
var passport = require('./app/auth/auth.js');
var app = module.exports = koa();
app.keys = ['ZeJSnGjgmDpJKzue5t3xSrWA','y5CZ4NrKbVP6ARgdmYNsFxKV'];
app.use(session(app));
app.use(bodyParser());
//configs are coming from config/default.js
app.use(passport.initialize());
app.use(passport.session());
//intialize koa-static
app.use(serve(config.publicfiles.path));
//pulls in routers
require('./app/routes')(app, passport);
//intialize koa-ejs
var render = require('koa-ejs');
render(app, {
root: path.join(config.template.path),
// layout: 'template',
viewExt: 'ejs',
cache: false,
debug: true
});
var port = process.env.PORT || 3000;
if (!module.parent) app.listen(port);