/products (search), product pages with revisions, getting and staying on a revision, retracting; /products/:id/edit; /create and new revisions upload from the browser straight to the catalog with a token from the hub; /library; /catalogs (directory, registering with a once-shown key); /console/catalogs to approve or reject. Every page now sends a nonce-based CSP (proxy.ts), so product descriptions can't run scripts. buttonVariants now merges classes, so outline links get their border. Co-Authored-By: Claude Opus 5.5 <[email protected]>
15 lines
509 B
TypeScript
15 lines
509 B
TypeScript
import "server-only";
|
|
import { notFound } from "next/navigation";
|
|
import { api, ApiError, unwrap, type ProductPage } from "@/lib/api";
|
|
|
|
/** The product, or not found (also when it's adult and the visitor can't see adult products). */
|
|
export async function loadProduct(id: string): Promise<ProductPage> {
|
|
if (!/^[a-z2-7]{10}$/.test(id)) notFound();
|
|
try {
|
|
return unwrap(await api.products({ id }).get());
|
|
} catch (e) {
|
|
if (e instanceof ApiError && e.status === 404) notFound();
|
|
throw e;
|
|
}
|
|
}
|