mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-06 03:20:13 +08:00
feat: add /users/me endpoint
This commit is contained in:
1 parent
ae221a696c
commit
a7422853fa
8 files changed
+112
-19
No files matched your search
@@ -0,0 +1,25 @@
|
||||
import { UserProfile } from '@linux-odyssey/models'
|
||||
|
||||
export async function me(req, res) {
|
||||
const userProfile = await UserProfile.findOne({
|
||||
user: req.user._id,
|
||||
}).populate('user')
|
||||
console.log(userProfile)
|
||||
if (!userProfile) {
|
||||
res.status(404).json({ message: 'User not found' })
|
||||
return
|
||||
}
|
||||
const {
|
||||
user: { username, email },
|
||||
progress,
|
||||
} = userProfile
|
||||
res.json({
|
||||
username,
|
||||
email,
|
||||
progress,
|
||||
})
|
||||
}
|
||||
|
||||
export default {
|
||||
me,
|
||||
}
|
||||
Reference in new issue
Block a user