diff options
| author | Yuval Adam <_@yuv.al> | 2025-07-10 13:55:01 +0200 |
|---|---|---|
| committer | Yuval Adam <_@yuv.al> | 2025-07-10 13:55:23 +0200 |
| commit | 3f0837d920ba67496c5fc7f50485aed84b37d05e (patch) | |
| tree | 45548ab3defff3abfb34245e41db606caedf7e0b /src/pages/api/hello.ts | |
| parent | c4284d7c2ab7b73af8424fcf379f44dee1682a1a (diff) | |
Simplify code'
Diffstat (limited to 'src/pages/api/hello.ts')
| -rw-r--r-- | src/pages/api/hello.ts | 54 |
1 files changed, 0 insertions, 54 deletions
diff --git a/src/pages/api/hello.ts b/src/pages/api/hello.ts deleted file mode 100644 index eba198d..0000000 --- a/src/pages/api/hello.ts +++ /dev/null @@ -1,54 +0,0 @@ -import type { APIRoute } from 'astro'; - -export const GET: APIRoute = async ({ request }) => { - const url = new URL(request.url); - const name = url.searchParams.get('name') || 'World'; - - return new Response( - JSON.stringify({ - message: `Hello, ${name}!`, - timestamp: new Date().toISOString(), - method: 'GET' - }), - { - status: 200, - headers: { - 'Content-Type': 'application/json', - }, - } - ); -}; - -export const POST: APIRoute = async ({ request }) => { - try { - const body = await request.json(); - - return new Response( - JSON.stringify({ - message: 'Data received successfully', - received: body, - timestamp: new Date().toISOString(), - method: 'POST' - }), - { - status: 200, - headers: { - 'Content-Type': 'application/json', - }, - } - ); - } catch (error) { - return new Response( - JSON.stringify({ - error: 'Invalid JSON', - timestamp: new Date().toISOString() - }), - { - status: 400, - headers: { - 'Content-Type': 'application/json', - }, - } - ); - } -};
\ No newline at end of file |
