mirror of
https://github.com/spacebarchat/server.git
synced 2024-11-23 10:52:30 +01:00
Merge pull request #462 from hbjydev/unit-tests-expanded
Add unit tests for Gateway endpoints
This commit is contained in:
commit
a5811c1c09
15655
api/package-lock.json
generated
15655
api/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -63,6 +63,8 @@
|
||||
"typescript-json-schema": "0.50.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"@babel/preset-env": "^7.15.8",
|
||||
"@babel/preset-typescript": "^7.15.0",
|
||||
"@fosscord/util": "file:../util",
|
||||
"ajv": "8.6.2",
|
||||
"ajv-formats": "^2.1.1",
|
||||
|
@ -1,15 +1,29 @@
|
||||
import { Config } from "@fosscord/util";
|
||||
import { Router, Response, Request } from "express";
|
||||
import { route } from "@fosscord/api";
|
||||
import { route, RouteOptions } 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" });
|
||||
});
|
||||
export interface GatewayBotResponse {
|
||||
url: string;
|
||||
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;
|
||||
res.json({
|
||||
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;
|
7521
util/package-lock.json
generated
7521
util/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user