-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
51 lines (37 loc) · 1.12 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
var config = require('./config')
var express = require('express')
var pg = require('pg.js')
var fs = require('fs')
// var bodyParser = require('body-parser')
var routes = require('./routes')
var http = require('http')
var https = require('https')
http.globalAgent.maxSockets = 20000
https.globalAgent.maxSockets = 20000
var path = require('path')
var app = express()
var IS_DEV = app.get('env') === 'development'
app.disable('x-powered-by')
// app.use(bodyParser.json())
app.set('views', __dirname + '/views')
app.set('view engine', 'ejs')
app.use(express.static(path.join(__dirname, 'public')))
var errorHandler = function (err, req, res, next) {
console.error(err)
res.status(500)
res.render('500')
}
app.use(errorHandler)
app.get('/', routes.base)
app.get('/api/data', routes.api)
app.all('*', function (err, req, res, next) {
console.log(err)
res.redirect('/')
})
process.on('uncaughtException', function (err) {
console.log('Exception: ' + err)
console.log(err.stack)
})
http.createServer(app).listen(config.http.port, function () {
console.log('Server launched and listening on port ' + config.http.port)
})