unit test for getResource()

This commit is contained in:
Chris Troutner
2020-02-06 14:51:09 -08:00
parent 86951eccac
commit 8a558db690
2 changed files with 16 additions and 4 deletions
+4 -4
View File
@@ -40,6 +40,8 @@ class RateLimits {
this.rateLimiter = new RateLimiterRedis(rateLimitOptions)
}
// Used to disconnect from the Redis DB.
// Called by unit tests so that node.js thread doesn't live forever.
closeRedis() {
redisClient.disconnect()
}
@@ -228,9 +230,7 @@ class RateLimits {
/*
This is the new rate limit function that uses the rate-limiter-flexible npm
library. For the moment, it only distinguishes between anonymous usage
and registered user access. anon usage allows up to 3 RPM, whereas registered
users (with JWT tokens) have 100 RPM.
library.
*/
async newRateLimit(req, res, next) {
try {
@@ -353,7 +353,7 @@ class RateLimits {
// what kind of variations will be seen in production.
getResource(url) {
try {
console.log(`url: ${JSON.stringify(url, null, 2)}`)
// console.log(`url: ${JSON.stringify(url, null, 2)}`)
const splitUrl = url.split("/")
const resource = splitUrl[1]