Precharge les mappings IMDb au warmup (1.27s -> 16ms sur le premier appel /api?t=imdb)

This commit is contained in:
unfr
2026-04-24 07:47:23 +02:00
parent 4687b83cde
commit fbf99a9ccf
2 changed files with 15 additions and 1 deletions

View File

@@ -33,3 +33,12 @@ export async function lookupImdb(imdbId) {
}
return null;
}
// Eager-load both mappings — used at server startup to remove the first-request
// 1s latency. Returns the number of entries loaded per type.
export async function preloadMappings() {
const out = { movie: 0, tv: 0 };
try { out.movie = (await loadOne('movie')).size; } catch { /* missing */ }
try { out.tv = (await loadOne('tv')).size; } catch { /* missing */ }
return out;
}