Wroclaw
eebf25198d
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
22 lines
480 B
TypeScript
22 lines
480 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.client.delete({
|
|
where: {
|
|
id: BigInt(id),
|
|
},
|
|
});
|
|
} catch (e) {
|
|
// FIXME: should be 500 on errors other than "RecordNotFound"
|
|
throw createError({ statusCode: 404 });
|
|
}
|
|
|
|
return null;
|
|
});
|