2025-06-28 17:07:53 +00:00

47 lines
1.1 KiB
TypeScript

import { error, json, text } from '@sveltejs/kit';
import type { RequestHandler } from './$types';
/***********************************************************
*
* Author: Christian Risi 26/06/2025
*
* There is no POST handling here as it's not
* idempotent, so semantically it's better a
* PUT instead of a POST
*
***********************************************************/
export const GET: RequestHandler = async ({ request }) => {
return json(1)
}
export const PUT: RequestHandler = async ({ request }) => {
return json(1)
}
export const PATCH: RequestHandler = async ({ request }) => {
return json(1)
}
export const DELETE: RequestHandler = async ({ request, }) => {
// TODO: make it delete the resource
return json(1)
}
export const fallback: RequestHandler = async ({ request }) => {
// TODO: return method not allowed
const res = new Response(
null,
{
status: 405,
statusText: "Method Not Allowed",
headers: {
Allow: "GET, PUT, PATCH, DELETE"
}
}
)
return res
};