-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
36 lines (30 loc) · 987 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
36
const winston = require('winston');
const express = require('express');
const path = require('path');
const bodyParser = require('body-parser');
const argv = require('yargs').argv;
const serverNames = {
mongoServerName : argv.mongo,
rabbitServerName : argv.rabbit
}
var app = express();
app.use(bodyParser.json()); // to support JSON-encoded bodies
app.use(bodyParser.urlencoded({ // to support URL-encoded bodies
extended: true
}));
app.use(function(req, res, next) {
res.setHeader('Access-Control-Allow-Methods', 'GET, POST');
res.setHeader('Access-Control-Allow-Headers', 'X-Requested-With,content-type, Authorization');
next();
});
var fs = require('fs');
var RouteDir = 'routes';
var files = fs.readdirSync(RouteDir);
files.forEach(function(file) {
var filePath = path.resolve('./', RouteDir, file);
var route = require(filePath);
route.init(serverNames, app);
});
app.listen(8090, function() {
winston.info('wat_scheduler is listenning on port 8090');
});