1
0
forked from Yara724/api

Toggle External API

This commit is contained in:
SepehrYahyaee
2026-05-16 16:23:01 +03:30
parent f2848a6179
commit 094816ce8f
11 changed files with 358 additions and 14 deletions

View File

@@ -0,0 +1,46 @@
import { ApiProperty, ApiPropertyOptional } from "@nestjs/swagger";
import { IsBoolean, IsOptional, ValidateNested } from "class-validator";
import { Type } from "class-transformer";
export class ExternalApisSettingsDto {
@ApiPropertyOptional({
description:
"When true, SandHub/Tejarat inquiry HTTP APIs are called. When false, mocks are used and validations pass.",
example: false,
})
@IsOptional()
@IsBoolean()
sandHubUseLiveApi?: boolean;
}
export class UpdateSystemSettingsDto {
@ApiPropertyOptional({ type: ExternalApisSettingsDto })
@IsOptional()
@ValidateNested()
@Type(() => ExternalApisSettingsDto)
externalApis?: ExternalApisSettingsDto;
}
export class ExternalApisSettingsViewDto {
@ApiProperty({
description:
"Stored in `system_settings.externalApis.sandHubUseLiveApi` — controls SandHubService",
example: false,
})
sandHubUseLiveApi: boolean;
}
export class SystemSettingsResponseDto {
@ApiProperty({ example: "global" })
key: string;
@ApiProperty({ type: ExternalApisSettingsViewDto })
externalApis: ExternalApisSettingsViewDto;
@ApiProperty({
description: "Human-readable mode for operators",
example: "mock",
enum: ["live", "mock"],
})
sandHubMode: "live" | "mock";
}