Drop NODE_ENV for explicit config toggles (todo §0.1); app is environment-agnostic

This commit is contained in:
2026-06-15 10:53:33 +02:00
parent 2d43430405
commit a070362649
9 changed files with 79 additions and 37 deletions

View File

@@ -8,14 +8,15 @@ import { serveStatic } from "./static.ts";
const rootDir = join(dirname(fileURLToPath(import.meta.url)), "..");
export interface AppOptions {
// Cache compiled templates: on in production, off in dev so edits show live.
// Cache compiled templates; caller decides (server passes config.cacheTemplates).
// Off by default so edits show live; the app itself never inspects the environment.
cache?: boolean;
publicDir?: string;
viewsDir?: string;
}
export function createApp(options: AppOptions = {}): Server {
const cache = options.cache ?? process.env["NODE_ENV"] === "production";
const cache = options.cache ?? false;
const publicDir = options.publicDir ?? join(rootDir, "public");
const viewsDir = options.viewsDir ?? join(rootDir, "views");