2023-06-06 14:29:05 +02:00
|
|
|
export default defineEventHandler(async (event) => {
|
|
|
|
const { name, color } = await readBody(event)
|
|
|
|
|
2023-06-06 16:35:25 +02:00
|
|
|
const user = await getUser('@me', event)
|
|
|
|
|
2023-06-06 14:29:05 +02:00
|
|
|
const team = new TeamModel({
|
|
|
|
name,
|
|
|
|
color
|
|
|
|
})
|
|
|
|
|
|
|
|
await team.save()
|
|
|
|
|
2023-06-06 16:35:25 +02:00
|
|
|
user.teamId = team._id
|
|
|
|
|
|
|
|
await user.save()
|
|
|
|
|
2023-06-06 14:29:05 +02:00
|
|
|
return team
|
|
|
|
})
|