From fe17f5d155663b613bd107db26104af301772e7a Mon Sep 17 00:00:00 2001 From: Rory& Date: Fri, 31 Jul 2026 05:28:52 +0200 Subject: [PATCH] schemas for wellknowns --- assets/openapi.json | Bin 1023831 -> 1035668 bytes assets/schemas.json | Bin 460357 -> 463711 bytes .../%2Ewell-known/spacebar/client.ts | 16 ++++--- .../%2Ewell-known/spacebar/index.ts | 8 +++- src/schemas/api/spacebar/WellKnown.ts | 42 ++++++++++++++++++ 5 files changed, 60 insertions(+), 6 deletions(-) create mode 100644 src/schemas/api/spacebar/WellKnown.ts diff --git a/assets/openapi.json b/assets/openapi.json index 23da8478a67011f24ab096d73f01bb6756a0c712..c7d9c6f0bedf9ff829f6a07c94882e6ef29e6ea3 100644 GIT binary patch delta 1533 zcma)6OKcle6xH**8PE7rC&VUAosXT0Gzp16{GISt1wWKUiSB2+KlG?Io%@ zWgF?l;2PhELWt|ZU?1(nrerZ=^Jl3O+K|);pPTQ~a~CCqk8#~-XeAVPP8fRimD5(_ z_OcW!m*D%IJA;NOX@l#WxucTXO9l{noT~uYS_zM<1GER>4JzWZ^MV688)wl&7u%7G zo1G~9#LpYc%u;yg73#!wvt*(r{#Rwe&S;1zv~V7bWa_Eg2CC?;s?&478S!<7bk%o; zD)C4{pZ>vJwk0%8zeC3;$8$*~g}YB19s^5_L3@+yVixdl&67t|E1#Kyt;u_^BWmqY!|3%x2m3*<|gf6Gs;B#_b_-9D(?)?5sTXX4N;QUFl z4>wN|XG!XqXm!KYLJwflBRF)89>FL3X(z&(&5OUAsd>q2r!06D0t;i_Y8S8jksB8K zq_I@xCYF}@+lNI16%;v^o|-FX?hK2+5-Ly3me+{zrY7tQi2Gp-h&QO5RwMZf0dbv} zm83d3+poMXtFclkvOzJ8ABRP^kWnY1N_y#5P-G#oFy(Ir&F^|}bX@Glg&U^#^Vydz zZ*fSRH497k7tAayEUYZ{_@gMr53hSx~Rz;OGFbM zEgnTpW%xKxG5slZ>~zAHXKi!H%F_2(IcT7U**W%XA7Fw%SEZvn&8vSJrz&pO^!Xz| z1X2U^(DrG0*#q)2fho9prH8A`XcxD3!Jp&pJ2c%}`DD4;?^WYzC7NV%6Y-Qcs!rBu ztq0_&21-Sy*rBH|ecSZm)``?5QB#}HlsJ>}|7z`?3>%mIuNCK|cl+LM`PPN(IolCz zUNhgTH(t?rQ~I{re&=qO-Uu78@$`-z-?W-qh<&#?jOAYpk0AT1I124aX{ZW(6~{id GiT?oVmoL%) delta 139 zcmbO-+y44KyM`9V7N!>FEiAUe(wv2cgJ${F-{MR=O}Lf7S931oIuRA{aZYDyWaE(ZM?s?e=ykdl53LSNI1JP1il{6L5{ zVpK4S!HfN)E&;1+6I#g74(XuKE$)H^r$WUzba3-ERfI~0bC!Gl_xyh6Q96stBbp=!SBqle@ZQ-ANk^uz zwn9Nw{d@`wQ8H0o!o#*cu| taq&DI?}YrnDVkSE;#!QnD7mdI{V7J{Xg#I_PprJ=7I#b3t-LOt{stRJ)e!&y delta 43 wcmcb=Oy+2hOhXG}3)2>6lbY!t+8BAJ`%PeGYftE824WT { res.json({ api: { - baseUrl: Config.get().api.endpointPublic?.split("/api/")[0], + baseUrl: Config.get().api.endpointPublic!.split("/api/")[0], apiVersions: { default: Config.get().api.defaultVersion, active: Config.get().api.activeVersions, }, }, cdn: { - baseUrl: Config.get().cdn.endpointPublic, + baseUrl: Config.get().cdn.endpointPublic!, }, gateway: { - baseUrl: Config.get().gateway.endpointPublic, + baseUrl: Config.get().gateway.endpointPublic!, encoding: ["etf", "json"], compression: ["zstd-stream", "zlib-stream", null], }, @@ -49,9 +55,9 @@ router.get( Config.get().admin.endpointPublic === null ? undefined : { - baseUrl: Config.get().admin.endpointPublic, + baseUrl: Config.get().admin.endpointPublic!, }, - }); + } satisfies SpacebarWellKnownClientResponse); }, ); diff --git a/src/api/routes_toplevel/%2Ewell-known/spacebar/index.ts b/src/api/routes_toplevel/%2Ewell-known/spacebar/index.ts index 1a5961362..472571e5d 100644 --- a/src/api/routes_toplevel/%2Ewell-known/spacebar/index.ts +++ b/src/api/routes_toplevel/%2Ewell-known/spacebar/index.ts @@ -19,6 +19,7 @@ import { Router, Response, Request } from "express"; import { route } from "@spacebar/api/middlewares"; import { Config } from "@spacebar/util"; +import { SpacebarWellKnownLegacyResponse } from "@spacebar/schemas/api/spacebar/WellKnown"; const router = Router({ mergeParams: true }); @@ -28,11 +29,16 @@ router.get( spacebarOnly: true, authentication: "never", deprecated: true, + responses: { + 200: { + body: "SpacebarWellKnownLegacyResponse", + }, + }, }), (req: Request, res: Response) => { res.json({ api: (Config.get().api.endpointPublic + "/api/").replace("//api/", "/api/"), - }); + } satisfies SpacebarWellKnownLegacyResponse); }, ); diff --git a/src/schemas/api/spacebar/WellKnown.ts b/src/schemas/api/spacebar/WellKnown.ts new file mode 100644 index 000000000..cc21f5d8f --- /dev/null +++ b/src/schemas/api/spacebar/WellKnown.ts @@ -0,0 +1,42 @@ +/* + Spacebar: A FOSS re-implementation and extension of the Discord.com backend. + Copyright (C) 2026 Spacebar and Spacebar Contributors + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . +*/ + +export interface SpacebarWellKnownLegacyResponse { + api: string; +} + +export interface SpacebarWellKnownClientResponse { + api: { + baseUrl: string; + apiVersions: { + default: string; + active: string[]; + }; + }; + cdn: { + baseUrl: string; + }; + gateway: { + baseUrl: string; + encoding: string[]; + compression: (string | null)[]; + }; + admin?: { + baseUrl: string; + }; +}