feat(server): expose the api rate limit to the env vars

This commit is contained in:
Ahmed Bouhuolia
2023-07-16 21:15:13 +02:00
parent da514403a1
commit 92f929152f
2 changed files with 10 additions and 4 deletions

View File

@@ -1,9 +1,12 @@
import dotenv from 'dotenv';
import path from 'path';
import { toInteger } from 'lodash';
import { castCommaListEnvVarToArray, parseBoolean } from '@/utils';
dotenv.config();
const API_RATE_LIMIT = process.env.API_RATE_LIMIT?.split(',') || [];
module.exports = {
/**
* Your favorite port
@@ -97,7 +100,7 @@ module.exports = {
jwtSecret: process.env.JWT_SECRET,
/**
*
*
*/
resetPasswordSeconds: 600,
@@ -130,9 +133,9 @@ module.exports = {
blockDuration: 60 * 15,
},
requests: {
points: 60,
duration: 60,
blockDuration: 60 * 10,
points: API_RATE_LIMIT[0] ? toInteger(API_RATE_LIMIT[0]) : 120,
duration: API_RATE_LIMIT[1] ? toInteger(API_RATE_LIMIT[1]) : 60,
blockDuration: API_RATE_LIMIT[2] ? toInteger(API_RATE_LIMIT[2]) : 60 * 10,
},
},