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 test-fullstack-main.sh
start-fullstack-main.sh start-fullstack-main.sh
start-fullstack-test.sh start-fullstack-test.sh
start-free-main.sh
coverage coverage
start-my-infra start-my-infra
+3 -1
View File
@@ -3,7 +3,9 @@
*/ */
const config = { 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 module.exports = config
+9 -9
View File
@@ -99,7 +99,7 @@ class RateLimits {
} }
// Used for displaying error message. Default value is 3. // 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: // 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 // 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 // Calculates the points consumed, based on the jwt information and the route
// requested. // requested.
calcPoints (jwtInfo) { calcPoints (jwtInfo) {
let retVal = 30 // By default, use anonymous tier. let retVal = 2 // By default, use anonymous tier.
try { try {
// console.log(`jwtInfo: ${JSON.stringify(jwtInfo, null, 2)}`) // console.log(`jwtInfo: ${JSON.stringify(jwtInfo, null, 2)}`)
@@ -179,22 +179,22 @@ class RateLimits {
if (jwtInfo.id) { if (jwtInfo.id) {
// SLP indexer routes // SLP indexer routes
if (level40Routes.includes(resource)) { if (level40Routes.includes(resource)) {
if (apiLevel >= 40) retVal = 1 if (apiLevel >= 40) retVal = 2
// else if (apiLevel >= 10) retVal = 10 // else if (apiLevel >= 10) retVal = 10
else retVal = 10 else retVal = 2
// Normal indexer routes // Normal indexer routes
} else if (level30Routes.includes(resource)) { } else if (level30Routes.includes(resource)) {
if (apiLevel >= 30) retVal = 1 if (apiLevel >= 30) retVal = 2
else retVal = 10 else retVal = 2
// Full node tier // Full node tier
} else if (apiLevel >= 20) { } else if (apiLevel >= 20) {
retVal = 1 retVal = 2
// Free tier, full node only. // Free tier, full node only.
} else { } else {
retVal = 10 retVal = 2
} }
} }
@@ -202,7 +202,7 @@ class RateLimits {
} catch (err) { } catch (err) {
wlogger.error('Error in route-ratelimit.js/calcPoints()') wlogger.error('Error in route-ratelimit.js/calcPoints()')
// throw err // throw err
retVal = 30 retVal = 2
} }
return retVal return retVal