full upgrade to dev
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
import { NextResponse } from "next/server";
|
||||
import http from "http";
|
||||
import NodeCache from "node-cache";
|
||||
|
||||
// Use a dynamic import for node-fetch so tests that mock it (via jest.mock) are respected
|
||||
@@ -9,7 +8,7 @@ async function getFetch() {
|
||||
// support both CJS and ESM interop
|
||||
return (mod as { default: unknown }).default ?? mod;
|
||||
} catch (_err) {
|
||||
return (globalThis as unknown as { fetch: unknown }).fetch;
|
||||
return globalThis.fetch;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,11 +44,9 @@ export async function GET() {
|
||||
}
|
||||
|
||||
try {
|
||||
const agent = new http.Agent({ keepAlive: true });
|
||||
const fetchFn = await getFetch();
|
||||
const response = await fetchFn(
|
||||
const response = await (fetchFn as unknown as typeof fetch)(
|
||||
`${GHOST_API_URL}/ghost/api/content/posts/?key=${GHOST_API_KEY}&limit=all`,
|
||||
{ agent: agent as unknown as undefined },
|
||||
);
|
||||
const posts: GhostPostsResponse =
|
||||
(await response.json()) as GhostPostsResponse;
|
||||
|
||||
@@ -81,10 +81,9 @@ export async function GET() {
|
||||
|
||||
// For tests return a plain object so tests can inspect `.body` easily
|
||||
if (process.env.NODE_ENV === "test") {
|
||||
return {
|
||||
body: xml,
|
||||
return new NextResponse(xml, {
|
||||
headers: { "Content-Type": "application/xml" },
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
return new NextResponse(xml, {
|
||||
@@ -115,7 +114,7 @@ export async function GET() {
|
||||
try {
|
||||
const mod = await import("node-fetch");
|
||||
const nodeFetch = mod.default ?? mod;
|
||||
response = await nodeFetch(
|
||||
response = await (nodeFetch as unknown as typeof fetch)(
|
||||
`${process.env.GHOST_API_URL}/ghost/api/content/posts/?key=${process.env.GHOST_API_KEY}&limit=all`,
|
||||
);
|
||||
} catch (err) {
|
||||
|
||||
Reference in New Issue
Block a user