Add backend jobs system with built-in tasks and TOML-based configuration parsing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
OverlordandClaude Bot committed 2026-10-13 14:20:31 +02:00
1 parent 9647ac8c50
commit 1f6d41ab06
27 files changed
+1590 -25

No files matched your search

+22
View File
@@ -5,6 +5,12 @@ export type BackendConfig = {
metricsPort: number;
spawnerSocket: string;
frontendDir: string;
contentDir: string;
jobsFile: string;
/** Absolute URL of the site, for the sitemap. */
siteUrl: string;
/** Route name to content file, from LEGAL_PAGES like "impressum:impressum.txt". */
legalPages: Map<string, string>;
/** Directory for the status file shown in sandboxes; empty disables it. */
statusDir: string;
build: string;
@@ -31,6 +37,18 @@ function list(value: string | undefined): string[] {
return (value ?? '').split(',').map((entry) => entry.trim()).filter(Boolean);
}
function legalPages(value: string): Map<string, string>
{
const pages = new Map<string, string>();
for (const pair of list(value))
{
const [route = '', file = ''] = pair.split(':');
if (!/^[a-z0-9-]+$/.test(route) || !file) throw new Error(`LEGAL_PAGES entry "${pair}" must look like route:file`);
pages.set(route, file);
}
return pages;
}
export function loadConfig(env: NodeJS.ProcessEnv): BackendConfig
{
const config: BackendConfig = {
@@ -39,6 +57,10 @@ export function loadConfig(env: NodeJS.ProcessEnv): BackendConfig
metricsPort: integer(env, 'METRICS_PORT', 9090, 0),
spawnerSocket: env.SPAWNER_SOCKET ?? '/run/spawner/spawner.sock',
frontendDir: env.FRONTEND_DIR ?? '/app/public',
contentDir: env.CONTENT_DIR ?? '/content',
jobsFile: env.JOBS_FILE ?? '/config/jobs.toml',
siteUrl: env.SITE_URL ?? 'https://security-command.org',
legalPages: legalPages(env.LEGAL_PAGES ?? 'impressum:impressum.txt,datenschutz:datenschutz.txt'),
statusDir: env.STATUS_DIR ?? '',
build: env.BUILD_SHA ?? 'dev',
allowedOrigins: list(env.ALLOWED_ORIGINS),