-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
35 lines (27 loc) · 878 Bytes
/
index.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
/* Node modules */
const bodyParser = require('body-parser')
const config = require('dos-config')
const express = require('express')
/* Helpers & Middlewares modules */
const loader = require('./helpers/folder-loader')
const reqExtend = require('./middlewares/req-extend')
const secureHook = require('./middlewares/secure-hook')
const server = express()
/* Loaders */
const routes = loader('lib/modules', ['index.js'])
/* External middlewares */
server.use(bodyParser.json({ limit: config.bodyParser.limit }))
server.use(bodyParser.urlencoded({
extended: true,
limit: config.bodyParser.limit
}))
/* Pre middlewares */
server.use(secureHook)
server.use(reqExtend)
/* Routes */
routes.forEach(route => server.use(require(route)))
/* Start up the server */
server.listen(config.port, () => {
console.log(`Listening on port ${config.port}`)
})
module.exports = server