Gitea Actions Runner Test / test-job (push) Successful in 0s
CI / check (push) Successful in 28s
CI / tests-unit (push) Successful in 1m39s
CI / tests-integration (push) Successful in 1m41s
CI / tests-ui (push) Successful in 2m27s
CI / preflight (push) Skipped
CI / deploy (push) Successful in 3m35s
Rebuild production nginx from the repo (deployment/proxy/*) with a single Cache-Control owner per route: the app stays the source, nginx only manages headers, and Cloudflare stores the public API allowlist at the edge. - deployment/proxy: nginx.conf, mime.types, nginx-cms.conf and the blue/green upstream snippet; config backed by scripts/nginx-sync.sh (idempotent install + reload, --check/--force). - nginx serves Cache-Tag headers on the public allowlist (cms-public), gamedata, client and camera responses so the edge and purge stay in sync. - src/lib/edge-cache.ts + tests: coalesced, fire-and-forget edge purges that no-op unless Cloudflare is configured; scripts/cf-purge.sh and cf-setup-cache.sh create and purge the cache rule. - src/lib/cloudflare-api.ts: purgeCacheByTags/purgeCacheByUrls. - Purge hooks after catalog exports (public + gamedata) and on shop, team, guild, photo and rare-values edits; ci-deploy purges after each release. - src/proxy.ts excludes the imaging/images docs from the middleware matcher.
54 lines
1.6 KiB
TypeScript
54 lines
1.6 KiB
TypeScript
"use server";
|
|
|
|
import { eq } from "drizzle-orm";
|
|
import { revalidatePath } from "next/cache";
|
|
import { requirePermission } from "@/lib/admin/guard";
|
|
import { db, WebsiteTeams } from "@/lib/db";
|
|
import { EDGE_CACHE_TAGS, purgeEdgeCache } from "@/lib/edge-cache";
|
|
import { PERMS } from "@/lib/permissions";
|
|
|
|
export async function createTeam(formData: FormData): Promise<void> {
|
|
await requirePermission(PERMS.USERS_EDIT);
|
|
|
|
const rankName = String(formData.get("rankName") ?? "")
|
|
.normalize("NFC")
|
|
.trim();
|
|
if (!rankName) return;
|
|
|
|
const badge = String(formData.get("badge") ?? "")
|
|
.normalize("NFC")
|
|
.trim();
|
|
const jobDescription = String(formData.get("jobDescription") ?? "")
|
|
.normalize("NFC")
|
|
.trim();
|
|
const staffColor =
|
|
String(formData.get("staffColor") ?? "")
|
|
.normalize("NFC")
|
|
.trim() || "#327fa8";
|
|
const hiddenRank = formData.get("hiddenRank") === "on";
|
|
|
|
const now = new Date();
|
|
await db.insert(WebsiteTeams).values({
|
|
rankName: rankName.slice(0, 255),
|
|
badge: badge ? badge.slice(0, 255) : null,
|
|
jobDescription: jobDescription ? jobDescription.slice(0, 255) : null,
|
|
staffColor: staffColor.slice(0, 255),
|
|
hiddenRank,
|
|
createdAt: now,
|
|
updatedAt: now,
|
|
});
|
|
|
|
revalidatePath("/admin/teams");
|
|
void purgeEdgeCache([EDGE_CACHE_TAGS.public], "team edited");
|
|
}
|
|
|
|
export async function deleteTeam(formData: FormData): Promise<void> {
|
|
await requirePermission(PERMS.USERS_EDIT);
|
|
|
|
const id = BigInt(String(formData.get("id")));
|
|
await db.delete(WebsiteTeams).where(eq(WebsiteTeams.id, id));
|
|
|
|
revalidatePath("/admin/teams");
|
|
void purgeEdgeCache([EDGE_CACHE_TAGS.public], "team edited");
|
|
}
|