Split dailyShare.js and document the shared exported functions with JSDoc
dailyShare.js held fillTemplate and formatCountdown, used across the whole TCG, under a Daily Card name. They now live in textFormat.js at the root, and the Daily Card helpers in daily/dailyFormat.js. 173 exported functions that other files call now explain what they return and how they treat missing values: the server game rules, the toolbox storage chain, the shared hooks and utilities, and the TCG display helpers. website/AGENTS.md asks the same of new shared functions. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
166790245f
commit
aa8bb1ebaa
71 changed files with 339 additions and 57 deletions
|
|
@ -9,11 +9,13 @@
|
|||
* @see docs/SERVER.md
|
||||
*/
|
||||
|
||||
/** Lit un booléen de configuration (`1`, `true`, `yes`, `on`, sans casse) ; valeur absente ou vide : `fallback`. */
|
||||
export function bool(value, fallback = false) {
|
||||
if (value == null || value === "") return fallback;
|
||||
return /^(1|true|yes|on)$/i.test(String(value));
|
||||
}
|
||||
|
||||
/** Envoie une réponse JSON jamais mise en cache, avec sa longueur et `nosniff` ; `headers` complète ou remplace ces en-têtes. */
|
||||
export function json(res, status, body, headers = {}) {
|
||||
const payload = JSON.stringify(body);
|
||||
res.writeHead(status, {
|
||||
|
|
@ -26,6 +28,7 @@ export function json(res, status, body, headers = {}) {
|
|||
res.end(payload);
|
||||
}
|
||||
|
||||
/** Crée une erreur que le routeur d'API renvoie telle quelle au client : statut HTTP, code stable pour l'interface, message lisible. */
|
||||
export function httpError(status, code, message, extra = {}) {
|
||||
return Object.assign(new Error(message), { status, code, ...extra });
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue