-
Notifications
You must be signed in to change notification settings - Fork 58
/
Copy pathapp.js
41 lines (30 loc) · 961 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
40
41
'use strict';
require('./globals');
require('./setup-qcloud-sdk');
const http = require('http');
const express = require('express');
const bodyParser = require('body-parser');
const morgan = require('morgan');
const config = require('./config');
const app = express();
app.set('query parser', 'simple');
app.set('case sensitive routing', true);
app.set('jsonp callback name', 'callback');
app.set('strict routing', true);
app.set('trust proxy', true);
app.disable('x-powered-by');
// 记录请求日志
app.use(morgan('tiny'));
// parse `application/x-www-form-urlencoded`
app.use(bodyParser.urlencoded({ extended: true }));
// parse `application/json`
app.use(bodyParser.json());
app.use('/', require('./routes'));
// 打印异常日志
process.on('uncaughtException', error => {
console.log(error);
});
// 启动server
http.createServer(app).listen(config.port, () => {
console.log('Express server listening on port: %s', config.port);
});