Clean up: remove test files and logging

This commit is contained in:
Web-serfer 2026-04-27 21:05:52 +05:00
parent 8b7301d0da
commit 7144e27714
3 changed files with 4 additions and 52 deletions

View file

@ -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');