Files
liqa/src/config/app.config.ts
T
ars9 9e79cad237 feat(session): persistent browser context pool with lifecycle management
- SessionContextService: in-memory Map of live Playwright handles, reused
  per sessionName across exec_code/open_url calls; closed on module destroy
- SessionSchedulerService: @Interval closes idle sessions and deletes old
  closed ones using SESSION_IDLE_TIMEOUT_MINUTES / SESSION_DELETE_CLOSED_DAYS
- SessionService: onApplicationBootstrap closes all open sessions on restart;
  upsert marks status=open and sets lastUsedAt; adds markOpen/markClosed/
  touchLastUsed/findExpiredOpen/findOldClosed/findById helpers
- SessionEntity: status (open|closed) and lastUsedAt columns added
- AuthService: keeps browser alive after login, registers context in pool
- BrowserService: named sessions reuse persistent context; anonymous remain ephemeral
- AppConfig: all config fields declared with typed defaults; validate wired
  into ConfigModule so mis-configuration fails fast at startup
- ConfigService<AppConfig, true> used everywhere — no more untyped get() calls
2026-04-08 20:14:05 +03:00

47 lines
1015 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/sessions.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;
}