20CAKE20.JS
11-server

Server

11

server/api/cakes/[id].get.ts

Route Parameter

Example

Read a file-based route parameter from the API context.

export default async (_data: unknown, context: ApiContext) => {
  const cake = await db.cake.findUnique({
    where: { id: context.params.id },
  });
  if (!cake) return new Response("Cake not found.", { status: 404 });
  return { cake };
};