The web API and dashboard for the Global Ban Minecraft mod. Servers sync punishments to and from it with a single POST request, and server owners manage servers, communities and members in the dashboard.
Built with Astro (SSR, Node adapter), Effect v4, Drizzle on libSQL/SQLite, better-auth (Discord sign-in) and Tailwind.
For a public instance available to anyone check out https://global-ban.matthiesen.dev
Requires Node 22.12+ and pnpm.
pnpm install
cp .env.example .env # then fill in the values below
pnpm db:migrate
astro dev| Variable | Purpose |
|---|---|
DATABASE_URL |
libSQL URL, e.g. file:local.db or a Turso URL |
DATABASE_AUTH_TOKEN |
Auth token for remote libSQL (leave empty for a local file) |
BETTER_AUTH_SECRET |
Long random secret used to sign sessions |
BETTER_AUTH_URL |
Public base URL of this app |
DISCORD_CLIENT_ID, DISCORD_CLIENT_SECRET |
Discord OAuth app credentials. Set the redirect URI to <BETTER_AUTH_URL>/api/auth/callback/discord |
TRUSTED_PROXY |
none (default), traefik or cloudflare. Selects which header carries the client IP for rate limiting |
TRUSTED_PROXY_HOPS |
Number of trusted proxies that append to X-Forwarded-For (default 1, used by traefik) |
| Command | Description |
|---|---|
pnpm dev |
Start the dev server |
pnpm build / pnpm preview |
Production build (Node standalone) and preview |
pnpm check |
Type-check with astro check |
pnpm test |
Run the vitest suite (uses in-memory libSQL) |
pnpm db:generate |
Generate a migration after changing src/db/schema.ts |
pnpm db:migrate |
Apply migrations |
- Sign in to the dashboard with Discord.
- Open Servers and register the server using the UUID from the mod's server config. Treat this UUID as a secret: it is the only credential the mod sends.
- Assign the server to a community. A server that is not in a community receives
403from the sync endpoint. - In the mod's config, set
scheduler_apiSyncUrlto<your-host>/api/v1/sync.
POST /api/v1/sync
Headers: Content-Type: application/json, X-Global-Ban-UUID: <server uuid>
The body and the response use the same shape, matching the mod's SyncData record (see src/domain/punishment.ts):
{
"punishments": [
{
"type": "ADD",
"record": {
"type": "BAN",
"timestamp": 1700000000,
"duration": -1,
"playerUuid": "…",
"playerIp": "203.0.113.7",
"playerDisplayName": "Player",
"punisherUuid": "…",
"punisherDisplayName": "Moderator",
"reason": "Griefing",
"serverUuid": "…"
}
}
]
}- Sync
typeisADDorREMOVE. PunishmenttypeisBAN,IP_BANorKICK.durationof-1means permanent. - The request carries the server's pending punishments. The response carries only what that server has not received yet: punishments from its community and from approved subscriptions, plus
REMOVEfor ones it was given that have since been revoked. - Delivery is tracked per server, so repeating a request returns nothing new. Re-sending the same punishment is harmless.
serverUuidin responses is the origin server's public id, never its secret UUID. Punishments whose origin server was deleted use the all-zero UUID.
| Status | Meaning |
|---|---|
200 |
Success (the mod clears its pending queue on this) |
400 |
Missing or invalid header, malformed JSON or body, or body over 1 MB |
403 |
Server not registered, or not assigned to a community |
429 |
Rate limited; the Retry-After header gives the seconds to wait |
500 |
Database error |
curl -X POST http://localhost:4321/api/v1/sync \
-H 'Content-Type: application/json' \
-H 'X-Global-Ban-UUID: 11111111-1111-4111-8111-111111111111' \
-d '{"punishments":[]}'Two in-memory token buckets guard the endpoint (src/services/rateLimit.ts):
- Per client IP, checked before any parsing or database access: burst of 120, refilling 2 per second.
- Per server UUID: burst of 10, refilling 1 every 10 seconds. This also applies to unregistered UUIDs.
Both are far above the mod's minimum one-minute sync interval. State is per process, so it resets on restart and is not shared between multiple instances. IPv6 clients are limited per /64.
The public appeal pages use their own per-IP buckets: name lookups (burst 20, 1 per 5 seconds), IP lookups (burst 5, 1 per 50 seconds) and appeal submissions (burst 5, 1 per 200 seconds).
By default the limiter uses the connection's address, which behind a proxy is the proxy itself. Set TRUSTED_PROXY so the real client IP is used instead:
cloudflare: readsCF-Connecting-IP, which Cloudflare sets itself, including for Tunnel and Access traffic. This also works for Cloudflare Tunnel in front of Traefik, since the header passes through.traefik: readsX-Forwarded-Forcounted from the right, so values a client adds are ignored. SetTRUSTED_PROXY_HOPSif more than one trusted proxy appends to it.
If the expected header is missing or not a valid IP, the connection address is used. These headers can be forged by anyone who reaches the app directly, so only enable a mode when the app is reachable solely through that proxy: keep it off published host ports, and use a Tunnel or firewall rules.
- Servers: register, move between communities, transfer or delete. Last sync time is shown per server.
- Communities: create communities, request to join, accept invites, subscribe to other communities.
- Community page: members and roles, invites by Discord user ID, join requests, subscription approvals, ownership transfer and deletion.
- Punishments: punishments from your communities, with player IPs always masked. Admins can revoke.
- Appeals: appeals sent to communities you administer. See Appeals.
- Transfers: accept, decline or cancel ownership offers.
New accounts only see their own servers and communities.
| Role | Can do |
|---|---|
| Owner | Everything, including promoting admins, transferring ownership and deleting the community |
| Admin | Invite members, approve join requests, remove members, approve subscriptions, revoke punishments, decide appeals and manage ban overrides |
| Member | View members and punishments, add their own servers, leave |
- Invites are tied to an immutable Discord user ID and can only be accepted by the linked Discord account. Users can copy their ID from Discord with Developer Mode enabled.
- A subscription lets one community receive another's punishments. It stays pending until an admin of the source community approves it, and sync ignores pending ones.
- Removing a member detaches their servers from the community.
- Ownership transfers need the recipient to accept. A transferred server leaves its community if the new owner is not a member of it.
- Deleting a server or community requires typing its name. Deleting a community removes its punishment records. Deleting a server keeps the punishments it originated.
Players can appeal bans without an account. Only BAN and IP_BAN punishments are appealable; KICK never reaches this API.
- At
/appealthe player looks up their name or IP address. Only active (not revoked, not expired) bans are listed, and only the community, type, reason and date are shown. The IP, punisher and server are never exposed. - The player picks the bans and communities to appeal to and submits a message with an optional contact. Each community gets its own appeal. Eligible communities are the one that issued the ban plus every community with an approved subscription to it.
- The player receives a private link,
/appeal/case/<token>, to read replies, answer or withdraw. The token is shown once and only its SHA-256 hash is stored, so keep the link. - Admins of the receiving community review it under Appeals in the dashboard and can reply, approve or deny.
What approval does depends on who decides:
- Issuing community: the punishment is revoked everywhere, and servers receive a
REMOVEon their next sync. - Subscribing community: a ban override is created. The ban is lifted for that community's servers only and stays active elsewhere. Admins list and remove overrides on the community page; removing one re-sends the ban to the community's servers.
The deciding admin is recorded as decidedByUserId on the appeal and revokedByUserId on a revoked punishment. Dashboard revokes record it too; revokes that arrive through sync do not.
Each punishment and community pair can be appealed once. A withdrawn appeal can be filed again; a decided one cannot.
Because there is no login, anyone who knows a player's name can look up and appeal that player's bans. Lookups and submissions are rate limited per client IP, with the strictest limit on IP lookups.
src/domain/ Effect schemas mirroring the mod's Java records, IP masking
src/db/ Drizzle schema and client
src/services/ Effect services: sync, dashboard, membership, ownership, appeals
src/pages/api/ /api/v1/sync and the better-auth handler
src/pages/appeal/ Public appeal lookup, submission and case pages
src/pages/dashboard/ Server-rendered dashboard pages
drizzle/ Generated SQL migrations
This project is MIT Licensed