From 125f91632f0607903596fff3aeaf67d3df593ec7 Mon Sep 17 00:00:00 2001 From: Hayden Young Date: Fri, 15 Oct 2021 11:05:51 +0000 Subject: feat: add tests to gateway routes, split into own routers --- api/src/routes/gateway.ts | 26 -------------------------- api/src/routes/gateway/bot.ts | 40 ++++++++++++++++++++++++++++++++++++++++ api/src/routes/gateway/index.ts | 24 ++++++++++++++++++++++++ 3 files changed, 64 insertions(+), 26 deletions(-) delete mode 100644 api/src/routes/gateway.ts create mode 100644 api/src/routes/gateway/bot.ts create mode 100644 api/src/routes/gateway/index.ts (limited to 'api') diff --git a/api/src/routes/gateway.ts b/api/src/routes/gateway.ts deleted file mode 100644 index 4b3a0ea6..00000000 --- a/api/src/routes/gateway.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { Config } from "@fosscord/util"; -import { Router, Response, Request } from "express"; -import { route } from "@fosscord/api"; - -const router = Router(); - -router.get("/", route({}), (req: Request, res: Response) => { - const { endpointPublic } = Config.get().gateway; - res.json({ url: endpointPublic || process.env.GATEWAY || "ws://localhost:3002" }); -}); - -router.get("/bot", route({}), (req: Request, res: Response) => { - const { endpointPublic } = Config.get().gateway; - res.json({ - url: endpointPublic || process.env.GATEWAY || "ws://localhost:3002", - shards: 1, - session_start_limit: { - total: 1000, - remaining: 999, - reset_after: 14400000, - max_concurrency: 1 - } - }); -}); - -export default router; diff --git a/api/src/routes/gateway/bot.ts b/api/src/routes/gateway/bot.ts new file mode 100644 index 00000000..3a038276 --- /dev/null +++ b/api/src/routes/gateway/bot.ts @@ -0,0 +1,40 @@ +import { Config } from "@fosscord/util"; +import { Router, Response, Request } from "express"; +import { route, RouteOptions } from "@fosscord/api"; + +const router = Router(); + +export interface GatewayBotResponse { + url: string; + shards: number; + session_start_limit: { + total: number; + remaining: number; + reset_after: number; + max_concurrency: number; + } +} + +const options: RouteOptions = { + test: { + response: { + body: "GatewayBotResponse" + } + } +}; + +router.get("/bot", route(options), (req: Request, res: Response) => { + const { endpointPublic } = Config.get().gateway; + res.json({ + url: endpointPublic || process.env.GATEWAY || "ws://localhost:3002", + shards: 1, + session_start_limit: { + total: 1000, + remaining: 999, + reset_after: 14400000, + max_concurrency: 1 + } + }); +}); + +export default router; diff --git a/api/src/routes/gateway/index.ts b/api/src/routes/gateway/index.ts new file mode 100644 index 00000000..9bad7478 --- /dev/null +++ b/api/src/routes/gateway/index.ts @@ -0,0 +1,24 @@ +import { Config } from "@fosscord/util"; +import { Router, Response, Request } from "express"; +import { route, RouteOptions } from "@fosscord/api"; + +const router = Router(); + +export interface GatewayResponse { + url: string; +} + +const options: RouteOptions = { + test: { + response: { + body: "GatewayResponse" + } + } +}; + +router.get("/", route(options), (req: Request, res: Response) => { + const { endpointPublic } = Config.get().gateway; + res.json({ url: endpointPublic || process.env.GATEWAY || "ws://localhost:3002" }); +}); + +export default router; -- cgit 1.4.1