forked from cnpm/mirrors
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
39 lines (30 loc) · 803 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
38
39
'use strict';
global.Promise = require('bluebird');
var middlewares = require('koa-middlewares');
var logger = require('./common/logger');
var config = require('./config');
var routes = require('./routes');
var http = require('http');
var path = require('path');
var koa = require('koa');
var app = koa();
app.proxy = true;
app.use(middlewares.favicon());
app.use(middlewares.rt());
app.use(middlewares.compress({threshold: 150}));
app.use(middlewares.conditional());
app.use(middlewares.etag());
middlewares.ejs(app, {
root: path.join(__dirname, 'views'),
cache: !config.debug,
debug: config.debug,
locals: {
config: config
}
});
routes(app);
app.on('error', function (err) {
console.log(err.stack);
logger.error(err);
});
module.exports = http.createServer(app.callback());