-
Notifications
You must be signed in to change notification settings - Fork 2
/
config.js
48 lines (40 loc) · 1.33 KB
/
config.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
module.exports = {
// Currently ignored
RL_NODE_ENV: 'development',
// Proxy listens on this port. Hit this port to be forward to RL_API_URL
RL_PORT: 4000,
// Requests to me at port RL_PORT will be forwarded here
RL_API_URL: 'http://lugh:8888',
// How many requests per minute
RL_LIMIT_LIMIT: 2,
// What header is used to identify the client
// If header not included (and resource is rate-limited),
// will fail with HTTP 400 status.
RL_API_KEY_HEADER: 'api_key',
REDIS_PORT: 6379,
REDIS_HOST: "127.0.0.1"
}
// Override any values with env variables
for(var key in module.exports) {
module.exports[key] = process.env[key] || module.exports[key];
}
/**
* Maps a given request to a rate-limited resource name,
* or null if the resource is not rate-limited.
*
* It is up to you to classify the resource based on the URL, HTTP method,
* or whatever. To rate-limit all requests from the same pool, just return
* the same string every time.
*/
module.exports.getRateLimitedResource = function(req) {
if (!(req.url.match('reapi'))) {
return null;
}
if (req.url.match('engines') && req.url.match('events') && req.method == 'POST') {
return 'FormEventPost';
}
if (req.url.match('cns/notifications') && req.method == 'POST') {
return 'CNSNotificationsPost';
}
return null;
}