feat: Added update team url
All checks were successful
Build and Deploy / Deploy Web (push) Successful in 1m3s
Build and Deploy / Deploy Discord Bot (push) Successful in 44s

This commit is contained in:
Xeovalyte 2023-06-08 15:23:40 +02:00
parent fabc504e06
commit df3ff5f1c3
2 changed files with 26 additions and 0 deletions

BIN
assets/logo-zoomed-dev.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 601 KiB

View File

@ -0,0 +1,26 @@
export default defineEventHandler(async (event) => {
const { teamName, teamColor } = await readBody(event)
let teamId: string = event.context.params ? event.context.params.id : '@current'
if (teamId === '@current') {
const user = await getUser('@me', event)
if (!user.team) {
throw createError({ statusCode: 400, statusMessage: 'User must be in a team' })
}
teamId = user.team._id.toString()
}
const team = await TeamModel.findByIdAndUpdate(teamId, {
$set: {
name: teamName, color: teamColor
}
}, { returnDocument: 'after', runValidators: true })
if (!team) {
throw createError({ statusCode: 400, statusMessage: 'Team could not be found' })
}
return team
})