From 799d15bf41abe040f6d266f0f1c25e2c5ad492e4 Mon Sep 17 00:00:00 2001 From: SennayT Date: Tue, 14 Jul 2026 10:44:21 +0300 Subject: [PATCH] Revert "remove throttler again and increase limits" This reverts commit fdb5e0f74c477707f0162b8687bec4f3f5230a42. --- apps/edr-passenger-api/src/app.module.ts | 10 ++-- .../system-config/system-config.service.ts | 52 ++++++++----------- 2 files changed, 28 insertions(+), 34 deletions(-) diff --git a/apps/edr-passenger-api/src/app.module.ts b/apps/edr-passenger-api/src/app.module.ts index 6867acb6c..7652fc980 100644 --- a/apps/edr-passenger-api/src/app.module.ts +++ b/apps/edr-passenger-api/src/app.module.ts @@ -69,11 +69,11 @@ import { EOtpType } from "@tria-plc/iamapi-common"; @Module({ imports: [ - // ThrottlerModule.forRoot([ - // { name: "auth", ttl: 60, limit: 100000 }, - // { name: "strict", ttl: 60, limit: 100000 }, - // { name: "default", ttl: 60, limit: 100000 }, - // ]), + ThrottlerModule.forRoot([ + { name: "auth", ttl: 60, limit: 100000 }, + { name: "strict", ttl: 60, limit: 100000 }, + { name: "default", ttl: 60, limit: 100000 }, + ]), ConfigModule.forRoot({ isGlobal: true, load: [ diff --git a/apps/edr-passenger-api/src/modules/system-config/system-config.service.ts b/apps/edr-passenger-api/src/modules/system-config/system-config.service.ts index 040d51f10..3cfa1beb8 100644 --- a/apps/edr-passenger-api/src/modules/system-config/system-config.service.ts +++ b/apps/edr-passenger-api/src/modules/system-config/system-config.service.ts @@ -1,29 +1,28 @@ -import { Injectable } from "@nestjs/common"; -import { PrismaService } from "../../common/prisma.service"; +import { Injectable } from '@nestjs/common'; +import { PrismaService } from '../../common/prisma.service'; export const CONFIG_KEYS = { - SEAT_HOLD_DURATION_MINUTES: "seat_hold_duration_minutes", - HOLD_CUTOFF_HOURS_BEFORE_DEPARTURE: "hold_cutoff_hours_before_departure", - BOARDING_WINDOW_HOURS_BEFORE_DEPARTURE: - "boarding_window_hours_before_departure", - THROTTLE_AUTH_LIMIT: "throttle_auth_limit", - THROTTLE_AUTH_TTL_MS: "throttle_auth_ttl_ms", - THROTTLE_STRICT_LIMIT: "throttle_strict_limit", - THROTTLE_STRICT_TTL_MS: "throttle_strict_ttl_ms", - THROTTLE_DEFAULT_LIMIT: "throttle_default_limit", - THROTTLE_DEFAULT_TTL_MS: "throttle_default_ttl_ms", + SEAT_HOLD_DURATION_MINUTES: 'seat_hold_duration_minutes', + HOLD_CUTOFF_HOURS_BEFORE_DEPARTURE: 'hold_cutoff_hours_before_departure', + BOARDING_WINDOW_HOURS_BEFORE_DEPARTURE: 'boarding_window_hours_before_departure', + THROTTLE_AUTH_LIMIT: 'throttle_auth_limit', + THROTTLE_AUTH_TTL_MS: 'throttle_auth_ttl_ms', + THROTTLE_STRICT_LIMIT: 'throttle_strict_limit', + THROTTLE_STRICT_TTL_MS: 'throttle_strict_ttl_ms', + THROTTLE_DEFAULT_LIMIT: 'throttle_default_limit', + THROTTLE_DEFAULT_TTL_MS: 'throttle_default_ttl_ms', } as const; const DEFAULTS: Record = { - [CONFIG_KEYS.SEAT_HOLD_DURATION_MINUTES]: "5", - [CONFIG_KEYS.HOLD_CUTOFF_HOURS_BEFORE_DEPARTURE]: "2", - [CONFIG_KEYS.BOARDING_WINDOW_HOURS_BEFORE_DEPARTURE]: "4", - [CONFIG_KEYS.THROTTLE_AUTH_LIMIT]: "5000", - [CONFIG_KEYS.THROTTLE_AUTH_TTL_MS]: "60", - [CONFIG_KEYS.THROTTLE_STRICT_LIMIT]: "20000", - [CONFIG_KEYS.THROTTLE_STRICT_TTL_MS]: "60", - [CONFIG_KEYS.THROTTLE_DEFAULT_LIMIT]: "100000", - [CONFIG_KEYS.THROTTLE_DEFAULT_TTL_MS]: "6", + [CONFIG_KEYS.SEAT_HOLD_DURATION_MINUTES]: '5', + [CONFIG_KEYS.HOLD_CUTOFF_HOURS_BEFORE_DEPARTURE]: '2', + [CONFIG_KEYS.BOARDING_WINDOW_HOURS_BEFORE_DEPARTURE]: '4', + [CONFIG_KEYS.THROTTLE_AUTH_LIMIT]: '5', + [CONFIG_KEYS.THROTTLE_AUTH_TTL_MS]: '60000', + [CONFIG_KEYS.THROTTLE_STRICT_LIMIT]: '20', + [CONFIG_KEYS.THROTTLE_STRICT_TTL_MS]: '60000', + [CONFIG_KEYS.THROTTLE_DEFAULT_LIMIT]: '100', + [CONFIG_KEYS.THROTTLE_DEFAULT_TTL_MS]: '60000', }; @Injectable() @@ -39,14 +38,11 @@ export class SystemConfigService { async getValue(key: string): Promise { const row = await this.prisma.systemConfig.findUnique({ where: { key } }); - return row?.value ?? DEFAULTS[key] ?? ""; + return row?.value ?? DEFAULTS[key] ?? ''; } async getNumber(key: string): Promise { - return ( - parseInt(await this.getValue(key), 10) || - parseInt(DEFAULTS[key] ?? "0", 10) - ); + return parseInt(await this.getValue(key), 10) || parseInt(DEFAULTS[key] ?? '0', 10); } async set(key: string, value: string): Promise { @@ -57,9 +53,7 @@ export class SystemConfigService { }); } - async updateMany( - entries: Record, - ): Promise> { + async updateMany(entries: Record): Promise> { await Promise.all(Object.entries(entries).map(([k, v]) => this.set(k, v))); return this.getAll(); }