1
0
Fork 0
polaris-task-force/src/app/api/arma/v1/reinforcements/route.ts
Z8MB1E 38e6b3d89f feat(reinforcement-pools): store per-pool balances and sync to the game bridge
New Game collection reinforcement-pools (name, faction, armaFactions,
available, enabled) with manual-edit audit via reinforcement:adjust. The
events hook applies reinforcement.spawn/.refund deltas (soft limits, no
floor, idempotent by eventId) before the game's next pull, and a new GET
/api/arma/v1/reinforcements endpoint serves enabled pools to the server.
2026-10-07 00:28:42 -04:00

35 lines
1 KiB
TypeScript

import { NextRequest, NextResponse } from "next/server";
import { requireArmaServer } from "@/lib/arma-bridge/server";
export const runtime = "nodejs";
export const dynamic = "force-dynamic";
/**
* Called by the Arma 3 bridge (get_reinforcements) on the server's ~15 s
* reinforcement cycle. Returns every enabled reinforcement pool with its
* current balance and the Arma faction classes it counts, so the game can
* attribute curator placements and render the Zeus HUD.
*/
export async function GET(req: NextRequest) {
const auth = await requireArmaServer(req);
if (auth instanceof NextResponse) return auth;
const { payload } = auth;
const pools = await payload.find({
collection: "reinforcement-pools",
where: { enabled: { equals: true } },
limit: 200,
depth: 0,
overrideAccess: true,
});
return NextResponse.json({
ok: true,
pools: pools.docs.map((pool) => ({
poolId: pool.id,
name: pool.name,
available: pool.available ?? 0,
armaFactions: pool.armaFactions ?? [],
})),
});
}