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