import { json, error } from '@sveltejs/kit';
import type { RequestHandler } from './$types';
import { backendFetch } from '$lib/server/scraper';

export const PATCH: RequestHandler = async ({ params }) => {
	const id = params.id;
	if (!id) throw error(400, 'id required');
	const res = await backendFetch('/api/notifications/' + id, { method: 'PATCH' });
	const data = await res.json().catch(() => ({}));
	return json(data);
};

// DELETE /api/notifications/[id] — dismiss a single notification
export const DELETE: RequestHandler = async ({ params }) => {
	const id = params.id;
	if (!id) throw error(400, 'id required');
	const res = await backendFetch('/api/notifications/' + id, { method: 'DELETE' });
	const data = await res.json().catch(() => ({}));
	return json(data);
};
