mirror of
https://github.com/ArthurDanjou/arthome.git
synced 2026-01-14 20:19:26 +01:00
18 lines
457 B
TypeScript
18 lines
457 B
TypeScript
import { useValidatedBody } from 'h3-zod'
|
|
import { CreateCategorySchema } from '~~/types/types'
|
|
|
|
export default defineEventHandler(async (event) => {
|
|
try {
|
|
const user = await getUserSession(event)
|
|
const body = await useValidatedBody(event, CreateCategorySchema)
|
|
await useDrizzle().insert(tables.categories).values({
|
|
userId: user.user.id,
|
|
...body,
|
|
})
|
|
return { statusCode: 200 }
|
|
}
|
|
catch (err) {
|
|
return { err }
|
|
}
|
|
})
|