Polarcraft/webv2/server/api/users/[id]/teamInvites.post.ts

16 lines
397 B
TypeScript

export default defineEventHandler(async (event) => {
const { teamId } = await readBody(event)
const userId: string = event.context.params ? event.context.params.id : '@me'
const user = await getUser(userId, event)
const { teamInvites } = await UserModel.findByIdAndUpdate(user._id, {
$addToSet: {
teamInvites: teamId
}
}) ?? { teamInvites: [] }
return teamInvites
})