-
Notifications
You must be signed in to change notification settings - Fork 1
/
config.js
71 lines (63 loc) · 1.64 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import rc from 'rc';
const prefix = 'pow';
function translate (key, obj) {
if (!key.startsWith(`${prefix}_`)) return;
let cursor = obj;
const keys = key.substring(prefix.length + 1).split('__');
const length = keys.length - 1;
for (let i = 0; i < length; ++i) {
const key = keys[i];
if (!cursor[key]) {
return false;
}
cursor = cursor[key];
}
if (typeof cursor === 'object') {
const lastKey = keys.pop();
cursor[lastKey] = Object.values(cursor[lastKey]);
}
return true;
}
const config = rc(prefix, {
server: {
cors: {}
},
pow: {
// interval for adjusting the level
levelInt: 130,
// size of a measurement bucket
stepInt: 2500,
// only even multiples of the stepInterval
seconds: 5 * 2,
// currently only 3 layers of levels
levels: [50000, 3000000, 10000000],
// default time is 30 seconds for a pow max solving time
ttl: 1000 * 30,
// max concurrent pow configs that are allowed
// everything that comes past this deletes from the front
max: 100000
},
token: {
// max time until backend needs to check the token
// by default 15 seconds
ttl: 1000 * 15,
// max concurrent tokens that are allowed
// everything that comes past this deletes from the front
max: 100000
},
clients: {
// test123: {
// secret: '123456'
// }
}
});
if (config.translate) {
if (typeof config.translate === 'string') {
translate(config.translate, config);
} else if (typeof config.translate === 'object') {
Object.values(config.translate).forEach((value) =>
translate(value, config)
);
}
}
export default config;