move trpc to api

This commit is contained in:
Carl-Gerhard Lindesvärd
2024-04-23 08:21:15 +02:00
parent 8207f15a83
commit ec8bf02fb9
37 changed files with 497 additions and 156 deletions

View 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)
);
}),
});