Skip to content

Commit 89d99b6

Browse files
committed
fix formatting
1 parent 2c4f267 commit 89d99b6

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

src/utils/rateLimiter.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@ import { logger } from './logger.js'
44
import { Response } from 'express'
55

66
export const rateLimiter: RateLimitRequestHandler = rateLimit({
7-
windowMs: 60 * 1000,
8-
limit: (req: Request): number => {
9-
logger.debug(`Rate limit check ${ req.auth ? 'authenticated' : 'anon' } - ${ req.headers['cf-connecting-ip'] ?? req.ip }`)
10-
return req.auth ? 60 : 5 // 60 req/min for auth, 5 for anon
11-
},
12-
keyGenerator: (req: Request): string => {
13-
return req.auth?.sub ? `session-${req.auth.sub}` : req.ip!
14-
},
15-
handler: (req: Request, res: Response) => {
16-
logger.warn('Rate limiting IP address:', req.ip)
17-
res.status(429).send({ message: 'Rate limited' })
18-
}
19-
})
7+
windowMs: 60 * 1000,
8+
limit: (req: Request): number => {
9+
logger.debug(`Rate limit check ${req.auth ? 'authenticated' : 'anon'} - ${req.headers['cf-connecting-ip'] ?? req.ip}`)
10+
return req.auth ? 60 : 5 // 60 req/min for auth, 5 for anon
11+
},
12+
keyGenerator: (req: Request): string => {
13+
return req.auth?.sub ? `session-${req.auth.sub}` : req.ip!
14+
},
15+
handler: (req: Request, res: Response) => {
16+
logger.warn('Rate limiting IP address:', req.ip)
17+
res.status(429).send({ message: 'Rate limited' })
18+
},
19+
})

0 commit comments

Comments
 (0)