forked from project-sunbird/sunbird-collection-editor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
39 lines (33 loc) · 1.19 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
var express = require('express'),
http = require('http'),
path = require('path'),
fs = require('fs'),
proxy = require('express-http-proxy'),
urlHelper = require('url'),
bodyParser = require('body-parser');
http.globalAgent.maxSockets = 100000;
var app = express();
// all environments
app.set('port', 3000);
app.use(bodyParser.urlencoded({ extended: false }))
app.use(bodyParser.json({limit: '50mb'}))
app.use(express.static(path.join(__dirname, '.')));
app.use('/action', proxy('dev.ekstep.in', {
https: true,
proxyReqPathResolver: function(req) {
return "/api" + urlHelper.parse(req.url).path;
},
proxyReqOptDecorator: function(proxyReqOpts, srcReq) {
// you can update headers
proxyReqOpts.headers['Content-Type'] = 'application/json';
proxyReqOpts.headers['user-id'] = 'content-editor';
return proxyReqOpts;
}
}));
var routes = __dirname + '/server/routes', route_files = fs.readdirSync(routes);
route_files.forEach(function (file) {
require(routes + '/' + file)(app, __dirname);
});
var server = http.createServer(app).listen(app.get('port'), 1500);
server.timeout = 0;
process.env['NODE_TLS_REJECT_UNAUTHORIZED'] = '0';