diff --git a/assets/openapi.json b/assets/openapi.json index 6f5112a..298ad18 100644 --- a/assets/openapi.json +++ b/assets/openapi.json @@ -13639,12 +13639,6 @@ ], "tags": [ "users" - ], - "x-badges": [ - { - "label": "Spacebar-only", - "color": "red" - } ] }, "patch": { @@ -13677,12 +13671,6 @@ }, "tags": [ "users" - ], - "x-badges": [ - { - "label": "Spacebar-only", - "color": "red" - } ] } }, @@ -13795,12 +13783,6 @@ ], "tags": [ "users" - ], - "x-badges": [ - { - "label": "Spacebar-only", - "color": "red" - } ] }, "patch": { @@ -13833,12 +13815,6 @@ }, "tags": [ "users" - ], - "x-badges": [ - { - "label": "Spacebar-only", - "color": "red" - } ] } }, @@ -15797,12 +15773,6 @@ }, "tags": [ "track" - ], - "x-badges": [ - { - "label": "Spacebar-only", - "color": "red" - } ] } }, @@ -16109,12 +16079,6 @@ }, "tags": [ "scheduled-maintenances" - ], - "x-badges": [ - { - "label": "Spacebar-only", - "color": "red" - } ] } }, @@ -16247,12 +16211,6 @@ ], "tags": [ "reporting" - ], - "x-badges": [ - { - "label": "Spacebar-only", - "color": "red" - } ] } }, @@ -16291,12 +16249,6 @@ }, "tags": [ "reporting" - ], - "x-badges": [ - { - "label": "Spacebar-only", - "color": "red" - } ] } }, @@ -16336,12 +16288,6 @@ ], "tags": [ "reporting" - ], - "x-badges": [ - { - "label": "Spacebar-only", - "color": "red" - } ] } }, @@ -16380,12 +16326,6 @@ }, "tags": [ "reporting" - ], - "x-badges": [ - { - "label": "Spacebar-only", - "color": "red" - } ] } }, @@ -16425,12 +16365,6 @@ ], "tags": [ "reporting" - ], - "x-badges": [ - { - "label": "Spacebar-only", - "color": "red" - } ] } }, @@ -16469,12 +16403,6 @@ }, "tags": [ "reporting" - ], - "x-badges": [ - { - "label": "Spacebar-only", - "color": "red" - } ] } }, @@ -16514,12 +16442,6 @@ ], "tags": [ "reporting" - ], - "x-badges": [ - { - "label": "Spacebar-only", - "color": "red" - } ] } }, @@ -16558,12 +16480,6 @@ }, "tags": [ "reporting" - ], - "x-badges": [ - { - "label": "Spacebar-only", - "color": "red" - } ] } }, @@ -16603,12 +16519,6 @@ ], "tags": [ "reporting" - ], - "x-badges": [ - { - "label": "Spacebar-only", - "color": "red" - } ] } }, @@ -16647,12 +16557,6 @@ }, "tags": [ "reporting" - ], - "x-badges": [ - { - "label": "Spacebar-only", - "color": "red" - } ] } }, @@ -16692,12 +16596,6 @@ ], "tags": [ "reporting" - ], - "x-badges": [ - { - "label": "Spacebar-only", - "color": "red" - } ] } }, @@ -16736,12 +16634,6 @@ }, "tags": [ "reporting" - ], - "x-badges": [ - { - "label": "Spacebar-only", - "color": "red" - } ] } }, @@ -16781,12 +16673,6 @@ ], "tags": [ "reporting" - ], - "x-badges": [ - { - "label": "Spacebar-only", - "color": "red" - } ] } }, @@ -16825,12 +16711,6 @@ }, "tags": [ "reporting" - ], - "x-badges": [ - { - "label": "Spacebar-only", - "color": "red" - } ] } }, @@ -16870,12 +16750,6 @@ ], "tags": [ "reporting" - ], - "x-badges": [ - { - "label": "Spacebar-only", - "color": "red" - } ] } }, @@ -16914,12 +16788,6 @@ }, "tags": [ "reporting" - ], - "x-badges": [ - { - "label": "Spacebar-only", - "color": "red" - } ] } }, @@ -16959,12 +16827,6 @@ ], "tags": [ "reporting" - ], - "x-badges": [ - { - "label": "Spacebar-only", - "color": "red" - } ] } }, @@ -17003,12 +16865,6 @@ }, "tags": [ "reporting" - ], - "x-badges": [ - { - "label": "Spacebar-only", - "color": "red" - } ] } }, @@ -17048,12 +16904,6 @@ ], "tags": [ "reporting" - ], - "x-badges": [ - { - "label": "Spacebar-only", - "color": "red" - } ] } }, @@ -17092,12 +16942,6 @@ }, "tags": [ "reporting" - ], - "x-badges": [ - { - "label": "Spacebar-only", - "color": "red" - } ] } }, @@ -21828,12 +21672,6 @@ }, "tags": [ "guild-recommendations" - ], - "x-badges": [ - { - "label": "Spacebar-only", - "color": "red" - } ] } }, @@ -24485,12 +24323,6 @@ }, "tags": [ "beaker" - ], - "x-badges": [ - { - "label": "Spacebar-only", - "color": "red" - } ] } }, @@ -24800,12 +24632,6 @@ }, "tags": [ "auth" - ], - "x-badges": [ - { - "label": "Spacebar-only", - "color": "red" - } ] } }, @@ -24845,12 +24671,6 @@ }, "tags": [ "auth" - ], - "x-badges": [ - { - "label": "Spacebar-only", - "color": "red" - } ] } }, @@ -25026,12 +24846,6 @@ }, "tags": [ "auth" - ], - "x-badges": [ - { - "label": "Spacebar-only", - "color": "red" - } ] } }, @@ -25156,12 +24970,6 @@ }, "tags": [ "applications" - ], - "x-badges": [ - { - "label": "Spacebar-only", - "color": "red" - } ] } }, diff --git a/default.nix b/default.nix index af33301..691162a 100644 --- a/default.nix +++ b/default.nix @@ -18,6 +18,7 @@ ./tsconfig.json ./assets ./patches + ./scripts ] ) ); @@ -41,7 +42,7 @@ npmDeps = pkgs.importNpmLock { npmRoot = filteredSrc; }; npmConfigHook = pkgs.importNpmLock.npmConfigHook; - npmBuildScript = "build:src:tsgo"; + npmBuildScript = "build:tsgo"; makeCacheWritable = true; nativeBuildInputs = with pkgs; [ (pkgs.python3.withPackages (ps: with ps; [ setuptools ])) @@ -64,6 +65,7 @@ # remove packages not needed for production, or at least try to... npm prune --omit dev --no-save $npmInstallFlags "''${npmInstallFlagsArray[@]}" $npmFlags "''${npmFlagsArray[@]}" rm -v dist/src.tsbuildinfo + rm -rv scripts time ${./nix/trimNodeModules.sh} # Copy outputs diff --git a/scripts/openapi.js b/scripts/openapi.js index 5afee15..86d502e 100644 --- a/scripts/openapi.js +++ b/scripts/openapi.js @@ -213,7 +213,7 @@ obj.tags = [...new Set([...(obj.tags || []), getTag(p)])]; - if (missingRoutes.additional.includes(path.replace(/\/$/, ""))) { + if (route.spacebarOnly === true || missingRoutes?.additional.includes(path.replace(/\/$/, ""))) { obj["x-badges"] = [ { label: "Spacebar-only", @@ -231,12 +231,13 @@ async function main() { console.log("Generating OpenAPI Specification..."); - const routesRes = await fetch("https://github.com/spacebarchat/missing-routes/raw/main/missing.json", { - headers: { - Accept: "application/json", - }, - }); - const missingRoutes = await routesRes.json(); + // const routesRes = await fetch("https://github.com/spacebarchat/missing-routes/raw/main/missing.json", { + // headers: { + // Accept: "application/json", + // }, + // }); + // const missingRoutes = await routesRes.json(); + let missingRoutes = undefined; combineSchemas(schemas); apiRoutes(missingRoutes); diff --git a/src/api/routes/-/healthz.ts b/src/api/routes/-/healthz.ts index de45a29..90f6054 100644 --- a/src/api/routes/-/healthz.ts +++ b/src/api/routes/-/healthz.ts @@ -22,7 +22,7 @@ const router = Router({ mergeParams: true }); -router.get("/", route({ deprecated: true }), (req: Request, res: Response) => { +router.get("/", route({ deprecated: true, spacebarOnly: true }), (req: Request, res: Response) => { if (!getDatabase()) return res.sendStatus(503); return res.sendStatus(200); diff --git a/src/api/routes/-/readyz.ts b/src/api/routes/-/readyz.ts index de45a29..90f6054 100644 --- a/src/api/routes/-/readyz.ts +++ b/src/api/routes/-/readyz.ts @@ -22,7 +22,7 @@ const router = Router({ mergeParams: true }); -router.get("/", route({ deprecated: true }), (req: Request, res: Response) => { +router.get("/", route({ deprecated: true, spacebarOnly: true }), (req: Request, res: Response) => { if (!getDatabase()) return res.sendStatus(503); return res.sendStatus(200); diff --git a/src/api/routes/applications/detectable.ts b/src/api/routes/applications/detectable.ts index 83122e7..688a7d1 100644 --- a/src/api/routes/applications/detectable.ts +++ b/src/api/routes/applications/detectable.ts @@ -34,6 +34,7 @@ body: "ApplicationDetectableResponse", }, }, + spacebarOnly: false, // not part of public openapi }), async (req: Request, res: Response) => { // cache for 6 hours diff --git a/src/api/routes/auth/fingerprint.ts b/src/api/routes/auth/fingerprint.ts index a4a49d0..2a77d3c 100644 --- a/src/api/routes/auth/fingerprint.ts +++ b/src/api/routes/auth/fingerprint.ts @@ -20,10 +20,17 @@ import { Snowflake } from "@spacebar/util"; import { Request, Response, Router } from "express"; const router = Router({ mergeParams: true }); -router.post("/", route({ responses: { 200: { body: "CreateFingerprintResponse" } } }), (req: Request, res: Response) => { - const snowflake = Snowflake.generate(); - return res.json({ - fingerprint: `${snowflake}.${createHash("sha512").update(snowflake).digest("base64")}`, - }); -}); +router.post( + "/", + route({ + responses: { 200: { body: "CreateFingerprintResponse" } }, + spacebarOnly: false, // not part of public openapi + }), + (req: Request, res: Response) => { + const snowflake = Snowflake.generate(); + return res.json({ + fingerprint: `${snowflake}.${createHash("sha512").update(snowflake).digest("base64")}`, + }); + }, +); export default router; diff --git a/src/api/routes/auth/generate-registration-tokens.ts b/src/api/routes/auth/generate-registration-tokens.ts index a6b70c6..1493c2d 100644 --- a/src/api/routes/auth/generate-registration-tokens.ts +++ b/src/api/routes/auth/generate-registration-tokens.ts @@ -38,6 +38,7 @@ }, right: "CREATE_REGISTRATION_TOKENS", responses: { 200: { body: "GenerateRegistrationTokensResponse" } }, + spacebarOnly: true, }), async (req: Request, res: Response) => { const count = req.query.count ? parseInt(req.query.count as string) : 1; diff --git a/src/api/routes/auth/mfa/totp.ts b/src/api/routes/auth/mfa/totp.ts index 366fb10..d50f2d0 100644 --- a/src/api/routes/auth/mfa/totp.ts +++ b/src/api/routes/auth/mfa/totp.ts @@ -36,6 +36,7 @@ body: "APIErrorResponse", }, }, + spacebarOnly: false, // not part of public openapi }), async (req: Request, res: Response) => { // const { code, ticket, gift_code_sku_id, login_source } = diff --git a/src/api/routes/auth/mfa/webauthn.ts b/src/api/routes/auth/mfa/webauthn.ts index 3359767..8e6c5f0 100644 --- a/src/api/routes/auth/mfa/webauthn.ts +++ b/src/api/routes/auth/mfa/webauthn.ts @@ -41,6 +41,7 @@ 200: { body: "TokenResponse" }, 400: { body: "APIErrorResponse" }, }, + spacebarOnly: false, // not part of public openapi }), async (req: Request, res: Response) => { if (!WebAuthn.fido2) { diff --git a/src/api/routes/auth/whoami.ts b/src/api/routes/auth/whoami.ts index 4d28b9f..5136637 100644 --- a/src/api/routes/auth/whoami.ts +++ b/src/api/routes/auth/whoami.ts @@ -30,6 +30,7 @@ body: "WhoAmIResponse", }, }, + spacebarOnly: true, }), /* interface Request { diff --git a/src/api/routes/beaker.ts b/src/api/routes/beaker.ts index 4eb2941..22c1904 100644 --- a/src/api/routes/beaker.ts +++ b/src/api/routes/beaker.ts @@ -28,6 +28,7 @@ responses: { 204: {}, }, + spacebarOnly: false, // Not part of public openapi }), (req: Request, res: Response) => { // TODO: diff --git a/src/api/routes/guild-recommendations.ts b/src/api/routes/guild-recommendations.ts index 38ba102..37ce779 100644 --- a/src/api/routes/guild-recommendations.ts +++ b/src/api/routes/guild-recommendations.ts @@ -32,6 +32,7 @@ body: "GuildRecommendationsResponse", }, }, + spacebarOnly: false, // Not part of public openapi schema }), async (req: Request, res: Response) => { // const { limit, personalization_disabled } = req.query; diff --git a/src/api/routes/ping.ts b/src/api/routes/ping.ts index be737f8..2a5ec6a 100644 --- a/src/api/routes/ping.ts +++ b/src/api/routes/ping.ts @@ -30,6 +30,7 @@ body: "InstancePingResponse", }, }, + spacebarOnly: true, }), (req: Request, res: Response) => { const { general } = Config.get(); diff --git a/src/api/routes/policies/instance/config.ts b/src/api/routes/policies/instance/config.ts index 946ac8a..686ecd1 100755 --- a/src/api/routes/policies/instance/config.ts +++ b/src/api/routes/policies/instance/config.ts @@ -30,6 +30,7 @@ body: "Object", }, }, + spacebarOnly: true, }), async (req: Request, res: Response) => { const general = Config.get(); diff --git a/src/api/routes/policies/instance/domains.ts b/src/api/routes/policies/instance/domains.ts index 339eedb..3d33037 100644 --- a/src/api/routes/policies/instance/domains.ts +++ b/src/api/routes/policies/instance/domains.ts @@ -29,6 +29,7 @@ body: "InstanceDomainsResponse", }, }, + spacebarOnly: true, }), (req: Request, res: Response) => { const { cdn, gateway, api } = Config.get(); diff --git a/src/api/routes/policies/instance/index.ts b/src/api/routes/policies/instance/index.ts index bb04475..31e80bd 100644 --- a/src/api/routes/policies/instance/index.ts +++ b/src/api/routes/policies/instance/index.ts @@ -29,6 +29,7 @@ body: "APIGeneralConfiguration", }, }, + spacebarOnly: true, }), (req: Request, res: Response) => { const { general } = Config.get(); diff --git a/src/api/routes/policies/instance/limits.ts b/src/api/routes/policies/instance/limits.ts index 375c721..380d9e1 100644 --- a/src/api/routes/policies/instance/limits.ts +++ b/src/api/routes/policies/instance/limits.ts @@ -29,6 +29,7 @@ body: "APILimitsConfiguration", }, }, + spacebarOnly: true, }), (req: Request, res: Response) => { const { limits } = Config.get(); diff --git a/src/api/routes/policies/stats.ts b/src/api/routes/policies/stats.ts index 0edcfd6..9090d78 100644 --- a/src/api/routes/policies/stats.ts +++ b/src/api/routes/policies/stats.ts @@ -32,6 +32,7 @@ body: "APIErrorResponse", }, }, + spacebarOnly: true, }), async (req: Request, res: Response) => { if (!Config.get().security.statsWorldReadable) { diff --git a/src/api/routes/reporting/index.ts b/src/api/routes/reporting/index.ts index dbbd000..c4ae611 100644 --- a/src/api/routes/reporting/index.ts +++ b/src/api/routes/reporting/index.ts @@ -57,6 +57,7 @@ }, 204: {}, }, + spacebarOnly: false, // Maps to /reporting/menu/:id }), (req: Request, res: Response) => { // TODO: implement @@ -76,6 +77,7 @@ }, 204: {}, }, + spacebarOnly: false, // Maps to /reporting/:id }), (req: Request, res: Response) => { // TODO: implement diff --git a/src/api/routes/scheduled-maintenances/upcoming.json.ts b/src/api/routes/scheduled-maintenances/upcoming.json.ts index b215074..bf8fa55 100644 --- a/src/api/routes/scheduled-maintenances/upcoming.json.ts +++ b/src/api/routes/scheduled-maintenances/upcoming.json.ts @@ -20,11 +20,17 @@ import { route } from "@spacebar/api"; const router = Router({ mergeParams: true }); -router.get("/", route({}), (req: Request, res: Response) => { - res.json({ - page: {}, - scheduled_maintenances: {}, - }); -}); +router.get( + "/", + route({ + spacebarOnly: false, // not part of public openapi + }), + (req: Request, res: Response) => { + res.json({ + page: {}, + scheduled_maintenances: {}, + }); + }, +); export default router; diff --git a/src/api/routes/track.ts b/src/api/routes/track.ts index d320613..fe33b50 100644 --- a/src/api/routes/track.ts +++ b/src/api/routes/track.ts @@ -21,9 +21,15 @@ const router = Router({ mergeParams: true }); -router.post("/", route({}), (req: Request, res: Response) => { - // TODO: - res.sendStatus(204); -}); +router.post( + "/", + route({ + spacebarOnly: false, // Not part of the public OpenAPI schema + }), + (req: Request, res: Response) => { + // TODO: + res.sendStatus(204); + }, +); export default router; diff --git a/src/api/routes/users/@me/settings-proto/1.ts b/src/api/routes/users/@me/settings-proto/1.ts index d54bdf3..6df652a 100644 --- a/src/api/routes/users/@me/settings-proto/1.ts +++ b/src/api/routes/users/@me/settings-proto/1.ts @@ -40,6 +40,7 @@ description: "Whether to try to apply the settings update atomically (default false)", }, }, + spacebarOnly: false, // maps to /users/@me/settings-proto/1 }), async (req: Request, res: Response) => { const userSettings = await UserSettingsProtos.getOrDefault(req.user_id); @@ -59,6 +60,7 @@ body: "SettingsProtoUpdateResponse", }, }, + spacebarOnly: false, // maps to /users/@me/settings-proto/1 }), async (req: Request, res: Response) => { const { settings, required_data_version } = req.body as SettingsProtoUpdateSchema; @@ -84,6 +86,7 @@ body: "SettingsProtoJsonResponse", }, }, + spacebarOnly: true, }), async (req: Request, res: Response) => { const userSettings = await UserSettingsProtos.getOrDefault(req.user_id); @@ -109,6 +112,7 @@ description: "Whether to try to apply the settings update atomically (default false)", }, }, + spacebarOnly: true, }), async (req: Request, res: Response) => { const { settings, required_data_version } = req.body as SettingsProtoUpdateJsonSchema; diff --git a/src/api/routes/users/@me/settings-proto/2.ts b/src/api/routes/users/@me/settings-proto/2.ts index 809db84..ac3280e 100644 --- a/src/api/routes/users/@me/settings-proto/2.ts +++ b/src/api/routes/users/@me/settings-proto/2.ts @@ -40,6 +40,7 @@ description: "Whether to try to apply the settings update atomically (default false)", }, }, + spacebarOnly: false, // maps to /users/@me/settings-proto/2 }), async (req: Request, res: Response) => { const userSettings = await UserSettingsProtos.getOrDefault(req.user_id); @@ -59,6 +60,7 @@ body: "SettingsProtoUpdateResponse", }, }, + spacebarOnly: false, // maps to /users/@me/settings-proto/2 }), async (req: Request, res: Response) => { const { settings, required_data_version } = req.body as SettingsProtoUpdateSchema; @@ -84,6 +86,7 @@ body: "SettingsProtoJsonResponse", }, }, + spacebarOnly: true, }), async (req: Request, res: Response) => { const userSettings = await UserSettingsProtos.getOrDefault(req.user_id); @@ -109,6 +112,7 @@ description: "Whether to try to apply the settings update atomically (default false)", }, }, + spacebarOnly: true, }), async (req: Request, res: Response) => { const { settings, required_data_version } = req.body as SettingsProtoUpdateJsonSchema; diff --git a/src/api/util/handlers/route.ts b/src/api/util/handlers/route.ts index 7ae00a5..022a522 100644 --- a/src/api/util/handlers/route.ts +++ b/src/api/util/handlers/route.ts @@ -64,6 +64,7 @@ }; }; deprecated?: boolean; + spacebarOnly?: boolean; // test?: { // response?: RouteResponse; // body?: unknown;