Add Meshkee product catalog navigation and details
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
co-authored by
Cursor
parent
00126e5777
commit
34ce4f6925
@@ -0,0 +1,17 @@
|
||||
import { fetchProductCategories } from "../../../lib/meshkee";
|
||||
|
||||
export async function GET() {
|
||||
try {
|
||||
const items = await fetchProductCategories();
|
||||
return Response.json(
|
||||
{ items },
|
||||
{
|
||||
headers: {
|
||||
"Cache-Control": "public, max-age=300, stale-while-revalidate=3600",
|
||||
},
|
||||
},
|
||||
);
|
||||
} catch {
|
||||
return Response.json({ items: [] }, { status: 502 });
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
import type { NextRequest } from "next/server";
|
||||
import { fetchLatestProducts } from "../../../lib/meshkee";
|
||||
|
||||
export async function GET(request: NextRequest) {
|
||||
const requestedCount = Number(request.nextUrl.searchParams.get("count"));
|
||||
const count = Number.isInteger(requestedCount)
|
||||
? Math.min(Math.max(requestedCount, 1), 24)
|
||||
: 4;
|
||||
|
||||
try {
|
||||
const items = await fetchLatestProducts(count);
|
||||
return Response.json(
|
||||
{ items },
|
||||
{
|
||||
headers: {
|
||||
"Cache-Control": "public, max-age=300, stale-while-revalidate=3600",
|
||||
},
|
||||
},
|
||||
);
|
||||
} catch {
|
||||
return Response.json({ items: [] }, { status: 502 });
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user