* 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
13 lines
433 B
TypeScript
13 lines
433 B
TypeScript
import { ExecutionContext, Injectable } from '@nestjs/common';
|
|
import { GqlExecutionContext } from '@nestjs/graphql';
|
|
import { ThrottlerGuard } from '@nestjs/throttler';
|
|
|
|
@Injectable()
|
|
export class GqlThrottlerGuard extends ThrottlerGuard {
|
|
getRequestResponse(context: ExecutionContext) {
|
|
const gqlCtx = GqlExecutionContext.create(context);
|
|
const ctx = gqlCtx.getContext();
|
|
return { req: ctx.req, res: ctx.res };
|
|
}
|
|
}
|