remove keyprefix as not needed and

updates to package.json, redis import and git ignore
This commit is contained in:
Tanya Byrne
2020-08-25 16:40:30 +01:00
parent 83c6fb5624
commit 41e3a693b1
3 changed files with 6 additions and 7 deletions

1
api/.gitignore vendored
View File

@@ -6,3 +6,4 @@ debug.db
test
dist
tmp
.env

View File

@@ -111,7 +111,8 @@
"resolve-cwd": "^3.0.0",
"sharp": "^0.25.4",
"uuid": "^8.3.0",
"uuid-validate": "0.0.3"
"uuid-validate": "0.0.3",
"rate-limiter-flexible": "^2.1.10"
},
"optionalDependencies": {
"mssql": "^6.2.0",
@@ -119,7 +120,6 @@
"oracledb": "^5.0.0",
"pg": "^8.3.0",
"sqlite3": "^5.0.0",
"rate-limiter-flexible": "^2.1.10",
"redis": "^3.0.2"
},
"devDependencies": {

View File

@@ -1,4 +1,3 @@
import redis from 'redis';
import {
RateLimiterRedis,
RateLimiterMemory,
@@ -6,8 +5,8 @@ import {
IRateLimiterOptions,
} from 'rate-limiter-flexible';
import camelcase from 'camelcase';
import { RedisNotFoundException } from '../exceptions';
import env from '../env';
import { RedisNotFoundException } from './exceptions';
import env from './env';
// options for the rate limiter are set below. Opts can be found
// at https://github.com/animir/node-rate-limiter-flexible/wiki/Options
@@ -22,7 +21,6 @@ export default rateLimiterConfig;
function getRateLimiterConfig(): IRateLimiterOptions {
const config: any = {};
config.keyPrefix = 'rlflx';
for (const [key, value] of Object.entries(env)) {
if (key === 'CONSUMED_POINTS_LIMIT') {
config.points = value;
@@ -38,6 +36,7 @@ function getRateLimiterConfig(): IRateLimiterOptions {
}
function getRateLimiterRedisConfig(): IRateLimiterStoreOptions {
const redis = require('redis');
const redisConfig: any = {};
const redisClient = redis.createClient({
enable_offline_queue: false,
@@ -50,7 +49,6 @@ function getRateLimiterRedisConfig(): IRateLimiterStoreOptions {
throw new RedisNotFoundException('Redis client does not exist');
}
redisConfig.keyPrefix = 'rlflx';
redisConfig.storeClient = redisClient;
for (const [key, value] of Object.entries(env)) {