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
23 lines
629 B
TypeScript
23 lines
629 B
TypeScript
import { defineEventHandler, readBody } from "h3";
|
|
|
|
import { checkIsClient } from "../clients.post";
|
|
import { database } from "~/server/utils/database";
|
|
import { prismaToWeb } from "~/server/utils/prismaToWeb";
|
|
|
|
import { createError } from "#imports";
|
|
|
|
export default defineEventHandler(async (e) => {
|
|
const body = await readBody(e);
|
|
const id = e.context.params?.id as string;
|
|
|
|
if (!checkIsClient(body, true)) throw createError({ message: "Invalid body", statusCode: 400 });
|
|
|
|
const rvalue = await database.client.update({
|
|
where: {
|
|
id: BigInt(id),
|
|
},
|
|
data: body,
|
|
});
|
|
|
|
return prismaToWeb(rvalue);
|
|
});
|