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:
parent
5ccff54e4d
commit
125f91632f
@ -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",
|
24
api/src/routes/gateway/index.ts
Normal file
24
api/src/routes/gateway/index.ts
Normal 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;
|
Loading…
Reference in New Issue
Block a user