activity logging middleware

This commit is contained in:
yohlo
2025-09-30 10:47:02 -05:00
parent 8b1bbe213d
commit 63ea515a31
11 changed files with 311 additions and 16 deletions

View File

@@ -9,6 +9,7 @@ import { MatchInput } from "@/features/matches/types";
import { serverEvents } from "@/lib/events/emitter";
import { superTokensFunctionMiddleware } from "@/utils/supertokens";
import { PlayerInfo } from "../players/types";
import { serverFnLoggingMiddleware } from "@/utils/activities";
const orderedTeamsSchema = z.object({
tournamentId: z.string(),
@@ -17,7 +18,7 @@ const orderedTeamsSchema = z.object({
export const generateTournamentBracket = createServerFn()
.inputValidator(orderedTeamsSchema)
.middleware([superTokensAdminFunctionMiddleware])
.middleware([superTokensAdminFunctionMiddleware, serverFnLoggingMiddleware])
.handler(async ({ data: { tournamentId, orderedTeamIds } }) =>
toServerResult(async () => {
logger.info("Generating tournament bracket", {
@@ -138,7 +139,7 @@ export const generateTournamentBracket = createServerFn()
export const startMatch = createServerFn()
.inputValidator(z.string())
.middleware([superTokensAdminFunctionMiddleware])
.middleware([superTokensAdminFunctionMiddleware, serverFnLoggingMiddleware])
.handler(async ({ data }) =>
toServerResult(async () => {
logger.info("Starting match", data);
@@ -171,7 +172,7 @@ const endMatchSchema = z.object({
});
export const endMatch = createServerFn()
.inputValidator(endMatchSchema)
.middleware([superTokensAdminFunctionMiddleware])
.middleware([superTokensAdminFunctionMiddleware, serverFnLoggingMiddleware])
.handler(async ({ data: { matchId, home_cups, away_cups, ot_count } }) =>
toServerResult(async () => {
logger.info("Ending match", matchId);