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

19 lines
288 B
TypeScript

export default defineEventHandler(async (event) => {
const { name, color } = await readBody(event)
const user = await getUser('@me', event)
const team = new TeamModel({
name,
color
})
await team.save()
user.teamId = team._id
await user.save()
return team
})