Polarcraft/webv2/server/api/users/[id]/teamInvites.post.ts
Xeovalyte fbcd0d1bb9
Some checks failed
Build and Deploy / Deploy Web (push) Failing after 1s
Build and Deploy / Deploy Discord Bot (push) Failing after 1s
feat: Added team page
2023-06-24 13:27:33 +02:00

22 lines
495 B
TypeScript

export default defineEventHandler(async (event) => {
const { teamId } = await readBody(event)
console.log(teamId)
const userId: string = event.context.params ? event.context.params.id : '@me'
if (userId === '@me') {
throw createError({ statusCode: 400, statusMessage: 'Cannot invite current user to a team' })
}
const user = await getUser(userId, event)
await UserModel.findByIdAndUpdate(user._id, {
$addToSet: {
teamInvites: teamId
}
})
return user
})