From b22871674e9155604cd328cccd070dfe8f470a6b Mon Sep 17 00:00:00 2001 From: Roman Petriv Date: Mon, 30 Oct 2023 06:14:37 +0200 Subject: [PATCH] fix: limit offset to 1000 for API by default --- packages/api/.env.example | 3 ++- packages/api/.env.test | 1 + .../src/api/dtos/common/pagingOptionsWithMaxItemsLimit.dto.ts | 2 +- .../api/src/common/dtos/pagingOptionsWithMaxItemsLimit.dto.ts | 2 +- 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/api/.env.example b/packages/api/.env.example index 5e8f59fd64..e9a1ce6464 100644 --- a/packages/api/.env.example +++ b/packages/api/.env.example @@ -6,7 +6,8 @@ METRICS_PORT=3005 COLLECT_DB_CONNECTION_POOL_METRICS_INTERVAL=10000 PORT=3020 LOG_LEVEL=debug -LIMITED_PAGINATION_MAX_ITEMS=100000 +LIMITED_PAGINATION_MAX_ITEMS=10000 +API_LIMITED_PAGINATION_MAX_ITEMS=1000 DISABLE_API_SCHEMA_DOCS=false DISABLE_BFF_API_SCHEMA_DOCS=false DISABLE_EXTERNAL_API=false diff --git a/packages/api/.env.test b/packages/api/.env.test index 3566e2364e..d4d855e2d6 100644 --- a/packages/api/.env.test +++ b/packages/api/.env.test @@ -2,4 +2,5 @@ DATABASE_URL='postgres://postgres:postgres@localhost:5432/block-explorer-e2e' METRICS_PORT=3005 PORT=3007 LIMITED_PAGINATION_MAX_ITEMS=15 +API_LIMITED_PAGINATION_MAX_ITEMS=15 CONTRACT_VERIFICATION_API_URL=http://verification.api diff --git a/packages/api/src/api/dtos/common/pagingOptionsWithMaxItemsLimit.dto.ts b/packages/api/src/api/dtos/common/pagingOptionsWithMaxItemsLimit.dto.ts index 6341f34c2d..db85df611e 100644 --- a/packages/api/src/api/dtos/common/pagingOptionsWithMaxItemsLimit.dto.ts +++ b/packages/api/src/api/dtos/common/pagingOptionsWithMaxItemsLimit.dto.ts @@ -6,7 +6,7 @@ import { PagingOptionsDto } from "./pagingOptions.dto"; import { config } from "dotenv"; config(); -const maxItemsLimit = parseInt(process.env.LIMITED_PAGINATION_MAX_ITEMS, 10) || 10000; +const maxItemsLimit = parseInt(process.env.API_LIMITED_PAGINATION_MAX_ITEMS, 10) || 1000; export class PagingOptionsWithMaxItemsLimitDto extends PagingOptionsDto { @ApiPropertyOptional({ diff --git a/packages/api/src/common/dtos/pagingOptionsWithMaxItemsLimit.dto.ts b/packages/api/src/common/dtos/pagingOptionsWithMaxItemsLimit.dto.ts index a1ac934035..dd5f8607c8 100644 --- a/packages/api/src/common/dtos/pagingOptionsWithMaxItemsLimit.dto.ts +++ b/packages/api/src/common/dtos/pagingOptionsWithMaxItemsLimit.dto.ts @@ -6,7 +6,7 @@ import { PagingOptionsDto } from "./pagingOptions.dto"; import { config } from "dotenv"; config(); -const maxItemsLimit = parseInt(process.env.LIMITED_PAGINATION_MAX_ITEMS, 10) || 100000; +const maxItemsLimit = parseInt(process.env.LIMITED_PAGINATION_MAX_ITEMS, 10) || 10000; export class PagingOptionsWithMaxItemsLimitDto extends PagingOptionsDto { @ApiPropertyOptional({