fix(public): distinguish unavailable data from empty results and missing pages
CI / check (push) Successful in 56s
CI / deploy (push) Successful in 1m30s
CI / publish-container (push) Successful in 44s

This commit is contained in:
Simo committed 2026-09-11 00:39:53 +02:00
1 parent db4acbb46e
commit 445ef13846
16 files changed
+608 -169

No files matched your search

+6 -2
View File
@@ -26,12 +26,15 @@ const CACHE_KEY = "news_list";
const FETCH_LIMIT = 30;
/**
* Shared, cached news list used by both the homepage and the news archive so
* Shared, cached news preview list used by the homepage and other widgets so
* a single "news_list" cache entry serves both routes. Returns at most
* `limit` rows with `createdAt` normalized to a Date (the cache round-trip
* serializes timestamps to ISO strings).
*/
export async function getNewsList(limit: number): Promise<NewsListItem[]> {
export async function getNewsList(
limit: number,
options: { throwOnError?: boolean } = {},
): Promise<NewsListItem[]> {
try {
const rows = await cacheNews<NewsListRow[]>(CACHE_KEY, TTL_MS, () =>
db
@@ -62,6 +65,7 @@ export async function getNewsList(limit: number): Promise<NewsListItem[]> {
}))
.slice(0, limit);
} catch (error) {
if (options.throwOnError) throw error;
logger.error("Public news query failed", { module: "news", error });
return [];
}