forked from robertsLando/statistics-server
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.js
46 lines (46 loc) · 1.45 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
40
41
42
43
44
45
46
module.exports = {
db: {
host: process.env.MONGO_HOST || 'localhost',
db: 'statistics',
port: process.env.MONGO_PORT || 27017,
username: process.env.MONGO_USER,
password: process.env.MONGO_PSW,
collections: {
statistics: {
index: {
default: [{ id: 1, date: 1 }, { unique: true }],
'timestamp last 24h': [{ ts: 1, date: 1, id: 1 }]
},
timeseries: true
},
// add below custom collections if any
manufacturer: {
index: {
default: [{ manufacturerId: 1 }, { unique: true }]
}
},
product: {
index: {
default: [{ manufacturerId: 1, productType: 1, productId: 1 }, { unique: true }]
}
}
}
},
apis: {
statistics: '/statistics',
updateDb: '/update-db'
},
port: process.env.PORT || '5000',
rateLimit: {
maxRequests: parseInt(process.env.RATELIMIT) || 2, // mind that 1 request needs to be done for auth
ttl: 60 * 1000 // 1 minute
},
// When behind a reverse proxy, set this field to `true`, so the rate-limiter can see the user's external IP
// Make sure to configure the proxy correctly. Details can be found at: http://expressjs.com/en/guide/behind-proxies.html
// For nginx, the following config will do:
// proxy_set_header X-Forwarded-For $remote_addr
// proxy_set_header X-Forwarded-Host ""
// proxy_set_header X-Forwarded-Proto ""
proxy: true,
key: process.env.KEY
}