Files
linux-odyssey/server/src/routers/userRouter.ts
T
Justin Lin 2feedc329c refactor: use bun for package management
+ add package.json to each packages
+ update import path
2026-10-11 16:50:01 +11:00

26 lines
638 B
TypeScript

import { TRPCError } from '@trpc/server'
import { UserProfile } from '@odyssey/models'
import { protectedProcedure, router } from '../trpc.js'
export const userRouter = router({
getMyProfile: protectedProcedure.query(async (opts) => {
const { id, username, email } = opts.ctx.user
const userProfile = await UserProfile.findOne({
user: id,
})
if (!userProfile) {
throw new TRPCError({
code: 'NOT_FOUND',
message: `UserProfile not found for user ${username} ${id}!`,
})
}
const { progress } = userProfile
return {
username,
email,
progress,
}
}),
})