full upgrade to dev

This commit is contained in:
2026-01-08 11:31:57 +01:00
parent 4bf94007cc
commit 7320a0562d
17 changed files with 629 additions and 442 deletions

View File

@@ -15,40 +15,52 @@ export async function GET(request: Request) {
try {
// Debug: show whether fetch is present/mocked
// eslint-disable-next-line no-console
console.log('DEBUG fetch in fetchProject:', typeof (globalThis as any).fetch, 'globalIsMock:', !!(globalThis as any).fetch?._isMockFunction);
/* eslint-disable @typescript-eslint/no-explicit-any */
console.log(
"DEBUG fetch in fetchProject:",
typeof (globalThis as any).fetch,
"globalIsMock:",
!!(globalThis as any).fetch?._isMockFunction,
);
// Try global fetch first (as tests often mock it). If it fails or returns undefined,
// fall back to dynamically importing node-fetch.
let response: any;
if (typeof (globalThis as any).fetch === 'function') {
if (typeof (globalThis as any).fetch === "function") {
try {
response = await (globalThis as any).fetch(
`${GHOST_API_URL}/ghost/api/content/posts/slug/${slug}/?key=${GHOST_API_KEY}`,
);
} catch (e) {
} catch (_e) {
response = undefined;
}
}
if (!response || typeof response.ok === 'undefined') {
if (!response || typeof response.ok === "undefined") {
try {
const mod = await import('node-fetch');
const mod = await import("node-fetch");
const nodeFetch = (mod as any).default ?? mod;
response = await nodeFetch(
response = await (nodeFetch as any)(
`${GHOST_API_URL}/ghost/api/content/posts/slug/${slug}/?key=${GHOST_API_KEY}`,
);
} catch (err) {
} catch (_err) {
response = undefined;
}
}
/* eslint-enable @typescript-eslint/no-explicit-any */
// Debug: inspect the response returned from the fetch
// eslint-disable-next-line no-console
console.log('DEBUG fetch response:', response);
// Debug: inspect the response returned from the fetch
console.log("DEBUG fetch response:", response);
if (!response || !response.ok) {
throw new Error(`Failed to fetch post: ${response?.statusText ?? 'no response'}`);
throw new Error(
`Failed to fetch post: ${response?.statusText ?? "no response"}`,
);
}
const post = await response.json();