From 0b5af3145e42fbb2fa0c4fed176445bd72b11f73 Mon Sep 17 00:00:00 2001 From: devlikepro Date: Sun, 27 Jul 2025 15:05:42 +0700 Subject: [PATCH] [core] Always save config, not null --- src/core/storage/ISessionConfigRepository.ts | 2 +- src/core/storage/LocalSessionConfigRepository.ts | 6 +++--- src/structures/sessions.dto.ts | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/core/storage/ISessionConfigRepository.ts b/src/core/storage/ISessionConfigRepository.ts index f9546dbd..bb5e47fe 100644 --- a/src/core/storage/ISessionConfigRepository.ts +++ b/src/core/storage/ISessionConfigRepository.ts @@ -3,7 +3,7 @@ import { SessionConfig } from '../../structures/sessions.dto'; export abstract class ISessionConfigRepository { abstract saveConfig( sessionName: string, - config: SessionConfig | null, + config: SessionConfig, ): Promise; abstract getConfig(sessionName: string): Promise; diff --git a/src/core/storage/LocalSessionConfigRepository.ts b/src/core/storage/LocalSessionConfigRepository.ts index a418e6cb..b17df7d6 100644 --- a/src/core/storage/LocalSessionConfigRepository.ts +++ b/src/core/storage/LocalSessionConfigRepository.ts @@ -48,13 +48,13 @@ export class LocalSessionConfigRepository extends ISessionConfigRepository { return JSON.parse(content); } - async saveConfig(sessionName: string, config: SessionConfig | null) { - // Create folder if not exist + async saveConfig(sessionName: string, config: SessionConfig) { + // Create a folder if not exist const folder = this.store.getSessionDirectory(sessionName); await fs.mkdir(folder, { recursive: true }); // Save config const filepath = this.getFilePath(sessionName); - const content = JSON.stringify(config || null); + const content = JSON.stringify(config || {}); await writeFileAtomic(filepath, content); } diff --git a/src/structures/sessions.dto.ts b/src/structures/sessions.dto.ts index a96d89d2..a8b7e6c8 100644 --- a/src/structures/sessions.dto.ts +++ b/src/structures/sessions.dto.ts @@ -122,7 +122,7 @@ export class SessionConfig { }) @IsBoolean() @IsOptional() - debug: boolean; + debug?: boolean; @ApiProperty({ example: {