Polarcraft/webv2/server/api/users/[id]/minecraft/index.delete.ts

23 lines
606 B
TypeScript
Raw Normal View History

export default defineEventHandler(async (event) => {
const userId: string = event.context.params ? event.context.params.id : '@me'
const user = await getUser(userId, event)
if (user.$isEmpty('minecraft') || !user.minecraft) {
throw createError({ statusCode: 400, statusMessage: 'Minecraft has not been linked' })
}
try {
await WhitelistModel.deleteOne({ uuid: user.minecraft.uuid })
user.minecraft = undefined
2023-06-06 13:49:27 +02:00
await applyUsername(user)
} catch (e) {
console.error('Failed to update documents', e)
throw createError('Failed to update documents')
}
return ''
})