mirror of
https://github.com/db9979/tidefront.git
synced 2026-12-06 12:54:09 +01:00
Merge Korrekturen aus dem Prüfbericht
This commit is contained in:
commit
def697d2b7
45 files changed
+1116
-237
No files matched your search
@@ -6,6 +6,7 @@ import {
|
||||
createInvite,
|
||||
createResetCode,
|
||||
disableInvite,
|
||||
enableInvite,
|
||||
emailInfo,
|
||||
listInvites,
|
||||
listPlayers,
|
||||
@@ -131,6 +132,9 @@ export const adminRouter = t.router({
|
||||
disableInvite: adminProc
|
||||
.input(z.object({ code: z.string().max(64) }))
|
||||
.mutation(async ({ ctx, input }) => ({ ok: await disableInvite(ctx.engine.db, input.code) })),
|
||||
enableInvite: adminProc
|
||||
.input(z.object({ code: z.string().max(64) }))
|
||||
.mutation(async ({ ctx, input }) => ({ ok: await enableInvite(ctx.engine.db, input.code) })),
|
||||
createResetCode: adminProc
|
||||
.input(z.object({ playerId: z.number().int().min(1) }))
|
||||
.mutation(({ ctx, input }) =>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// tRPC-Grundlagen (Kontext, Prozeduren), getrennt vom Router, damit Teil-Router sie ohne Kreisimport nutzen.
|
||||
import { initTRPC, TRPCError } from "@trpc/server";
|
||||
import { GameError, type Engine } from "@tidefront/engine";
|
||||
import { GameError, inputErrorText, type Engine, type InputIssue } from "@tidefront/engine";
|
||||
|
||||
export interface Ctx {
|
||||
engine: Engine;
|
||||
@@ -11,7 +11,14 @@ export interface Ctx {
|
||||
ip: string;
|
||||
}
|
||||
|
||||
export const t = initTRPC.context<Ctx>().create();
|
||||
export const t = initTRPC.context<Ctx>().create({
|
||||
// Eingabefehler (Zod) als deutscher Kurztext, damit der Client mehr zeigen kann als „Keine Verbindung“.
|
||||
errorFormatter({ shape, error }) {
|
||||
const issues = (error.cause as { issues?: InputIssue[] } | undefined)?.issues;
|
||||
const inputError = error.code === "BAD_REQUEST" && Array.isArray(issues) ? inputErrorText(issues) : null;
|
||||
return { ...shape, data: { ...shape.data, inputError } };
|
||||
},
|
||||
});
|
||||
|
||||
export const authed = t.procedure.use(async ({ ctx, next }) => {
|
||||
if (!ctx.player) throw new TRPCError({ code: "UNAUTHORIZED" });
|
||||
|
||||
Reference in new issue
Block a user