Files
BanGUI/frontend/src/api/map.ts
Lukas ffaa14f864 Switch dashboard/map/history views to archive source for long-term data
Update fail2ban dbpurgeage to 648000 and history sync backfill/pagination for archive-based 7.5 day history.
2026-04-05 20:21:54 +02:00

31 lines
991 B
TypeScript

/**
* API functions for the world map / bans-by-country endpoint.
*/
import { get } from "./client";
import { ENDPOINTS } from "./endpoints";
import type { BansByCountryResponse, TimeRange } from "../types/map";
import type { BanOriginFilter } from "../types/ban";
/**
* Fetch ban counts aggregated by country for the given time window.
*
* @param range - Time-range preset.
* @param origin - Origin filter: `"blocklist"`, `"selfblock"`, or `"all"`
* (default `"all"`, which omits the parameter entirely).
*/
export async function fetchBansByCountry(
range: TimeRange = "24h",
origin: BanOriginFilter = "all",
source: "fail2ban" | "archive" = "fail2ban",
): Promise<BansByCountryResponse> {
const params = new URLSearchParams({ range });
if (origin !== "all") {
params.set("origin", origin);
}
if (source !== "fail2ban") {
params.set("source", source);
}
return get<BansByCountryResponse>(`${ENDPOINTS.dashboardBansByCountry}?${params.toString()}`);
}