Move app to apps/web-react in pnpm workspace layout

This commit is contained in:
Kalle
2026-08-16 09:20:33 +03:00
parent 7e365ccfcf
commit bbc8ea57af
2913 changed files with 227 additions and 250 deletions

View File

@@ -0,0 +1,30 @@
import { refreshApiTokensCache } from "~/features/api-public/api-public-utils.server";
import { refreshBannedCache } from "~/features/ban/core/banned.server";
import { clearParticipationInfoMap } from "~/features/front-page/core/ShowcaseTournaments.server";
import { refreshSendouQInstance } from "~/features/sendouq/core/SendouQ.server";
import { clearSeasonSkillsCache } from "~/features/sendouq/q-utils.server";
import {
clearAllTournamentDataCache,
refreshRunningTournaments,
} from "~/features/tournament-bracket/core/Tournament.server";
import { refreshTentativeTiersCache } from "~/features/tournament-organization/core/tentativeTiers.server";
import { clearUserCardCache } from "~/features/user-card/UserCardRepository.server";
import { cache } from "~/utils/cache.server";
/**
* Clears and refreshes every in-process cache, so the server serves what is in
* the database right now. E2E workers call this (via the route) after writing
* test data straight into the database file.
*/
export async function refreshCaches() {
clearAllTournamentDataCache();
clearParticipationInfoMap();
clearSeasonSkillsCache();
clearUserCardCache();
cache.clear();
await refreshBannedCache();
await refreshSendouQInstance();
await refreshTentativeTiersCache();
await refreshApiTokensCache();
await refreshRunningTournaments();
}

View File

@@ -0,0 +1,13 @@
import type { ActionFunction } from "react-router";
import { DANGEROUS_CAN_ACCESS_DEV_CONTROLS } from "~/features/admin/core/dev-controls";
import * as Seasons from "~/features/mmr/core/Seasons";
export const action: ActionFunction = async () => {
if (!DANGEROUS_CAN_ACCESS_DEV_CONTROLS) {
throw new Response(null, { status: 400 });
}
Seasons.DANGEROUS_setSeasonEndedOverride(true);
return Response.json(null);
};

View File

@@ -0,0 +1,23 @@
import type { ActionFunction, LoaderFunctionArgs } from "react-router";
import * as UserRepository from "~/features/user-page/UserRepository.server";
import { updatePatreonData } from "~/modules/patreon";
import {
canAccessLohiEndpoint,
unauthorizedIfFalsy,
} from "~/utils/remix.server";
export const action: ActionFunction = async ({ request }) => {
if (!canAccessLohiEndpoint(request)) {
throw new Response("Not authorized", { status: 403 });
}
await updatePatreonData();
return null;
};
export const loader = ({ request }: LoaderFunctionArgs) => {
unauthorizedIfFalsy(canAccessLohiEndpoint(request));
return UserRepository.findAllPatrons();
};

View File

@@ -0,0 +1,26 @@
import type { ActionFunctionArgs } from "react-router";
import { DANGEROUS_CAN_ACCESS_DEV_CONTROLS } from "~/features/admin/core/dev-controls";
import * as Seasons from "~/features/mmr/core/Seasons";
import { refreshCaches } from "../core/refresh-caches.server";
export const action = async ({ request }: ActionFunctionArgs) => {
if (!DANGEROUS_CAN_ACCESS_DEV_CONTROLS) {
throw new Response(null, { status: 400 });
}
// only the start of an e2e test asks for this. mid-test cache flushes must
// leave what the running test set up alone
if (await wantsDevOverridesReset(request)) {
Seasons.DANGEROUS_setSeasonEndedOverride(false);
}
await refreshCaches();
return Response.json(null);
};
async function wantsDevOverridesReset(request: Request) {
if (!request.headers.get("content-type")) return false;
return (await request.formData()).get("resetDevOverrides") === "true";
}

View File

@@ -0,0 +1,28 @@
import type { ActionFunctionArgs } from "react-router";
import { DANGEROUS_CAN_ACCESS_DEV_CONTROLS } from "~/features/admin/core/dev-controls";
export const action = async ({ request }: ActionFunctionArgs) => {
if (!DANGEROUS_CAN_ACCESS_DEV_CONTROLS) {
throw new Response(null, { status: 400 });
}
const routineName = (await request.formData()).get("name");
const { everyHourAt00, everyHourAt30, daily, everyTwoMinutes } = await import(
"~/routines/list.server"
);
const routine = [
...everyHourAt00,
...everyHourAt30,
...daily,
...everyTwoMinutes,
].find((routine) => routine.name === routineName);
if (!routine) {
throw new Response(`Unknown routine: ${routineName}`, { status: 400 });
}
await routine.run();
return Response.json(null);
};

View File

@@ -0,0 +1,16 @@
import type { ActionFunction } from "react-router";
import { DANGEROUS_CAN_ACCESS_DEV_CONTROLS } from "~/features/admin/core/dev-controls";
import { refreshCaches } from "../core/refresh-caches.server";
export const action: ActionFunction = async () => {
if (!DANGEROUS_CAN_ACCESS_DEV_CONTROLS) {
throw new Response(null, { status: 400 });
}
const { seed } = await import("~/db/seed");
await seed();
await refreshCaches();
return Response.json(null);
};

View File

@@ -0,0 +1,14 @@
import type { ActionFunction } from "react-router";
import * as UserRepository from "~/features/user-page/UserRepository.server";
import { canAccessLohiEndpoint } from "~/utils/remix.server";
export const action: ActionFunction = async ({ request }) => {
if (!canAccessLohiEndpoint(request)) {
throw new Response(null, { status: 403 });
}
// input untyped but we trust Lohi to give us correctly shaped request here
await UserRepository.updateMany(await request.json());
return null;
};