- Clone import: defer FurnitureData.json writes and append all entries in a single batched write instead of one read-modify-write per item, removing the main serialization bottleneck for large batches. - Clone import: raise SSE batch concurrency cap from 5 to 10 and bump the clone client/route default from 2 to 6. - Add a flush hook to runSseBatch so callers can batch deferred work before batch_complete is emitted, and surface flush errors as an error event. - Enable Next.js Cache Components (instant: false opt-out) and silence the related build warnings in next.config.ts. - Switch isomorphic-dompurify to dompurify and refresh dependencies.
41 lines
1.1 KiB
TypeScript
41 lines
1.1 KiB
TypeScript
import { eq } from "drizzle-orm";
|
|
import { apiJson } from "@/lib/api";
|
|
import { db, WebsiteArticles } from "@/lib/db";
|
|
|
|
/**
|
|
* GET /api/articles/:slug — single website_article by slug, including the
|
|
* fullStory body. Returns { error } (404) when the slug is unknown.
|
|
*/
|
|
export async function GET(
|
|
_req: Request,
|
|
{ params }: { params: Promise<{ slug: string }> },
|
|
) {
|
|
const { slug } = await params;
|
|
|
|
try {
|
|
const [article] = await db
|
|
.select({
|
|
id: WebsiteArticles.id,
|
|
title: WebsiteArticles.title,
|
|
slug: WebsiteArticles.slug,
|
|
shortStory: WebsiteArticles.shortStory,
|
|
fullStory: WebsiteArticles.fullStory,
|
|
image: WebsiteArticles.image,
|
|
createdAt: WebsiteArticles.createdAt,
|
|
updatedAt: WebsiteArticles.updatedAt,
|
|
})
|
|
.from(WebsiteArticles)
|
|
.where(eq(WebsiteArticles.slug, slug))
|
|
.limit(1);
|
|
|
|
if (!article) {
|
|
return apiJson({ error: "Article not found" }, { status: 404 });
|
|
}
|
|
|
|
return apiJson({ data: article });
|
|
} catch {
|
|
// DB unavailable — treat as not found rather than a 500.
|
|
return apiJson({ error: "Article not found" }, { status: 200 });
|
|
}
|
|
}
|