feat: add tests to gateway routes, split into own routers

This commit is contained in:
Hayden Young
2021-10-15 11:05:51 +00:00
committed by GitHub
parent 46a8d0f883
commit 4100932a8b
2 changed files with 44 additions and 6 deletions
+40
View File
@@ -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;
+24
View File
@@ -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;