Function
createRateLimiter
({
max,
windowMs,
message,
}: {
max: number
windowMs: number
message: string
})
Source from the content-addressed store, hash-verified
| 1 | import rateLimit from 'express-rate-limit' |
| 2 | |
| 3 | export function createRateLimiter({ |
| 4 | max, |
| 5 | windowMs, |
| 6 | message, |
| 7 | }: { |
| 8 | max: number |
| 9 | windowMs: number |
| 10 | message: string |
| 11 | }) { |
| 12 | return rateLimit({ |
| 13 | max, |
| 14 | windowMs, |
| 15 | message, |
| 16 | skip: (req) => { |
| 17 | if (req.method === 'OPTIONS') { |
| 18 | return true |
| 19 | } |
| 20 | |
| 21 | if (req.originalUrl.endsWith('/import')) { |
| 22 | return true |
| 23 | } |
| 24 | |
| 25 | return false |
| 26 | }, |
| 27 | }) |
| 28 | } |
Tested by
no test coverage detected