// POST /api/echo — echoes back the request body with server metadata. export async function API_post(req: Request): Promise { 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 { 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" }, }); }