Skip to content

Commit

Permalink
fixing typescript errors
Browse files Browse the repository at this point in the history
  • Loading branch information
andrew-bierman committed Feb 10, 2024
1 parent 4085048 commit fe82ec9
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions server/src/trpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { TRPCError, initTRPC } from '@trpc/server';
import type * as trpcExpress from '@trpc/server/adapters/express';
import { getUserByTokenService } from './services/user/getUserByToken';

const t = initTRPC.create();
const t = initTRPC.context<Context>().create();

/**
* Create a context object that will be passed to all resolvers
Expand Down Expand Up @@ -42,7 +42,7 @@ export const createContext = async ({
};
};

export type Context = inferAsyncReturnType<typeof createContext>;
export type Context = Awaited<ReturnType<typeof createContext>>;

/**
* Export reusable router and procedure helpers
Expand All @@ -65,7 +65,7 @@ const isAuthenticated = t.middleware(async (opts) => {
message: 'Invalid token',
});
}
return next(ctx);
return next({ ctx: { ...ctx, user: ctx.user } });
});

export const protectedProcedure = t.procedure.use(isAuthenticated);

0 comments on commit fe82ec9

Please sign in to comment.