CognxSafeTrack commited on
Commit ·
bb62bf7
1
Parent(s): 255a85a
fix: add explicit types to rateLimit errorResponseBuilder parameters
Browse files
apps/api/src/middleware/rateLimit.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
-
import { FastifyInstance } from 'fastify';
|
| 2 |
-
import rateLimit from '@fastify/rate-limit';
|
| 3 |
import { logger } from '../logger';
|
| 4 |
|
| 5 |
export async function setupRateLimit(server: FastifyInstance) {
|
|
@@ -7,7 +7,7 @@ export async function setupRateLimit(server: FastifyInstance) {
|
|
| 7 |
await server.register(rateLimit as any, {
|
| 8 |
max: 100,
|
| 9 |
timeWindow: '1 minute',
|
| 10 |
-
errorResponseBuilder: (_request, context) => {
|
| 11 |
return {
|
| 12 |
statusCode: 429,
|
| 13 |
error: 'Too Many Requests',
|
|
|
|
| 1 |
+
import { FastifyInstance, FastifyRequest } from 'fastify';
|
| 2 |
+
import rateLimit, { RateLimitReplyContext } from '@fastify/rate-limit';
|
| 3 |
import { logger } from '../logger';
|
| 4 |
|
| 5 |
export async function setupRateLimit(server: FastifyInstance) {
|
|
|
|
| 7 |
await server.register(rateLimit as any, {
|
| 8 |
max: 100,
|
| 9 |
timeWindow: '1 minute',
|
| 10 |
+
errorResponseBuilder: (_request: FastifyRequest, context: RateLimitReplyContext) => {
|
| 11 |
return {
|
| 12 |
statusCode: 429,
|
| 13 |
error: 'Too Many Requests',
|