import os from 'node:os'; import path from 'node:path'; import { fileURLToPath } from 'node:url'; const here = path.dirname(fileURLToPath(import.meta.url)); export const ROOT = path.resolve(here, '..'); export const DATA_DIR = process.env.LUMENROOM_DATA ? path.resolve(process.env.LUMENROOM_DATA) : path.join(here, 'data'); export const ORIGINAL_DIR = path.join(DATA_DIR, 'originals'); export const PREVIEW_DIR = path.join(DATA_DIR, 'previews'); export const THUMB_DIR = path.join(DATA_DIR, 'thumbs'); export const DB_PATH = path.join(DATA_DIR, 'lumenroom.db'); export const DIST_DIR = path.join(ROOT, 'dist'); export const PORT = Number(process.env.PORT || 8787); export const HOST = process.env.HOST || '0.0.0.0'; /** Shared invite code required to register after the first account exists. */ export const INVITE = process.env.LUMENROOM_INVITE || ''; /** Base URL of the dashboard this editor is bridged to, e.g. http://hub:3000. */ export const GLENLOCH_URL = (process.env.GLENLOCH_URL || '').replace(/\/+$/, ''); /** Shared HMAC secret for bridge tokens; must match the dashboard's value. */ export const BRIDGE_SECRET = process.env.BRIDGE_SECRET || ''; /** How long an imported bridge event survives without being reopened. */ export const BRIDGE_TTL_HOURS = Number(process.env.LUMENROOM_BRIDGE_TTL_HOURS || 12); /** Upload ceiling in bytes (300 MB default, bigger than any consumer raw). */ export const MAX_UPLOAD = Number(process.env.LUMENROOM_MAX_UPLOAD || 300 * 1024 * 1024); /** Long edge used for the editable proxy of raw files. */ export const RAW_PREVIEW_EDGE = Number(process.env.LUMENROOM_RAW_EDGE || 6000); export const SESSION_DAYS = 30; /** How many raws decode at once. One core is left for the HTTP server. */ export const RAW_WORKERS = Math.max( 1, Number( process.env.LUMENROOM_RAW_WORKERS || Math.min(4, Math.max(1, (os.availableParallelism?.() ?? os.cpus().length) - 1)), ), ); /** Idle decoder workers are disposed after this long to release memory. */ export const RAW_IDLE_MS = Number(process.env.LUMENROOM_RAW_IDLE_MS || 90_000);