Files
test-sites/pages/api/hello.ts
T

14 lines
508 B
TypeScript

// GET /api/hello — returns a greeting.
// Demonstrates reading query parameters and using env vars.
export async function API_get(req: Request): Promise<Response> {
const url = new URL(req.url);
const name = url.searchParams.get("name") || "World";
// Example: reading a secret from environment (configured in Docker Watcher).
const prefix = Deno.env.get("GREETING_PREFIX") || "Hello";
return Response.json({
message: `${prefix}, ${name}!`,
served_by: "Deno on Docker Watcher",
});
}