WorkshopTasker/server/api/clients/[id].delete.ts

23 lines
480 B
TypeScript
Raw Normal View History

import { defineEventHandler } from "h3";
2023-05-11 06:03:22 +02:00
import { database } from "~/server/utils/database";
2023-05-11 06:03:22 +02:00
import { createError } from "#imports";
export default defineEventHandler(async (e) => {
const id = e.context.params?.id as string;
try {
await database.client.delete({
where: {
id: BigInt(id),
},
});
} catch (e) {
// FIXME: should be 500 on errors other than "RecordNotFound"
throw createError({ statusCode: 404 });
}
return null;
2023-05-11 06:03:22 +02:00
});