feat: restructure into XFlow monorepo with Nuxt 4, Modular Onion Monolith, Android client, and Desktop CLI
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
import { requireAuth } from '~/server/utils/auth'
|
||||
import { prisma } from '~/server/utils/prisma'
|
||||
|
||||
export default defineEventHandler(async (event) => {
|
||||
const user = requireAuth(event)
|
||||
const body = await readBody(event)
|
||||
const { name = 'New Canvas', nodes = [], edges = [], isPublic = false, groupId } = body
|
||||
|
||||
if (groupId) {
|
||||
const membership = await prisma.groupMember.findUnique({
|
||||
where: { userId_groupId: { userId: user.id, groupId } }
|
||||
})
|
||||
if (!membership) {
|
||||
throw createError({ statusCode: 403, message: 'Not a member of this group' })
|
||||
}
|
||||
}
|
||||
|
||||
const id = `canvas-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`
|
||||
const canvas = await prisma.canvas.create({
|
||||
data: {
|
||||
id,
|
||||
name,
|
||||
nodes,
|
||||
edges,
|
||||
isPublic,
|
||||
ownerId: user.id,
|
||||
groupId: groupId || null
|
||||
}
|
||||
})
|
||||
|
||||
return { canvas }
|
||||
})
|
||||
Reference in New Issue
Block a user