-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
39 lines (31 loc) · 964 Bytes
/
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
// Module dependencies
var fs = require('fs');
var logger = require('./config/logger');
var app = require('./config/express');
// Set up sequelize orm
var db = require(__dirname + '/config/sequelize');
// Socket.io configuration
var io = require('./config/socketio');
// Sockets
var socketsPath = __dirname + '/app/sockets/connection.js';
require(socketsPath);
logger.info("Added socket: connection.js");
// Routes
var routesDir = __dirname + '/app/routes';
var routeFiles = fs.readdirSync(routesDir);
// Rate Limiter for entire application
var redisClient = require('redis').createClient();
var limiter = require('express-limiter')(app, redisClient);
limiter({
path: '/match',
method: 'all',
lookup: ['user.id', 'connection.remoteAddress'],
// Limit 50 requests per minute
total: 50,
expire: 60000
});
routeFiles.forEach(function(file) {
route = require(routesDir + '/' + file);
route.init(app);
logger.info("Added route: " + file);
});