Merge pull request #462 from hbjydev/unit-tests-expanded
Add unit tests for Gateway endpoints
This commit is contained in:
commit
781812a8c6
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"
|
"typescript-json-schema": "0.50.1"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@babel/preset-env": "^7.15.8",
|
||||||
|
"@babel/preset-typescript": "^7.15.0",
|
||||||
"@fosscord/util": "file:../util",
|
"@fosscord/util": "file:../util",
|
||||||
"ajv": "8.6.2",
|
"ajv": "8.6.2",
|
||||||
"ajv-formats": "^2.1.1",
|
"ajv-formats": "^2.1.1",
|
||||||
|
@ -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;
|
7521
util/package-lock.json
generated
7521
util/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user