move trpc to api
This commit is contained in:
30
packages/trpc/src/routers/user.ts
Normal file
30
packages/trpc/src/routers/user.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import { clerkClient } from '@clerk/fastify';
|
||||
import { z } from 'zod';
|
||||
|
||||
import { transformUser } from '@openpanel/db';
|
||||
|
||||
import { createTRPCRouter, protectedProcedure } from '../trpc';
|
||||
|
||||
export const userRouter = createTRPCRouter({
|
||||
update: protectedProcedure
|
||||
.input(
|
||||
z.object({
|
||||
firstName: z.string(),
|
||||
lastName: z.string(),
|
||||
})
|
||||
)
|
||||
.mutation(({ input, ctx }) => {
|
||||
return (
|
||||
clerkClient.users
|
||||
.updateUser(ctx.session.userId, {
|
||||
firstName: input.firstName,
|
||||
lastName: input.lastName,
|
||||
})
|
||||
// Typescript issue that is fine for now,
|
||||
// the properties we need are there
|
||||
// Will be resolved when we update clerk/nextjs to v5
|
||||
// @ts-expect-error
|
||||
.then(transformUser)
|
||||
);
|
||||
}),
|
||||
});
|
||||
Reference in New Issue
Block a user