router 분리

This commit is contained in:
2026-01-16 18:06:51 +00:00
parent 998035c66c
commit f3591612fa
13 changed files with 1440 additions and 1368 deletions
+15
View File
@@ -0,0 +1,15 @@
import { TRPCError } from '@trpc/server';
import type { GameApiContext } from '../../context.js';
export const getMyGeneral = async (ctx: Pick<GameApiContext, 'db' | 'auth'>) => {
if (!ctx.auth?.user.id) {
throw new TRPCError({ code: 'UNAUTHORIZED' });
}
const general = await ctx.db.general.findFirst({
where: { userId: ctx.auth.user.id },
});
if (!general) {
throw new TRPCError({ code: 'NOT_FOUND', message: 'General not found' });
}
return general;
};