mirror of
https://github.com/strapi/strapi.git
synced 2025-07-31 21:09:39 +00:00
change ratelimit to rateLimit
This commit is contained in:
parent
33bd405a2b
commit
ae7c60980c
@ -8,20 +8,20 @@ const { RateLimitError } = utils.errors;
|
|||||||
module.exports =
|
module.exports =
|
||||||
(config, { strapi }) =>
|
(config, { strapi }) =>
|
||||||
async (ctx, next) => {
|
async (ctx, next) => {
|
||||||
let ratelimitConfig = strapi.config.get('admin.ratelimit');
|
let rateLimitConfig = strapi.config.get('admin.rateLimit');
|
||||||
|
|
||||||
if (!ratelimitConfig) {
|
if (!rateLimitConfig) {
|
||||||
ratelimitConfig = {
|
rateLimitConfig = {
|
||||||
enabled: true,
|
enabled: true,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!has('enabled', ratelimitConfig)) {
|
if (!has('enabled', rateLimitConfig)) {
|
||||||
ratelimitConfig.enabled = true;
|
rateLimitConfig.enabled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ratelimitConfig.enabled === true) {
|
if (rateLimitConfig.enabled === true) {
|
||||||
const ratelimit = require('koa2-ratelimit').RateLimit;
|
const rateLimit = require('koa2-ratelimit').RateLimit;
|
||||||
|
|
||||||
const userEmail = toLower(ctx.request.body.email) || 'unknownEmail';
|
const userEmail = toLower(ctx.request.body.email) || 'unknownEmail';
|
||||||
|
|
||||||
@ -32,13 +32,11 @@ module.exports =
|
|||||||
handler() {
|
handler() {
|
||||||
throw new RateLimitError();
|
throw new RateLimitError();
|
||||||
},
|
},
|
||||||
...ratelimitConfig,
|
...rateLimitConfig,
|
||||||
...config,
|
...config,
|
||||||
};
|
};
|
||||||
|
|
||||||
console.log(loadConfig);
|
return rateLimit.middleware(loadConfig)(ctx, next);
|
||||||
|
|
||||||
return ratelimit.middleware(loadConfig)(ctx, next);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return next();
|
return next();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user