-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
46 lines (34 loc) · 1.47 KB
/
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
module.exports = function (config, db) {
var tokenizer = require('./botsleuth-tokenizer.js');
var botData = require('./data/bot-list.json');
var path = require('path');
var express = require('express'); // call express
var app = express(); // define our app using express
var bodyParser = require('body-parser');
var port = process.env.PORT || config.get("server.port"); // set our port
var routerOptions = {
app: app,
express: express,
config: config,
tokenizer: tokenizer,
botData: botData
}
app.set("view engine", "pug");
app.set("views", path.resolve("views"));
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json());
// Middleware part...
var apiRouter = require('./server/api/router.js')(routerOptions); // get an instance of the express Router
var webRouter = require('./server/web/router.js')(routerOptions);
// REGISTER OUR ROUTES -------------------------------
// all of our routes will be prefixed with /api
app.use('/api', apiRouter);
app.use('/', webRouter);
// This is where we are gonna serve the public website...
// TODO: Activate the server static files...
// START THE SERVER
// =============================================================================
app.listen(port);
console.log('Magic happens on port ' + port);
return app;
};