WorkshopTasker/server/api/orders/[id].delete.ts
Wroclaw eebf25198d Replace mysql2 with prisma
also I updated packages,
and properly typed api input
a lot of time was spent, I don't remeber what really I did x3
but everything was related to replacing mysql2 with prisma
2023-11-08 05:36:12 +01:00

22 lines
479 B
TypeScript

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