feat: implement user session management with Redis and add game token verification

This commit is contained in:
2025-12-30 01:55:40 +00:00
parent 29523ef22f
commit f01a21f2f0
28 changed files with 477 additions and 27 deletions
+15 -1
View File
@@ -1,4 +1,4 @@
import { initTRPC } from '@trpc/server';
import { initTRPC, TRPCError } from '@trpc/server';
import type { GameApiContext } from './context.js';
@@ -6,3 +6,17 @@ const t = initTRPC.context<GameApiContext>().create();
export const router = t.router;
export const procedure = t.procedure;
export const authedProcedure = t.procedure.use(({ ctx, next }) => {
if (!ctx.auth) {
throw new TRPCError({
code: 'UNAUTHORIZED',
message: 'Unauthorized',
});
}
return next({
ctx: {
...ctx,
auth: ctx.auth,
},
});
});