summary refs log tree commit diff
diff options
context:
space:
mode:
authorPuyodead1 <puyodead@proton.me>2023-03-23 11:57:42 -0400
committerPuyodead1 <puyodead@proton.me>2023-04-13 15:05:35 -0400
commit6347a77a7957d9bb4e4a5b4500829f641b54f9c3 (patch)
treed3b3ade7ce3d0740176958ba385efdbfc13acd7a
parentchannels (diff)
downloadserver-6347a77a7957d9bb4e4a5b4500829f641b54f9c3.tar.xz
gateway
-rw-r--r--src/api/routes/gateway/bot.ts55
-rw-r--r--src/api/routes/gateway/index.ts34
2 files changed, 54 insertions, 35 deletions
diff --git a/src/api/routes/gateway/bot.ts b/src/api/routes/gateway/bot.ts

index 243159ec..7e6bd04a 100644 --- a/src/api/routes/gateway/bot.ts +++ b/src/api/routes/gateway/bot.ts
@@ -16,32 +16,45 @@ along with this program. If not, see <https://www.gnu.org/licenses/>. */ +import { route } from "@spacebar/api"; import { Config } from "@spacebar/util"; -import { Router, Response, Request } from "express"; -import { route, RouteOptions } from "@spacebar/api"; +import { Request, Response, Router } from "express"; const router = Router(); -const options: RouteOptions = { - test: { - response: { - body: "GatewayBotResponse", - }, - }, -}; +export interface GatewayBotResponse { + url: string; + shards: number; + session_start_limit: { + total: number; + remaining: number; + reset_after: number; + max_concurrency: number; + }; +} -router.get("/", route(options), (req: Request, res: Response) => { - const { endpointPublic } = Config.get().gateway; - res.json({ - url: endpointPublic || process.env.GATEWAY || "ws://localhost:3001", - shards: 1, - session_start_limit: { - total: 1000, - remaining: 999, - reset_after: 14400000, - max_concurrency: 1, +router.get( + "/", + route({ + responses: { + 200: { + body: "GatewayBotResponse", + }, }, - }); -}); + }), + (req: Request, res: Response) => { + const { endpointPublic } = Config.get().gateway; + res.json({ + url: endpointPublic || process.env.GATEWAY || "ws://localhost:3001", + shards: 1, + session_start_limit: { + total: 1000, + remaining: 999, + reset_after: 14400000, + max_concurrency: 1, + }, + }); + }, +); export default router; diff --git a/src/api/routes/gateway/index.ts b/src/api/routes/gateway/index.ts
index 12e96919..877b6efa 100644 --- a/src/api/routes/gateway/index.ts +++ b/src/api/routes/gateway/index.ts
@@ -16,25 +16,31 @@ along with this program. If not, see <https://www.gnu.org/licenses/>. */ +import { route } from "@spacebar/api"; import { Config } from "@spacebar/util"; -import { Router, Response, Request } from "express"; -import { route, RouteOptions } from "@spacebar/api"; +import { Request, Response, Router } from "express"; const router = Router(); -const options: RouteOptions = { - test: { - response: { - body: "GatewayResponse", +export interface GatewayResponse { + url: string; +} + +router.get( + "/", + route({ + responses: { + 200: { + body: "GatewayResponse", + }, }, + }), + (req: Request, res: Response) => { + const { endpointPublic } = Config.get().gateway; + res.json({ + url: endpointPublic || process.env.GATEWAY || "ws://localhost:3001", + }); }, -}; - -router.get("/", route(options), (req: Request, res: Response) => { - const { endpointPublic } = Config.get().gateway; - res.json({ - url: endpointPublic || process.env.GATEWAY || "ws://localhost:3001", - }); -}); +); export default router;