Skip to content

Open-Source API Development Ecosystem • https://hoppscotch.io • Offline, On-Prem & Cloud • Web, Desktop & CLI • Open-Source Alternative to Postman, Insomnia

chore: apply ThrottlerBehindProxyGuard across controllers (#5746)

Mir Arif Hasan212b15890ef5
diff --git a/packages/hoppscotch-backend/src/app.controller.ts b/packages/hoppscotch-backend/src/app.controller.ts
index 8ce570ea3..298e9551b 100644
--- a/packages/hoppscotch-backend/src/app.controller.ts
+++ b/packages/hoppscotch-backend/src/app.controller.ts
@@ -1,6 +1,8 @@
-import { Controller, Get } from '@nestjs/common';
+import { Controller, Get, UseGuards } from '@nestjs/common';
+import { ThrottlerBehindProxyGuard } from './guards/throttler-behind-proxy.guard';
@Controller('ping')
+@UseGuards(ThrottlerBehindProxyGuard)
export class AppController {
@Get()
ping(): string {
diff --git a/packages/hoppscotch-backend/src/health/health.controller.ts b/packages/hoppscotch-backend/src/health/health.controller.ts
index 0f6326115..3c704f870 100644
--- a/packages/hoppscotch-backend/src/health/health.controller.ts
+++ b/packages/hoppscotch-backend/src/health/health.controller.ts
@@ -1,12 +1,14 @@
-import { Controller, Get } from '@nestjs/common';
+import { Controller, Get, UseGuards } from '@nestjs/common';
import {
HealthCheck,
HealthCheckService,
PrismaHealthIndicator,
} from '@nestjs/terminus';
+import { ThrottlerBehindProxyGuard } from 'src/guards/throttler-behind-proxy.guard';
import { PrismaService } from 'src/prisma/prisma.service';
@Controller('health')
+@UseGuards(ThrottlerBehindProxyGuard)
export class HealthController {
constructor(
private health: HealthCheckService,
diff --git a/packages/hoppscotch-backend/src/infra-config/onboarding.controller.ts b/packages/hoppscotch-backend/src/infra-config/onboarding.controller.ts
index b931ba5f6..1741e77d3 100644
--- a/packages/hoppscotch-backend/src/infra-config/onboarding.controller.ts
+++ b/packages/hoppscotch-backend/src/infra-config/onboarding.controller.ts
@@ -1,4 +1,12 @@
-import { Body, Controller, Get, HttpStatus, Post, Query } from '@nestjs/common';
+import {
+ Body,
+ Controller,
+ Get,
+ HttpStatus,
+ Post,
+ Query,
+ UseGuards,
+} from '@nestjs/common';
import { InfraConfigService } from './infra-config.service';
import { RESTError } from 'src/types/RESTError';
import { throwHTTPErr } from 'src/utils';
@@ -11,8 +19,10 @@ import {
} from './dto/onboarding.dto';
import { ApiCreatedResponse, ApiOkResponse } from '@nestjs/swagger';
import { plainToInstance } from 'class-transformer';
+import { ThrottlerBehindProxyGuard } from 'src/guards/throttler-behind-proxy.guard';
@Controller({ path: 'onboarding', version: '1' })
+@UseGuards(ThrottlerBehindProxyGuard)
export class OnboardingController {
constructor(private infraConfigService: InfraConfigService) {}
diff --git a/packages/hoppscotch-backend/src/published-docs/published-docs.controller.ts b/packages/hoppscotch-backend/src/published-docs/published-docs.controller.ts
index d3e6d5290..c61e80c09 100644
--- a/packages/hoppscotch-backend/src/published-docs/published-docs.controller.ts
+++ b/packages/hoppscotch-backend/src/published-docs/published-docs.controller.ts
@@ -5,6 +5,7 @@ import {
Query,
HttpCode,
HttpStatus,
+ UseGuards,
} from '@nestjs/common';
import { ApiTags, ApiOperation, ApiResponse } from '@nestjs/swagger';
import { PublishedDocsService } from './published-docs.service';
@@ -12,9 +13,11 @@ import { GetPublishedDocsQueryDto } from './published-docs.dto';
import * as E from 'fp-ts/Either';
import { throwHTTPErr } from 'src/utils';
import { PublishedDocs } from './published-docs.model';
+import { ThrottlerBehindProxyGuard } from 'src/guards/throttler-behind-proxy.guard';
@ApiTags('Published Docs')
@Controller({ version: '1', path: 'published-docs' })
+@UseGuards(ThrottlerBehindProxyGuard)
export class PublishedDocsController {
constructor(private readonly publishedDocsService: PublishedDocsService) {}