1
0
mirror of https://github.com/spacebarchat/server.git synced 2024-11-11 05:02:37 +01:00

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 5ccff54e4d
commit 125f91632f
2 changed files with 44 additions and 6 deletions

View File

@ -1,15 +1,29 @@
import { Config } from "@fosscord/util"; import { Config } from "@fosscord/util";
import { Router, Response, Request } from "express"; import { Router, Response, Request } from "express";
import { route } from "@fosscord/api"; import { route, RouteOptions } from "@fosscord/api";
const router = Router(); const router = Router();
router.get("/", route({}), (req: Request, res: Response) => { export interface GatewayBotResponse {
const { endpointPublic } = Config.get().gateway; url: string;
res.json({ url: endpointPublic || process.env.GATEWAY || "ws://localhost:3002" }); shards: number;
}); session_start_limit: {
total: number;
remaining: number;
reset_after: number;
max_concurrency: number;
}
}
router.get("/bot", route({}), (req: Request, res: Response) => { const options: RouteOptions = {
test: {
response: {
body: "GatewayBotResponse"
}
}
};
router.get("/bot", route(options), (req: Request, res: Response) => {
const { endpointPublic } = Config.get().gateway; const { endpointPublic } = Config.get().gateway;
res.json({ res.json({
url: endpointPublic || process.env.GATEWAY || "ws://localhost:3002", url: endpointPublic || process.env.GATEWAY || "ws://localhost:3002",

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;