diff options
Diffstat (limited to 'packages/web/src/server/api/trpc.ts')
| -rw-r--r-- | packages/web/src/server/api/trpc.ts | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/packages/web/src/server/api/trpc.ts b/packages/web/src/server/api/trpc.ts index e4dd0ab..56dcb4c 100644 --- a/packages/web/src/server/api/trpc.ts +++ b/packages/web/src/server/api/trpc.ts @@ -42,7 +42,7 @@ export const createTRPCContext = async (opts: { headers: Headers }) => { * ZodErrors so that you get typesafety on the frontend if your procedure fails due to validation * errors on the backend. */ -const t = initTRPC.context<typeof createTRPCContext>().create({ +const trpcInstance = initTRPC.context<typeof createTRPCContext>().create({ transformer: superjson, errorFormatter({ shape, error }) { return { @@ -61,7 +61,7 @@ const t = initTRPC.context<typeof createTRPCContext>().create({ * * @see https://trpc.io/docs/server/server-side-calls */ -export const createCallerFactory = t.createCallerFactory; +export const createCallerFactory = trpcInstance.createCallerFactory; /** * 3. ROUTER & PROCEDURE (THE IMPORTANT BIT) @@ -75,7 +75,7 @@ export const createCallerFactory = t.createCallerFactory; * * @see https://trpc.io/docs/router */ -export const createTRPCRouter = t.router; +export const createTRPCRouter = trpcInstance.router; /** * Middleware for timing procedure execution and adding an artificial delay in development. @@ -83,10 +83,10 @@ export const createTRPCRouter = t.router; * You can remove this if you don't like it, but it can help catch unwanted waterfalls by simulating * network latency that would occur in production but not in local development. */ -const timingMiddleware = t.middleware(async ({ next, path }) => { +const timingMiddleware = trpcInstance.middleware(async ({ next, path }) => { const start = Date.now(); - if (t._config.isDev) { + if (trpcInstance._config.isDev) { // artificial delay in dev const waitMs = Math.floor(Math.random() * 400) + 100; @@ -108,7 +108,7 @@ const timingMiddleware = t.middleware(async ({ next, path }) => { * guarantee that a user querying is authorized, but you can still access user session data if they * are logged in. */ -export const publicProcedure = t.procedure.use(timingMiddleware); +export const publicProcedure = trpcInstance.procedure.use(timingMiddleware); /** * Protected (authenticated) procedure @@ -118,7 +118,7 @@ export const publicProcedure = t.procedure.use(timingMiddleware); * * @see https://trpc.io/docs/procedures */ -export const protectedProcedure = t.procedure +export const protectedProcedure = trpcInstance.procedure .use(timingMiddleware) .use(({ ctx, next }) => { if (!ctx.user) { |