-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
47 lines (40 loc) · 1.47 KB
/
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
40
41
42
43
44
45
46
47
var koa = require('koa');
var logger = require('koa-logger');
var router = require('koa-router')();
var json = require('koa-json');
var views = require('koa-views');
var parser = require('koa-bodyparser');
var onerror = require('koa-onerror');
var koastatic = require('koa-static');
var path = require('path');
var session = require('koa-session');
var app = koa();
var index = require('./routes/index');
var server = require('./routes/server');
var rsrServer = require('./routes/rsrServer');
var redis = require('./routes/redis');
var gcbrowser = require('./routes/gcbrowser');
var gcserver = require('./routes/gcserver');
app.use(views('views', {
root: path.join(__dirname, 'views'),
default: 'ejs'
}));
app.use(parser());
app.use(json());
app.use(logger());
app.use(koastatic(path.join(__dirname, 'public')));
app.keys = ["jellyfish"];
app.use(session(app));
router.use('/', index.routes(), index.allowedMethods());
router.use('/server', server.routes(), server.allowedMethods());
router.use('/rsrServer', rsrServer.routes(), rsrServer.allowedMethods());
router.use('/redis', redis.routes(), redis.allowedMethods());
router.use('/gcbrowser', gcbrowser.routes(), gcbrowser.allowedMethods());
router.use('/gcserver', gcserver.routes(), gcserver.allowedMethods());
app.use(router.routes()).use(router.allowedMethods());
app.on('error', function(err, ctx) {
console.log('server error', err, ctx);
});
var port = 3000;
app.listen(port);
console.log('app listenning at port: ' + port);