mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-03-21 18:04:39 -05:00
31 lines
907 B
TypeScript
31 lines
907 B
TypeScript
import type { LoaderFunctionArgs } from "react-router";
|
|
import { cors } from "remix-utils/cors";
|
|
import { z } from "zod/v4";
|
|
import * as TournamentMatchRepository from "~/features/tournament-bracket/TournamentMatchRepository.server";
|
|
import { parseParams } from "~/utils/remix.server";
|
|
import { id } from "~/utils/zod";
|
|
import {
|
|
handleOptionsRequest,
|
|
requireBearerAuth,
|
|
} from "../api-public-utils.server";
|
|
import type { GetTournamentPlayersResponse } from "../schema";
|
|
|
|
const paramsSchema = z.object({
|
|
id,
|
|
});
|
|
|
|
export const loader = async ({ params, request }: LoaderFunctionArgs) => {
|
|
await handleOptionsRequest(request);
|
|
requireBearerAuth(request);
|
|
|
|
const { id } = parseParams({
|
|
params,
|
|
schema: paramsSchema,
|
|
});
|
|
|
|
const participants: GetTournamentPlayersResponse =
|
|
await TournamentMatchRepository.userParticipationByTournamentId(id);
|
|
|
|
return cors(request, Response.json(participants));
|
|
};
|