-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
48 lines (35 loc) · 974 Bytes
/
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
/**
* API服务
* Author : smohan
* Website : https://smohan.net
* Date: 2017/10/12
*/
const express = require('express')
const bodyParser = require('body-parser')
const compression = require('compression')
const cookieParser = require('cookie-parser')
const C = require('./server/config/')
const app = express()
app
.use(cookieParser())
.use(bodyParser.json())
.use(bodyParser.urlencoded({
extended: true
}))
.use(compression())
app
.set('x-powered-by', false)
.use((req, res, next) => {
res.set('X-Powered-By', 'express & mongoose')
res.set('X-Author', 'smohan')
res.set('X-Official-Website', 'https://smohan.net')
res.set('X-MBlog-Version', C.version)
next()
})
//api router
app.use('/api', require('./server/config/router')(new express.Router()))
require('./server/config/db')()
//console.log()
app.listen(C.server.port)
//console.log(`app run ${config.server.host}:${config.server.port}`)
module.exports = app