27 lines
687 B
TypeScript
27 lines
687 B
TypeScript
// apps/dm/src/entities/content/
|
|
// contents-api.ts
|
|
import { unstable_cache } from "next/cache";
|
|
import { ENDPOINT } from "@/src/shared/config";
|
|
|
|
|
|
|
|
export const getCachedContentDetail = unstable_cache(
|
|
async (contsSn: number, menuCd: string) => {
|
|
const baseUrl = process.env.NEXT_PUBLIC_PROXY_HOST || "http://localhost:3015";
|
|
const res = await fetch(
|
|
`${baseUrl}${ENDPOINT.CMS_SERVICE.CONTENTS}/${contsSn}?menuCd=${menuCd}`,
|
|
{
|
|
next: { revalidate: 3600, tags: [`content:${contsSn}`] },
|
|
}
|
|
);
|
|
|
|
if (!res.ok) {
|
|
console.log(res);
|
|
throw new Error("Failed to fetch content");
|
|
}
|
|
|
|
return res.json();
|
|
},
|
|
["dm-content-detail"],
|
|
);
|