sendou.ink/app/features/api-private/routes/seed.tsx
Kalle 8f156fb917
Team editors in addition to the owner (#2077)
* Initial

* Handle owner leaving

* Remove old team queries

* Progress

* Retire old toggle

* e2e tests

* Divide loaders/actions of team pages
2025-02-04 10:56:33 +02:00

36 lines
719 B
TypeScript

import type { ActionFunction } from "@remix-run/node";
import { z } from "zod";
import { seed } from "~/db/seed";
import { parseRequestPayload } from "~/utils/remix.server";
const seedSchema = z.object({
variation: z
.enum([
"NO_TOURNAMENT_TEAMS",
"DEFAULT",
"REG_OPEN",
"SMALL_SOS",
"NZAP_IN_TEAM",
])
.nullish(),
});
export type SeedVariation = NonNullable<
z.infer<typeof seedSchema>["variation"]
>;
export const action: ActionFunction = async ({ request }) => {
if (process.env.NODE_ENV === "production") {
throw new Response(null, { status: 400 });
}
const { variation } = await parseRequestPayload({
request,
schema: seedSchema,
});
await seed(variation);
return null;
};