35 lines
778 B
TypeScript
35 lines
778 B
TypeScript
const BACKEND_URL = process.env.BACKEND_URL;
|
|
|
|
export async function GET(
|
|
_request: Request,
|
|
{ params }: { params: Promise<{ id: string }> },
|
|
) {
|
|
const { id } = await params;
|
|
const response = await fetch(`${BACKEND_URL}/services/${id}`);
|
|
|
|
if (!response.ok) {
|
|
return new Response("Request failed in backend", {
|
|
status: response.status,
|
|
});
|
|
}
|
|
|
|
const data = await response.json();
|
|
|
|
return Response.json(data);
|
|
}
|
|
|
|
export async function DELETE(
|
|
_request: Request,
|
|
{ params }: { params: Promise<{ id: string }> },
|
|
) {
|
|
const { id } = await params;
|
|
const response = await fetch(`${BACKEND_URL}/services/${id}`, {
|
|
method: "DELETE",
|
|
});
|
|
|
|
const data = await response.json();
|
|
|
|
return Response.json(data, {
|
|
status: response.status,
|
|
});
|
|
}
|