Files
linux-odyssey/server/src/api/controllers/userController.js
T
2023-11-14 10:45:24 +08:00

21 lines
506 B
JavaScript

import { UserProfile } from '@linux-odyssey/models'
import { asyncHandler } from '../../middleware/error.js'
export const me = asyncHandler(async (req, res) => {
const userProfile = await UserProfile.findOne({
user: req.user._id,
})
if (!userProfile) {
throw new Error(
`UserProfile not found for user ${req.user.username} ${req.user._id}!`
)
}
const { username, email } = req.user
const { progress } = userProfile
res.json({
username,
email,
progress,
})
})