Skip to content

Commit c37ccab

Browse files
committed
.
1 parent af7121f commit c37ccab

File tree

4 files changed

+32
-45
lines changed

4 files changed

+32
-45
lines changed

src/app/catalog/page.tsx

Lines changed: 18 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { headers } from "next/headers";
22
import { redirect } from "next/navigation";
33
import { SignOut } from "@/components/sign-out-button";
4+
import { getRegistryV01Servers } from "@/generated/sdk.gen";
45
import { auth } from "@/lib/auth/auth";
56

67
export default async function CatalogPage() {
@@ -20,30 +21,23 @@ export default async function CatalogPage() {
2021
sample: Array<{ title: string; name: string; version?: string }>;
2122
} = { count: 0, titles: [], sample: [] };
2223
try {
23-
const isDev = process.env.NODE_ENV !== "production";
24-
const url = isDev
25-
? "http://localhost:9090/registry/v0.1/servers"
26-
: "/registry/v0.1/servers";
27-
const res = await fetch(url);
28-
if (res.ok) {
29-
type ServersPayload = {
30-
servers?: Array<{
31-
server?: { title?: string; name?: string; version?: string };
32-
}>;
33-
};
34-
const data: ServersPayload = await res.json();
35-
const items = Array.isArray(data?.servers) ? data.servers : [];
36-
const titles = items
37-
.map((it) => it?.server?.title ?? it?.server?.name)
38-
.filter((t): t is string => typeof t === "string")
39-
.slice(0, 5);
40-
const sample = items.slice(0, 5).map((it) => ({
41-
title: it?.server?.title ?? it?.server?.name ?? "Unknown",
42-
name: it?.server?.name ?? "unknown",
43-
version: it?.server?.version ?? undefined,
44-
}));
45-
serversSummary = { count: items.length, titles, sample };
46-
}
24+
const resp = await getRegistryV01Servers();
25+
const data = resp.data as {
26+
servers?: Array<{
27+
server?: { title?: string; name?: string; version?: string };
28+
}>;
29+
};
30+
const items = Array.isArray(data?.servers) ? data.servers : [];
31+
const titles = items
32+
.map((it) => it?.server?.title ?? it?.server?.name)
33+
.filter((t): t is string => typeof t === "string")
34+
.slice(0, 5);
35+
const sample = items.slice(0, 5).map((it) => ({
36+
title: it?.server?.title ?? it?.server?.name ?? "Unknown",
37+
name: it?.server?.name ?? "unknown",
38+
version: it?.server?.version ?? undefined,
39+
}));
40+
serversSummary = { count: items.length, titles, sample };
4741
} catch {
4842
// Leave serversSummary at its default empty state
4943
}

src/app/page.tsx

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { headers } from "next/headers";
22
import Link from "next/link";
33
import { redirect } from "next/navigation";
4+
import { getRegistryV01Servers } from "@/generated/sdk.gen";
45
import { auth } from "@/lib/auth/auth";
56

67
export default async function Home() {
@@ -19,23 +20,16 @@ export default async function Home() {
1920
titles: [],
2021
};
2122
try {
22-
const isDev = process.env.NODE_ENV !== "production";
23-
const url = isDev
24-
? "http://localhost:9090/registry/v0.1/servers"
25-
: "/registry/v0.1/servers";
26-
const res = await fetch(url);
27-
if (res.ok) {
28-
type ServersPayload = {
29-
servers?: Array<{ server?: { title?: string; name?: string } }>;
30-
};
31-
const data: ServersPayload = await res.json();
32-
const items = Array.isArray(data?.servers) ? data.servers : [];
33-
const titles = items
34-
.map((it) => it?.server?.title ?? it?.server?.name)
35-
.filter((t): t is string => typeof t === "string")
36-
.slice(0, 5);
37-
serversSummary = { count: items.length, titles };
38-
}
23+
const resp = await getRegistryV01Servers();
24+
const data = resp.data as {
25+
servers?: Array<{ server?: { title?: string; name?: string } }>;
26+
};
27+
const items = Array.isArray(data?.servers) ? data.servers : [];
28+
const titles = items
29+
.map((it) => it?.server?.title ?? it?.server?.name)
30+
.filter((t): t is string => typeof t === "string")
31+
.slice(0, 5);
32+
serversSummary = { count: items.length, titles };
3933
} catch {
4034
// Leave serversSummary at its default { count: 0, titles: [] }
4135
}

src/mocks/mocker.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,6 @@ export function autoGenerateHandlers() {
371371
const result: RequestHandler[] = [];
372372

373373
// Prefer Vite glob import when available (Vitest/Vite runtime)
374-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
375374
const fixtureImporters: Record<string, () => Promise<unknown>> =
376375
typeof import.meta.glob === "function"
377376
? import.meta.glob("./fixtures/**", { import: "default" })
@@ -566,7 +565,7 @@ export function autoGenerateHandlers() {
566565
const s = (jsonValue as Record<string, unknown>).servers;
567566
if (Array.isArray(s)) serversLen = s.length;
568567
}
569-
// eslint-disable-next-line no-console
568+
// biome-ignore lint: dev fixture response summary
570569
console.log(
571570
`[auto-mocker] respond ${method.toUpperCase()} ${rawPath} -> ${
572571
successStatus ? Number(successStatus) : 200

src/mocks/server.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ const port = 9090;
88
const httpServer = createServer(...handlers);
99

1010
httpServer.on("request", (req: IncomingMessage, _res: ServerResponse) => {
11-
// eslint-disable-next-line no-console
11+
// biome-ignore lint: dev mock server request log
1212
console.log(`[mock] ${req.method} ${req.url}`);
1313
});
1414

1515
httpServer.listen(port, () => {
16-
// eslint-disable-next-line no-console
16+
// biome-ignore lint: dev mock server startup log
1717
console.log(`MSW mock server running on http://localhost:${port}`);
1818
});

0 commit comments

Comments
 (0)