22 lines
495 B
TypeScript
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
|
|
})
|