WorkshopTasker/server/api/clients/[id].get.ts
2023-05-11 06:03:22 +02:00

20 lines
495 B
TypeScript

/* global defineEventHandler, createError */
import { database, data } from "~/server/utils/database";
import { client } from "~/utils/types/database";
export default defineEventHandler(async (e) => {
const id = e.context.params?.id;
const [data] = await database.query(
"SELECT *, CONVERT(`id`, CHAR) AS `id` FROM `clients` WHERE `id` = ?",
[id],
) as unknown as data<client>;
if (!data[0]) {
throw createError({
statusCode: 404,
});
}
return data[0];
});