Config: Refactor config method, so we have a new get all option, fix issues in configurations

This commit is contained in:
Diego Magdaleno
2021-05-21 18:18:58 -05:00
parent 8872f806f7
commit 05057b922a
11 changed files with 26 additions and 24 deletions
+1 -2
View File
@@ -44,8 +44,7 @@ export async function GlobalRateLimit(req: Request, res: Response, next: NextFun
}
export function getIpAdress(req: Request): string {
const rateLimitProperties = Config.apiConfig.get('security', {jwtSecret: crypto.randomBytes(256).toString("base64"), forwadedFor: null, captcha: {enabled:false, service: null, sitekey: null, secret: null}}) as Config.DefaultOptions;
const { forwadedFor } = rateLimitProperties.security;
const { forwadedFor } = Config.apiConfig.getAll().security;
const ip = forwadedFor ? <string>req.headers[forwadedFor] : req.ip;
return ip.replaceAll(".", "_").replaceAll(":", "_");
}