Files
arthome/server/api/tabs/[id].put.ts
2024-08-30 14:24:42 +02:00

29 lines
690 B
TypeScript

import { useValidatedBody } from 'h3-zod'
import { UpdateTabSchema } from '~~/types/types'
export default defineEventHandler(async (event) => {
try {
const { id } = await getRouterParams(event)
const body = await useValidatedBody(event, UpdateTabSchema)
await useDrizzle()
.update(tables.tabs)
.set({
name: body.name,
icon: body.icon,
color: body.color,
nameVisible: body.nameVisible,
link: body.link,
})
.where(
and(
eq(tables.tabs.id, id),
eq(tables.tabs.categoryId, body.categoryId),
),
)
return { statusCode: 200 }
}
catch (err) {
return { err }
}
})