* feat: rate-limiting guard added and configured in app module * feat: rate-limit annotation added in controllers and resolvers (query, mutation, not subscription) * docs: added comments
11 lines
448 B
TypeScript
11 lines
448 B
TypeScript
import { ThrottlerGuard } from '@nestjs/throttler';
|
|
import { Injectable } from '@nestjs/common';
|
|
|
|
@Injectable()
|
|
export class ThrottlerBehindProxyGuard extends ThrottlerGuard {
|
|
protected getTracker(req: Record<string, any>): string {
|
|
return req.ips.length ? req.ips[0] : req.ip; // individualize IP extraction to meet your own needs
|
|
// learn more: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Forwarded-For#directives
|
|
}
|
|
}
|