diff --git a/src/api/middlewares/ErrorHandler.ts b/src/api/middlewares/ErrorHandler.ts
index a3333be5..3ce1137e 100644
--- a/src/api/middlewares/ErrorHandler.ts
+++ b/src/api/middlewares/ErrorHandler.ts
@@ -9,14 +9,13 @@ export function ErrorHandler(error: Error, req: Request, res: Response, next: Ne
let code = 400;
let httpcode = code;
let message = error?.toString();
- let errors = undefined;
- let data = undefined;
+ let errors = null;
+ let data = null;
if (error instanceof HTTPError && error.code) {
code = httpcode = error.code;
- if(error.data) data = error.data;
- }
- else if (error instanceof ApiError) {
+ if (error.data) data = error.data;
+ } else if (error instanceof ApiError) {
code = error.code;
message = error.message;
httpcode = error.httpStatus;
diff --git a/src/api/middlewares/RateLimit.ts b/src/api/middlewares/RateLimit.ts
index dc93dcef..6d4b08b0 100644
--- a/src/api/middlewares/RateLimit.ts
+++ b/src/api/middlewares/RateLimit.ts
@@ -1,6 +1,6 @@
-import { getIpAdress } from "@fosscord/api";
import { Config, getRights, listenEvent } from "@fosscord/util";
import { NextFunction, Request, Response, Router } from "express";
+import { getIpAdress } from "..";
import { API_PREFIX_TRAILING_SLASH } from "./Authentication";
// Docs: https://discord.com/developers/docs/topics/rate-limits
diff --git a/src/api/middlewares/TestClient.ts b/src/api/middlewares/TestClient.ts
index 9090840e..e4daaf25 100644
--- a/src/api/middlewares/TestClient.ts
+++ b/src/api/middlewares/TestClient.ts
@@ -10,6 +10,7 @@ import { patchFile } from "..";
const prettier = require("prettier");
const AssetsPath = path.join(__dirname, "..", "..", "..", "assets");
+const cfg = Config.get();
export default function TestClient(app: Application) {
const agent = new ProxyAgent();
@@ -81,22 +82,22 @@ export default function TestClient(app: Application) {
return res.send(fs.readFileSync(assetCacheItem.FilePath));
});
app.get("/developers*", (_req: Request, res: Response) => {
- const { useTestClient } = Config.get().client;
res.set("Cache-Control", "public, max-age=" + 60 * 60 * 24);
res.set("content-type", "text/html");
- if (!useTestClient) return res.send("Test client is disabled on this instance. Use a stand-alone client to connect this instance.");
+ if (!cfg.client.useTestClient)
+ return res.send("Test client is disabled on this instance. Use a stand-alone client to connect this instance.");
res.send(fs.readFileSync(path.join(__dirname, "..", "..", "..", "assets", "developers.html"), { encoding: "utf8" }));
});
app.get("*", (req: Request, res: Response) => {
- const { useTestClient } = Config.get().client;
res.set("Cache-Control", "public, max-age=" + 60 * 60 * 24);
res.set("content-type", "text/html");
if (req.url.startsWith("/api") || req.url.startsWith("/__development")) return;
- if (!useTestClient) return res.send("Test client is disabled on this instance. Use a stand-alone client to connect this instance.");
+ if (!cfg.client.useTestClient)
+ return res.send("Test client is disabled on this instance. Use a stand-alone client to connect this instance.");
if (req.url.startsWith("/invite")) return res.send(html.replace("9b2b7f0632acd0c5e781", "9f24f709a3de09b67c49"));
res.send(html);
|