Hide unrevealed Cards pulls and show the odds players really get
Keep a pending opening's cards out of the home highlight and collection until they are revealed, and refuse transfers meanwhile. Odds now ignore rarities a pack cannot give. Stable files gain an ETag so card images revalidate instead of downloading again, and logging out clears the local collection copy. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
b2e46b1d2a
commit
155187d01f
11 changed files with 167 additions and 26 deletions
16
server.mjs
16
server.mjs
|
|
@ -66,6 +66,11 @@ function getCacheControl(root, file) {
|
|||
return "no-cache";
|
||||
}
|
||||
|
||||
function fileEtag(file) {
|
||||
const { size, mtimeMs } = statSync(file);
|
||||
return `W/"${size.toString(16)}-${Math.floor(mtimeMs).toString(16)}"`;
|
||||
}
|
||||
|
||||
export function createStaticServer({ root = defaultRoot, publicRoot = defaultPublicRoot, cardsApi = null } = {}) {
|
||||
async function handleRequest(req, res) {
|
||||
if (cardsApi && await cardsApi(req, res)) return;
|
||||
|
|
@ -79,9 +84,18 @@ export function createStaticServer({ root = defaultRoot, publicRoot = defaultPub
|
|||
return;
|
||||
}
|
||||
|
||||
const cacheControl = getCacheControl(root, file);
|
||||
// `no-cache` impose de revalider : sans validateur, chaque visite retéléchargerait le fichier entier.
|
||||
const etag = cacheControl === "no-cache" ? fileEtag(file) : null;
|
||||
if (etag && String(req.headers["if-none-match"] || "").split(",").some((value) => value.trim() === etag)) {
|
||||
res.writeHead(304, { ETag: etag, "Cache-Control": cacheControl });
|
||||
res.end();
|
||||
return;
|
||||
}
|
||||
res.writeHead(200, {
|
||||
"Content-Type": types[extname(file)] || "application/octet-stream",
|
||||
"Cache-Control": getCacheControl(root, file)
|
||||
"Cache-Control": cacheControl,
|
||||
...(etag ? { ETag: etag } : {})
|
||||
});
|
||||
// Un fichier remplacé pendant une livraison ne doit pas lever d'erreur non gérée.
|
||||
createReadStream(file).on("error", () => res.destroy()).pipe(res);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue