// apps/server/src/routers/profile.ts
import { router, protectedProcedure } from '../lib/trpc';
import { z } from 'zod';
export const profileRouter = router({
// Get user profile
getProfile: protectedProcedure.query(async ({ ctx }) => {
const user = await prisma.user.findUnique({
where: { id: ctx.session.userId },
});
return user;
}),
// Update profile
updateProfile: protectedProcedure
.input(z.object({
name: z.string().optional(),
email: z.string().email().optional(),
bio: z.string().optional(),
}))
.mutation(async ({ ctx, input }) => {
const updated = await prisma.user.update({
where: { id: ctx.session.userId },
data: input,
});
return updated;
}),
});