Create free branch with 30 RPM rate limits

This commit is contained in:
Chris Troutner
2020-06-27 14:58:35 -07:00
parent 1c00ea3cc6
commit 7b5eba9d45
3 changed files with 13 additions and 10 deletions
+1
View File
@@ -16,6 +16,7 @@ start-local-testnet.sh
test-fullstack-main.sh
start-fullstack-main.sh
start-fullstack-test.sh
start-free-main.sh
coverage
start-my-infra
+3 -1
View File
@@ -3,7 +3,9 @@
*/
const config = {
apiTokenSecret: process.env.TOKENSECRET ? process.env.TOKENSECRET : 'secret-jwt-token'
apiTokenSecret: process.env.TOKENSECRET
? process.env.TOKENSECRET
: 'secret-jwt-token'
}
module.exports = config
+9 -9
View File
@@ -99,7 +99,7 @@ class RateLimits {
}
// Used for displaying error message. Default value is 3.
let rateLimit = 3
let rateLimit = 50
// Code here for the rate limiter is adapted from this example:
// https://github.com/animir/node-rate-limiter-flexible/wiki/Overall-example#authorized-and-not-authorized-users
@@ -162,7 +162,7 @@ class RateLimits {
// Calculates the points consumed, based on the jwt information and the route
// requested.
calcPoints (jwtInfo) {
let retVal = 30 // By default, use anonymous tier.
let retVal = 2 // By default, use anonymous tier.
try {
// console.log(`jwtInfo: ${JSON.stringify(jwtInfo, null, 2)}`)
@@ -179,22 +179,22 @@ class RateLimits {
if (jwtInfo.id) {
// SLP indexer routes
if (level40Routes.includes(resource)) {
if (apiLevel >= 40) retVal = 1
if (apiLevel >= 40) retVal = 2
// else if (apiLevel >= 10) retVal = 10
else retVal = 10
else retVal = 2
// Normal indexer routes
} else if (level30Routes.includes(resource)) {
if (apiLevel >= 30) retVal = 1
else retVal = 10
if (apiLevel >= 30) retVal = 2
else retVal = 2
// Full node tier
} else if (apiLevel >= 20) {
retVal = 1
retVal = 2
// Free tier, full node only.
} else {
retVal = 10
retVal = 2
}
}
@@ -202,7 +202,7 @@ class RateLimits {
} catch (err) {
wlogger.error('Error in route-ratelimit.js/calcPoints()')
// throw err
retVal = 30
retVal = 2
}
return retVal