- collapse run log data blocks whose pretty-printed JSON exceeds a byte or line limit, with a per-block toggle and an expand/collapse-all button next to the Logs heading - align data blocks and toggles with the context/message column - add a "Copy logs" button that copies the filtered logs as plain text with every data block expanded - add GET /manifest.json with the app name, version and run log data limits (RUN_LOG_DATA_COLLAPSE_BYTES / RUN_LOG_DATA_COLLAPSE_LINES) - load the manifest in the client stale-while-revalidate: localStorage copy first, refetched per page load and on tab focus after a while - show the server version in the sidebar footer, with a reload hint when it differs from the client build Closes #3
89 lines
2.0 KiB
TypeScript
89 lines
2.0 KiB
TypeScript
import { plainToInstance } from "class-transformer";
|
|
import {
|
|
IsEnum,
|
|
IsInt,
|
|
IsString,
|
|
Max,
|
|
Min,
|
|
validateSync,
|
|
} from "class-validator";
|
|
|
|
import { appPackage } from "../common/app-package";
|
|
|
|
export enum TraceMode {
|
|
On = "on",
|
|
RetainOnFailure = "retain-on-failure",
|
|
Off = "off",
|
|
}
|
|
|
|
export class AppConfig {
|
|
/** `production` in the Docker image; also selects the default CORS origins. */
|
|
@IsString()
|
|
NODE_ENV: string = "development";
|
|
|
|
/** Comma-separated origins allowed to call the API cross-origin; empty = default for NODE_ENV. */
|
|
@IsString()
|
|
CORS_ORIGINS: string = "";
|
|
|
|
@IsInt()
|
|
@Min(1)
|
|
@Max(65535)
|
|
PORT: number = 3000;
|
|
|
|
@IsString()
|
|
APP_NAME: string = appPackage().name;
|
|
|
|
@IsString()
|
|
APP_VERSION: string = appPackage().version;
|
|
|
|
@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;
|
|
|
|
@IsString()
|
|
FILES_DIR: string = "data/files";
|
|
|
|
@IsInt()
|
|
@Min(1)
|
|
FILE_RUN_EXPIRATION_DAYS: number = 7;
|
|
|
|
@IsString()
|
|
FILE_CLEANUP_CRON: string = "0 3 * * *";
|
|
|
|
/** Directory with the built client to serve at `/`; empty to not serve it. */
|
|
@IsString()
|
|
CLIENT_DIR: string = "";
|
|
|
|
@IsEnum(TraceMode)
|
|
// Off by default: traces with screenshots and snapshots easily reach ~10 MB per run
|
|
PLAYWRIGHT_TRACE_MODE: TraceMode = TraceMode.Off;
|
|
|
|
/** Run log data blocks over this many bytes (pretty-printed) start collapsed in the UI. */
|
|
@IsInt()
|
|
@Min(0)
|
|
RUN_LOG_DATA_COLLAPSE_BYTES: number = 256;
|
|
|
|
/** Run log data blocks over this many lines (pretty-printed) start collapsed in the UI. */
|
|
@IsInt()
|
|
@Min(0)
|
|
RUN_LOG_DATA_COLLAPSE_LINES: number = 5;
|
|
}
|
|
|
|
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;
|
|
}
|