export default defineEventHandler(async (event) => { const userId: string = event.context.params ? event.context.params.id : '@me' if (userId === '@me') { return await getCurrentUser(event) } try { const user = await UserModel.findById(userId) if (!user) { throw createError({ statusCode: 400, statusMessage: 'No user was found' }) } return user } catch (e) { console.error('Failed to get user by id', e) throw createError({ statusCode: 500, statusMessage: 'Failed to get user' }) } })