forked from Wroclaw/WorkshopTasker
21 lines
495 B
TypeScript
21 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];
|
||
|
});
|