feat: initial test static site with Deno backend
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
// POST /api/echo — echoes back the request body with server metadata.
|
||||
export async function API_post(req: Request): Promise<Response> {
|
||||
let body: unknown = null;
|
||||
|
||||
try {
|
||||
body = await req.json();
|
||||
} catch {
|
||||
return Response.json(
|
||||
{ error: "Invalid JSON body" },
|
||||
{ status: 400 },
|
||||
);
|
||||
}
|
||||
|
||||
return Response.json({
|
||||
echo: body,
|
||||
server: {
|
||||
time: new Date().toISOString(),
|
||||
method: req.method,
|
||||
headers: Object.fromEntries(req.headers.entries()),
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
// GET /api/echo — returns usage instructions.
|
||||
export async function API_get(req: Request): Promise<Response> {
|
||||
return Response.json({
|
||||
usage: "POST a JSON body to this endpoint to see it echoed back.",
|
||||
example: { text: "hello", timestamp: "2026-04-11T00:00:00Z" },
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user