Repository Public
1import { resolve } from "node:path";2import type { Mode } from "@/modules/content-schema";34const e = process.env;5const int = (v: string | undefined, d: number) => { const n = Number(v); return v !== undefined && Number.isFinite(n) && n >= 0 ? n : d; };67export const env = {8 /**9 * Public origin, used for canonical URLs, the sitemap and social cards. Defaults to the real public10 * address so that a server started without configuration never advertises a localhost canonical.11 */12 get publicUrl() { return (e.ATLAS_PUBLIC_URL ?? "https://atlas.spboucher.ai").replace(/\/+$/, ""); },13 /** Mutable state and media, outside git. */14 get dataDir() { return resolve(/* turbopackIgnore: true */ e.ATLAS_DATA_DIR ?? "./data"); },15 /**16 * Development-only preview: shows the committed snapshot's unpublished material behind a banner.17 * It never reads the studio database and the studio is closed while it is on. Off unless set to "1".18 */19 get mode(): Mode { return e.ATLAS_PREVIEW === "1" ? "preview" : "production"; },20 get isProd() { return e.NODE_ENV === "production"; },2122 /**23 * Where the public site reads the course from: "auto" (the studio database once it holds a published24 * plan, the committed snapshot before that) or "seed" (always the committed snapshot; used by tests).25 */26 get contentSource(): "auto" | "seed" { return e.ATLAS_CONTENT_SOURCE === "seed" || e.ATLAS_PREVIEW === "1" ? "seed" : "auto"; },2728 /** Origin of the studio as the browser sees it: the WebAuthn expected origin and the CSRF reference. */29 get studioOrigin() { return new URL(e.ATLAS_STUDIO_ORIGIN ?? this.publicUrl).origin; },30 /** WebAuthn relying-party identifier: the registrable host of the studio (atlas.spboucher.ai, or localhost). */31 get rpId() { return e.ATLAS_RP_ID ?? new URL(this.studioOrigin).hostname; },32 /** Cookies are Secure whenever the studio origin is HTTPS. */33 get secureCookies() { return this.studioOrigin.startsWith("https://"); },3435 /** Path of a checkout of the course repository readable by the server (optional; an archive can be uploaded instead). */36 get courseRepo() { return e.ATLAS_COURSE_REPO ? resolve(/* turbopackIgnore: true */ e.ATLAS_COURSE_REPO) : null; },37 /** Bearer token of GET /api/health/details. When unset, that endpoint answers 404. */38 get healthToken() { return e.ATLAS_HEALTH_TOKEN ?? ""; },3940 /** Storage budget of ATLAS_DATA_DIR in bytes (0 = no budget, only the free space of the volume counts). */41 get quotaBytes() { return int(e.ATLAS_QUOTA_GB, 0) * 1e9; },42 /** Free space on the volume under which the studio warns (and, under a quarter of it, reports a critical state). */43 get minFreeBytes() { return int(e.ATLAS_MIN_FREE_GB, 20) * 1e9; },44 get maxMasterBytes() { return int(e.ATLAS_MAX_MASTER_GB, 40) * 1e9; },45 get maxResourceBytes() { return int(e.ATLAS_MAX_RESOURCE_MB, 500) * 1e6; },46 get maxArchiveBytes() { return int(e.ATLAS_MAX_ARCHIVE_MB, 300) * 1e6; },4748 get ffmpeg() { return e.ATLAS_FFMPEG ?? "ffmpeg"; },49 get ffprobe() { return e.ATLAS_FFPROBE ?? "ffprobe"; },50 /** JSON array of renditions, e.g. [{"height":360,"videoKbps":800,"audioKbps":96}]. Empty = built-in ladder. */51 get ladder() { return e.ATLAS_LADDER ?? ""; },52 get x264Preset() { return e.ATLAS_X264_PRESET ?? "medium"; },53 get workerConcurrency() { return Math.max(1, Math.min(4, int(e.ATLAS_WORKER_CONCURRENCY, 1))); },54 get jobTimeoutSeconds() { return int(e.ATLAS_JOB_TIMEOUT_MIN, 240) * 60 || 60; },55 get maxVideoSeconds() { return int(e.ATLAS_MAX_VIDEO_MIN, 240) * 60; },56};57