import { Global, Module } from '@nestjs/common'; import { APP_GUARD } from '@nestjs/core'; import { RateLimitGuard } from './rate-limit.guard'; import { RateLimitService } from './rate-limit.service'; /** * Global: the guard runs for every route but only acts where a handler * carries @RateLimit metadata; the service is injectable everywhere for * account-scoped limits. */ @Global() @Module({ providers: [RateLimitService, { provide: APP_GUARD, useClass: RateLimitGuard }], exports: [RateLimitService], }) export class RateLimitModule {}