feedback5 R1: pure move — the top-level code of server/index.js goes to server/http/ (config, common, files, static, media, buildTag, websocket, boot) verbatim; index.js imports it and re-exports the same 15 names, startServer and main are untouched
Only changes besides the move: `export` on helpers another module now needs (sendError, sendJson, splitUrl, GzipCache, isNotModified, serveFile, serveMedia, noopLog, makeLogger), ROOT resolves two levels up from server/http/config.js (same path), and short headers on the new files.
This commit is contained in:
1 parent
6b489b1776
commit
b48a67caec
9 files changed
+619
-552
No files matched your search
@@ -0,0 +1,28 @@
|
||||
// server/http/config.js — the repository root and the settings the server reads from the environment
|
||||
// (TRUST_PROXY → net.js trustProxy, DEBUG → the console logger's debug level). Moved from server/index.js.
|
||||
|
||||
import path from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
|
||||
/** Repository root. */
|
||||
export const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..', '..');
|
||||
|
||||
export const noopLog = { info() {}, warn() {}, error() {}, debug() {} };
|
||||
|
||||
/** TRUST_PROXY env → net.js trustProxy ('auto' unless explicitly on/off). @param {string | undefined} v */
|
||||
export function parseTrustProxy(v) {
|
||||
const s = String(v ?? '').trim().toLowerCase();
|
||||
if (['1', 'true', 'yes', 'on', 'always'].includes(s)) return true;
|
||||
if (['0', 'false', 'no', 'off', 'never'].includes(s)) return false;
|
||||
return 'auto';
|
||||
}
|
||||
|
||||
export function makeLogger(quiet) {
|
||||
if (quiet) return noopLog;
|
||||
return {
|
||||
info: (...a) => console.log(...a),
|
||||
warn: (...a) => console.warn(...a),
|
||||
error: (...a) => console.error(...a),
|
||||
debug: process.env.DEBUG ? (...a) => console.debug(...a) : () => {},
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user