Files
Avtex/app/server/api/canvas/[id].put.ts
T

25 lines
572 B
TypeScript

import { requireAuth } from '~/server/utils/auth'
import { canvases } from '~/server/utils/db'
export default defineEventHandler(async (event) => {
requireAuth(event)
const id = getRouterParam(event, 'id')
const body = await readBody(event)
const existing = canvases.get(id || '')
if (!existing) {
throw createError({ statusCode: 404, message: 'Canvas not found' })
}
const updated = {
...existing,
...body,
id: existing.id,
updatedAt: new Date().toISOString()
}
canvases.set(id || '', updated)
return { canvas: updated }
})