Polarcraft/webv2/server/api/teams/index.post.ts

19 lines
288 B
TypeScript
Raw Normal View History

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
})