summary refs log tree commit diff
diff options
context:
space:
mode:
authorRory& <root@rory.gay>2025-10-26 19:03:33 +0100
committerRory& <root@rory.gay>2025-11-22 13:02:19 +0100
commit49bc2be9bb5655afe5ce950a9edb0eba8049864e (patch)
tree12a8738f4cc6564f4676cce83595a23c848353af
parentfix: docker tags cannot include `+` (why? idk) (diff)
downloadserver-ts-49bc2be9bb5655afe5ce950a9edb0eba8049864e.tar.xz
Add well-known routes
-rw-r--r--src/api/Server.ts36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/api/Server.ts b/src/api/Server.ts

index f7307b3a..133e9dbb 100644 --- a/src/api/Server.ts +++ b/src/api/Server.ts
@@ -126,6 +126,42 @@ export class SpacebarServer extends Server { res.sendFile(path.join(ASSETS_FOLDER, "openapi.json")); }); + // current well-known location + app.get("/.well-known/spacebar", (req,res)=>{ + res.json({ + api: Config.get().api.endpointPublic + }); + }); + + // new well-known location + app.get("/.well-known/spacebar/client", (req,res)=>{ + let erlpackSupported = false; + try { + require("@yukikaze-bot/erlpack"); + erlpackSupported = true; + } catch (e) { + // empty + } + + res.json({ + api: { + baseUrl: Config.get().api.endpointPublic?.split("/api")[0] || "", // TODO: migrate database values to not include /api/v9 + apiVersions: { + default: Config.get().api.defaultVersion, + active: Config.get().api.activeVersions + } + }, + cdn: { + baseUrl: Config.get().cdn.endpointPublic + }, + gateway: { + baseUrl: Config.get().gateway.endpointPublic, + encoding: [...(erlpackSupported ? ["etf"] : []), "json"], + compression: ["zstd-stream", "zlib-stream", null], + } + }); + }); + this.app.use(ErrorHandler); ConnectionLoader.loadConnections();