feat: Added username configuration, closes #19

This commit is contained in:
Xeovalyte 2023-06-06 14:01:19 +02:00
parent 3c5e20e18e
commit e68097d813

View File

@ -0,0 +1,16 @@
export default defineEventHandler(async (event) => {
const { usernameType } = await readBody(event)
const userId: string = event.context.params ? event.context.params.id : '@me'
if (usernameType !== 'discord' && usernameType !== 'minecraft') {
throw createError({ statusCode: 400, statusMessage: 'UsernameType must be discord or minecraft' })
}
const user = await getUser(userId, event)
user.usernameType = usernameType
await applyUsername(user)
return user.username
})