diff --git a/assets/openapi.json b/assets/openapi.json index a6f5d96..2788cdb 100644 --- a/assets/openapi.json +++ b/assets/openapi.json @@ -7848,6 +7848,9 @@ "$ref": "#/components/schemas/StickerPack" } }, + "APIConnectionsConfiguration": { + "type": "object" + }, "UpdatesResponse": { "type": "object", "properties": { @@ -10323,25 +10326,6 @@ ] } }, - "/policies/instance/connections/": { - "get": { - "responses": { - "200": { - "description": "", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/APIConnectionsConfiguration" - } - } - } - } - }, - "tags": [ - "policies" - ] - } - }, "/ping/": { "get": { "responses": { @@ -14559,6 +14543,30 @@ ] } }, + "/connections/": { + "get": { + "security": [ + { + "bearer": [] + } + ], + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/APIConnectionsConfiguration" + } + } + } + } + }, + "tags": [ + "connections" + ] + } + }, "/connections/{connection_name}/callback/": { "post": { "security": [ diff --git a/src/api/routes/connections/index.ts b/src/api/routes/connections/index.ts new file mode 100644 index 0000000..37c20a3 --- /dev/null +++ b/src/api/routes/connections/index.ts @@ -0,0 +1,45 @@ +/* + Spacebar: A FOSS re-implementation and extension of the Discord.com backend. + Copyright (C) 2023 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 . +*/ + +import { route } from "@spacebar/api"; +import { ConnectionConfig } from "@spacebar/util"; +import { Request, Response, Router } from "express"; +const router = Router(); + +router.get( + "/", + route({ + responses: { + 200: { + body: "APIConnectionsConfiguration", + }, + }, + }), + async (req: Request, res: Response) => { + const config = ConnectionConfig.get(); + + Object.keys(config).forEach((key) => { + delete config[key].clientId; + delete config[key].clientSecret; + }); + + res.json(config); + }, +); + +export default router; diff --git a/src/api/routes/policies/instance/connections.ts b/src/api/routes/policies/instance/connections.ts deleted file mode 100644 index 37c20a3..0000000 --- a/src/api/routes/policies/instance/connections.ts +++ /dev/null @@ -1,45 +0,0 @@ -/* - Spacebar: A FOSS re-implementation and extension of the Discord.com backend. - Copyright (C) 2023 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 . -*/ - -import { route } from "@spacebar/api"; -import { ConnectionConfig } from "@spacebar/util"; -import { Request, Response, Router } from "express"; -const router = Router(); - -router.get( - "/", - route({ - responses: { - 200: { - body: "APIConnectionsConfiguration", - }, - }, - }), - async (req: Request, res: Response) => { - const config = ConnectionConfig.get(); - - Object.keys(config).forEach((key) => { - delete config[key].clientId; - delete config[key].clientSecret; - }); - - res.json(config); - }, -); - -export default router;