feat: prisma schema, groups API, deploy workflow
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
import { requireAuth } from '~/server/utils/auth'
|
||||
import { nodes, addAchievement } from '~/server/utils/db'
|
||||
|
||||
export default defineEventHandler(async (event) => {
|
||||
const user = requireAuth(event)
|
||||
const id = getRouterParam(event, 'id')
|
||||
const body = await readBody(event)
|
||||
|
||||
const existing = nodes.get(id || '') || { id, state: 'pending', assigned_to: user.id }
|
||||
|
||||
// Update state
|
||||
const updated = { ...existing, ...body, updatedAt: new Date().toISOString() }
|
||||
nodes.set(id || '', updated)
|
||||
|
||||
// Gamification: achievement on completion
|
||||
if (body.state === 'completed' && existing.state !== 'completed') {
|
||||
addAchievement(user.id, {
|
||||
id: `completed-${id}`,
|
||||
title: 'Задача выполнена',
|
||||
description: `Нода ${id} завершена`,
|
||||
icon: '✅'
|
||||
})
|
||||
}
|
||||
|
||||
return { node: updated }
|
||||
})
|
||||
Reference in New Issue
Block a user