mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-07 03:10:11 +08:00
21 lines
571 B
TypeScript
21 lines
571 B
TypeScript
import type { Express, Request, Response } from 'express'
|
|
import { UserProfile } from '@linux-odyssey/models'
|
|
import { asyncHandler } from '../../middleware/error.js'
|
|
|
|
export const me = asyncHandler(async (req: Request, res: Response) => {
|
|
const { id, username, email } = req.user as Express.ExistingUser
|
|
|
|
const userProfile = await UserProfile.findOne({
|
|
user: id,
|
|
})
|
|
if (!userProfile) {
|
|
throw new Error(`UserProfile not found for user ${username} ${id}!`)
|
|
}
|
|
const { progress } = userProfile
|
|
res.json({
|
|
username,
|
|
email,
|
|
progress,
|
|
})
|
|
})
|