feat: introducing rate-limiting on queries, mutations and most of the REST endpoints (HBE-111) (#46)
* 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
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
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 };
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user