2023-11-06 02:57:00 +01:00
|
|
|
import { defineEventHandler } from "h3";
|
2023-05-11 06:03:22 +02:00
|
|
|
|
2023-11-08 05:35:48 +01:00
|
|
|
import { database } from "~/server/utils/database";
|
|
|
|
import { prismaToWeb } from "~/server/utils/prismaToWeb";
|
2023-05-11 06:03:22 +02:00
|
|
|
|
2023-11-08 05:35:48 +01:00
|
|
|
import { createError } from "#imports";
|
|
|
|
|
|
|
|
export default defineEventHandler(async (e) => {
|
|
|
|
const key = e.context.params?.id as string;
|
|
|
|
const rvalue = await database.client.findUnique({
|
|
|
|
where: {
|
|
|
|
id: BigInt(key),
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
if (!rvalue) throw createError({ statusCode: 404 });
|
|
|
|
return prismaToWeb(rvalue);
|
2023-05-11 06:03:22 +02:00
|
|
|
});
|