import { defineEventHandler } from "h3"; import { type ResultSetHeader } from "mysql2"; import { database } from "~/server/utils/database"; import { createError } from "#imports"; export default defineEventHandler(async (e) => { const id = e.context.params?.id; const [result] = await database.query( "DELETE FROM `orders` WHERE `id` = ?", [id], ) as unknown as [ResultSetHeader]; if (result.affectedRows === 0) throw createError({ statusCode: 404 }); return null; });