Files
luminary/server/config.mjs
T
bhursey fa0a7e64ef Speed up raw imports and add a per-import 16-bit toggle
Import raws four at a time to match the decoder pool, compress the 16-bit
sidecar with RLE on the libuv pool, and demosaic X-Trans files in a single
Markesteijn pass so Fuji imports no longer queue into decode timeouts. The
import dialog now offers 16-bit (default) or 8-bit per import, sent as
`?sidecar=0`, and the camera thumbnail and embedded-preview fallbacks no
longer drop to 8-bit samples or store a 0x0 photo.
2026-12-02 03:25:53 +00:00

124 lines
5.0 KiB
JavaScript

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, '..');
/** Read a Luminary setting, falling back to its pre-rebrand LUMENROOM_ name. */
function setting(name, fallback = '') {
return process.env[`LUMINARY_${name}`] || process.env[`LUMENROOM_${name}`] || fallback;
}
const dataDir = setting('DATA');
export const DATA_DIR = dataDir ? path.resolve(dataDir) : 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');
// Keep the original filename so an existing catalog opens without a migration.
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 = setting('INVITE');
/**
* Single-user desktop mode, set by the Windows launcher (LUMINARY_LOCAL=1).
* The server creates one admin account and treats an unauthenticated request as
* that account, so a personal install never shows a signup or sign-in screen.
* Only safe on loopback, which is where the launcher binds; the server warns if
* it is enabled with a reachable HOST.
*/
export const LOCAL_MODE = setting('LOCAL') === '1';
export const LOCAL_EMAIL = setting('LOCAL_EMAIL', 'local@luminary');
/** 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 || '';
/** Optional key for encrypting saved SMTP and bridge credentials at rest. */
export const SECRET_KEY = setting('SECRET_KEY');
/** Trust X-Forwarded-For for rate limits; only behind a proxy that sets it. */
export const TRUST_PROXY = setting('TRUST_PROXY') === '1';
/** How long an imported bridge event survives without being reopened. */
export const BRIDGE_TTL_HOURS = Number(setting('BRIDGE_TTL_HOURS', '12'));
/** Upload ceiling in bytes (300 MB default, bigger than any consumer raw). */
export const MAX_UPLOAD = Number(setting('MAX_UPLOAD', String(300 * 1024 * 1024)));
/** Per-account storage allowance. 100 GiB unless the admin changes it. */
export const QUOTA_BYTES = Number(setting('QUOTA_BYTES', String(100 * 1024 * 1024 * 1024)));
/** Fraction of the quota at which the account is warned (0.9 = 90%). */
export const QUOTA_WARN_RATIO = Math.min(
0.99,
Math.max(0.5, Number(setting('QUOTA_WARN_RATIO', '0.9')) || 0.9),
);
/** Scheduled prunes always leave at least this much room below the cap. */
export const QUOTA_TARGET_RATIO = Math.min(
0.95,
Math.max(0.5, Number(setting('QUOTA_TARGET_RATIO', '0.8')) || 0.8),
);
/** Public URL used in notification emails. Empty falls back to localhost. */
export const PUBLIC_URL = setting('PUBLIC_URL').replace(/\/+$/, '');
/** Gmail SMTP defaults; the admin can override these in Administration. */
export const SMTP_HOST = setting('SMTP_HOST', 'smtp.gmail.com');
export const SMTP_PORT = Number(setting('SMTP_PORT', '465'));
export const SMTP_SECURE = setting('SMTP_SECURE', 'true') !== 'false';
export const SMTP_USER = setting('SMTP_USER');
export const SMTP_APP_PASSWORD = setting('SMTP_APP_PASSWORD');
export const SMTP_FROM = setting('SMTP_FROM', SMTP_USER);
/** Long edge used for the editable proxy of raw files. */
export const RAW_PREVIEW_EDGE = Number(setting('RAW_EDGE', '6000'));
/**
* Also store the 16-bit samples LibRaw decoded as a sidecar next to the JPEG
* proxy. It costs roughly 25x the JPEG in disk and download, but it is the only
* way the editor can grade from more than 256 levels per channel.
*/
export const RAW_16BIT = setting('16BIT', '1') !== '0';
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(
setting(
'RAW_WORKERS',
String(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(setting('RAW_IDLE_MS', '90000'));
/**
* Demosaic setting for Fujifilm X-Trans sensors. LibRaw reads `userQual` as
* Markesteijn passes for X-Trans, and the 3-pass default costs about 50 s on a
* 40 MP frame while 1-pass costs about 9 s. The proxy is downsampled to
* RAW_PREVIEW_EDGE, so the difference does not survive to the editor.
*/
export const RAW_XTRANS_QUALITY = Math.min(
3,
Math.max(1, Number(setting('RAW_XTRANS_QUALITY', '1')) || 1),
);
/** Ceiling on one demosaic, measured from when a worker picks the job up. */
export const RAW_TIMEOUT_MS = Number(setting('RAW_TIMEOUT_MS', '120000'));