-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
54 lines (50 loc) · 1.36 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
48
49
50
51
52
53
54
/* global __dirname */
/* global process */
process.env.NODE_ENV = 'development';
//================引入主模块=================
var koa = require('koa');
//引入日志模块
var logger = require('koa-logger');
//引入路由模块
//引入静态文件处理
var serve = require('koa-static');
//引入模板引擎
var jade = require('koa-jade');
//引入body parse
var bodyParser = require('koa-body-parser');
//引入session
var session = require('koa-session');
//引入querystring Parse
var queryString = require('qs');
var Orm = require('./lib/database');
var app = koa();
//===============引入自定义模块===============
//引入路由管理
var router = require('./router/route');
//================引入配置文件================
var config = require('./config/serverConfig');
//include config
//generate application
// app.use(logger());
//parse static file
app.use(serve(__dirname + '/public'));
app.use(function* (next) {
this.orm = Orm;
this.models = Orm.models;
yield next;
});
app.use(router.routes());
//parse Url query string
// app.use(function*(next){
// this.qs = queryString.parse(this.querystring);
// yield next;
// });
//parse request
// app.use(bodyParser());
//set session secret
// app.keys = config.secret;
//use session
// app.use(session(app));
app.listen(config.port, function () {
console.log('server listened on port :' + config.port);
});