Files
BanGUI/frontend/src/api/endpoints.ts
Lukas cbad4ea706 Add ban management features and update documentation
- Implement ban model, service, and router endpoints in backend
- Add ban table component and dashboard integration in frontend
- Update ban-related types and API endpoints
- Add comprehensive tests for ban service and dashboard router
- Update documentation (Features, Tasks, Architecture, Web-Design)
- Clean up old fail2ban configuration files
- Update Makefile with new commands
2026-03-06 20:33:42 +01:00

91 lines
3.9 KiB
TypeScript

/**
* API endpoint path constants.
*
* Every backend path used by the frontend is defined here.
* Components and API modules import from this file rather than
* hard-coding URL strings, so renaming an endpoint requires only one change.
*/
export const ENDPOINTS = {
// -------------------------------------------------------------------------
// Health
// -------------------------------------------------------------------------
health: "/health",
// -------------------------------------------------------------------------
// Setup wizard
// -------------------------------------------------------------------------
setup: "/setup",
setupTimezone: "/setup/timezone",
// -------------------------------------------------------------------------
// Authentication
// -------------------------------------------------------------------------
authLogin: "/auth/login",
authLogout: "/auth/logout",
// -------------------------------------------------------------------------
// Dashboard
// -------------------------------------------------------------------------
dashboardStatus: "/dashboard/status",
dashboardBans: "/dashboard/bans",
dashboardBansByCountry: "/dashboard/bans/by-country",
// -------------------------------------------------------------------------
// Jails
// -------------------------------------------------------------------------
jails: "/jails",
jail: (name: string): string => `/jails/${encodeURIComponent(name)}`,
jailStart: (name: string): string => `/jails/${encodeURIComponent(name)}/start`,
jailStop: (name: string): string => `/jails/${encodeURIComponent(name)}/stop`,
jailIdle: (name: string): string => `/jails/${encodeURIComponent(name)}/idle`,
jailReload: (name: string): string => `/jails/${encodeURIComponent(name)}/reload`,
jailsReloadAll: "/jails/reload-all",
jailIgnoreIp: (name: string): string => `/jails/${encodeURIComponent(name)}/ignoreip`,
// -------------------------------------------------------------------------
// Bans
// -------------------------------------------------------------------------
bans: "/bans",
bansActive: "/bans/active",
// -------------------------------------------------------------------------
// Geo / IP lookup
// -------------------------------------------------------------------------
geoLookup: (ip: string): string => `/geo/lookup/${encodeURIComponent(ip)}`,
// -------------------------------------------------------------------------
// Configuration
// -------------------------------------------------------------------------
configJails: "/config/jails",
configJail: (name: string): string => `/config/jails/${encodeURIComponent(name)}`,
configJailLogPath: (name: string): string =>
`/config/jails/${encodeURIComponent(name)}/logpath`,
configGlobal: "/config/global",
configReload: "/config/reload",
configRegexTest: "/config/regex-test",
configPreviewLog: "/config/preview-log",
// -------------------------------------------------------------------------
// Server settings
// -------------------------------------------------------------------------
serverSettings: "/server/settings",
serverFlushLogs: "/server/flush-logs",
// -------------------------------------------------------------------------
// Ban history
// -------------------------------------------------------------------------
history: "/history",
historyIp: (ip: string): string => `/history/${encodeURIComponent(ip)}`,
// -------------------------------------------------------------------------
// Blocklists
// -------------------------------------------------------------------------
blocklists: "/blocklists",
blocklist: (id: number): string => `/blocklists/${String(id)}`,
blocklistPreview: (id: number): string => `/blocklists/${String(id)}/preview`,
blocklistsImport: "/blocklists/import",
blocklistsSchedule: "/blocklists/schedule",
blocklistsLog: "/blocklists/log",
} as const;