mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-06 03:20:13 +08:00
feat: disable rate limits when testing
This commit is contained in:
1 parent
d0c01fffa8
commit
ca057a657b
2 files changed
+16
-8
No files matched your search
@@ -1,16 +1,24 @@
|
||||
import rateLimit from 'express-rate-limit'
|
||||
import config from '../config.js'
|
||||
|
||||
export const globalRateLimit = rateLimit({
|
||||
function createRateLimiter(options) {
|
||||
if (config.testing.enabled) {
|
||||
return (req, res, next) => next()
|
||||
}
|
||||
return rateLimit(options)
|
||||
}
|
||||
|
||||
export const globalRateLimit = createRateLimiter({
|
||||
windowMs: 60 * 1000, // 1 minute
|
||||
max: 100,
|
||||
})
|
||||
|
||||
export const authenticateRateLimit = rateLimit({
|
||||
export const authenticateRateLimit = createRateLimiter({
|
||||
windowMs: 2 * 60 * 1000,
|
||||
max: 5,
|
||||
})
|
||||
|
||||
export const sessionRateLimit = rateLimit({
|
||||
export const sessionRateLimit = createRateLimiter({
|
||||
windowMs: 10 * 1000,
|
||||
max: 1,
|
||||
keyGenerator: (req) => {
|
||||
|
||||
Reference in new issue
Block a user