- serve REST endpoints under /api/v1 with root exceptions for health and mcp - move swagger UI to /docs and allow direct frontend calls via CORS - remove Vite proxy/hash routing and rely on env-driven VITE_API_URL
47 lines
1011 B
TypeScript
47 lines
1011 B
TypeScript
import { IsInt, IsString, Min, Max } from "class-validator";
|
|
import { plainToInstance } from "class-transformer";
|
|
import { validateSync } from "class-validator";
|
|
|
|
import pkg from "../../package.json";
|
|
|
|
export class AppConfig {
|
|
@IsString()
|
|
NODE_ENV: string = "development";
|
|
|
|
@IsInt()
|
|
@Min(1)
|
|
@Max(65535)
|
|
PORT: number = 3000;
|
|
|
|
@IsString()
|
|
APP_NAME: string = pkg.name;
|
|
|
|
@IsString()
|
|
APP_VERSION: string = pkg.version;
|
|
|
|
@IsString()
|
|
KEYS_DIR: string = "keys";
|
|
|
|
@IsString()
|
|
DB_PATH: string = "data/liqa.db";
|
|
|
|
@IsInt()
|
|
@Min(1)
|
|
SESSION_IDLE_TIMEOUT_MINUTES: number = 30;
|
|
|
|
@IsInt()
|
|
@Min(1)
|
|
SESSION_DELETE_CLOSED_DAYS: number = 7;
|
|
}
|
|
|
|
export function validateAppConfig(config: Record<string, unknown>): AppConfig {
|
|
const validated = plainToInstance(AppConfig, config, {
|
|
enableImplicitConversion: true,
|
|
});
|
|
const errors = validateSync(validated, { skipMissingProperties: false });
|
|
if (errors.length > 0) {
|
|
throw new Error(errors.toString());
|
|
}
|
|
return validated;
|
|
}
|