From 7144e277149ad04e6f7ae6a56cfac6eef7120a32 Mon Sep 17 00:00:00 2001 From: Web-serfer Date: Mon, 27 Apr 2026 21:05:52 +0500 Subject: [PATCH] Clean up: remove test files and logging --- frontend/src/pages/api/increment-views.ts | 16 ++++--------- frontend/src/pages/api/test-debug.ts | 12 ---------- frontend/src/pages/api/test-post.ts | 28 ----------------------- 3 files changed, 4 insertions(+), 52 deletions(-) delete mode 100644 frontend/src/pages/api/test-debug.ts delete mode 100644 frontend/src/pages/api/test-post.ts diff --git a/frontend/src/pages/api/increment-views.ts b/frontend/src/pages/api/increment-views.ts index 063b977..b68d74a 100644 --- a/frontend/src/pages/api/increment-views.ts +++ b/frontend/src/pages/api/increment-views.ts @@ -19,24 +19,18 @@ function generateVisitorHash(ip: string, userAgent: string): string { async function pbRequest(method: string, path: string, body?: object) { const url = `${POCKETBASE_URL}${path}`; - console.log('[Increment Views] PB Request:', method, url); const options: RequestInit = { method, headers: { 'Content-Type': 'application/json' }, }; - if (body) { - options.body = JSON.stringify(body); - console.log('[Increment Views] PB Body:', JSON.stringify(body)); - } + if (body) options.body = JSON.stringify(body); const res = await fetch(url, options); - const status = res.status; - const err = await res.text(); - console.log('[Increment Views] PB Response:', status, err); if (!res.ok) { - throw new Error(`PB ${method} ${path}: ${status} - ${err}`); + const err = await res.text(); + throw new Error(`PB ${method} ${path}: ${res.status} - ${err}`); } - return JSON.parse(err) || {}; + return res.json(); } function jsonResponse(data: object, status = 200): Response { @@ -47,8 +41,6 @@ function jsonResponse(data: object, status = 200): Response { } export const GET: APIRoute = async ({ request, url }) => { - console.log('[Increment Views] PB_URL:', POCKETBASE_URL); - try { const postId = url.searchParams.get('postId'); diff --git a/frontend/src/pages/api/test-debug.ts b/frontend/src/pages/api/test-debug.ts deleted file mode 100644 index 85989e7..0000000 --- a/frontend/src/pages/api/test-debug.ts +++ /dev/null @@ -1,12 +0,0 @@ -import type { APIRoute } from 'astro'; - -export const GET: APIRoute = async ({ request }) => { - return new Response(JSON.stringify({ - url: request.url, - method: request.method, - headers: Object.fromEntries(request.headers.entries()), - }), { - status: 200, - headers: { 'Content-Type': 'application/json' } - }); -}; \ No newline at end of file diff --git a/frontend/src/pages/api/test-post.ts b/frontend/src/pages/api/test-post.ts deleted file mode 100644 index d1d857c..0000000 --- a/frontend/src/pages/api/test-post.ts +++ /dev/null @@ -1,28 +0,0 @@ -import type { APIRoute } from 'astro'; - -export const POST: APIRoute = async ({ request, url }) => { - if (request.method === 'OPTIONS') { - return new Response(null, { - status: 204, - headers: { - 'Access-Control-Allow-Origin': '*', - 'Access-Control-Allow-Methods': 'POST, OPTIONS', - 'Access-Control-Allow-Headers': 'Content-Type', - } - }); - } - - const params = Object.fromEntries(url.searchParams.entries()); - - return new Response(JSON.stringify({ - method: 'POST', - params, - url: request.url, - }), { - status: 200, - headers: { - 'Content-Type': 'application/json', - 'Access-Control-Allow-Origin': '*', - } - }); -}; \ No newline at end of file