diff --git a/api/src/Server.ts b/src/api/Server.ts
index 4cf0917d..e92335a5 100644
--- a/api/src/Server.ts
+++ b/src/api/Server.ts
@@ -1,18 +1,16 @@
-import "missing-native-js-functions";
+import { Config, getOrInitialiseDatabase, initEvent, registerRoutes } from "@fosscord/util";
+import { NextFunction, Request, Response, Router } from "express";
import { Server, ServerOptions } from "lambert-server";
+import morgan from "morgan";
+import path from "path";
+import { red } from "picocolors";
import { Authentication, CORS } from "./middlewares/";
-import { Config, initDatabase, initEvent } from "@fosscord/util";
-import { ErrorHandler } from "./middlewares/ErrorHandler";
import { BodyParser } from "./middlewares/BodyParser";
-import { Router, Request, Response, NextFunction } from "express";
-import path from "path";
+import { ErrorHandler } from "./middlewares/ErrorHandler";
import { initRateLimits } from "./middlewares/RateLimit";
import TestClient from "./middlewares/TestClient";
import { initTranslation } from "./middlewares/Translation";
-import morgan from "morgan";
import { initInstance } from "./util/handlers/Instance";
-import { registerRoutes } from "@fosscord/util";
-import { red } from "picocolors"
export interface FosscordServerOptions extends ServerOptions {}
@@ -34,7 +32,7 @@ export class FosscordServer extends Server {
}
async start() {
- await initDatabase();
+ await getOrInitialiseDatabase();
await Config.init();
await initEvent();
await initInstance();
@@ -44,13 +42,13 @@ export class FosscordServer extends Server {
this.app.use(
morgan("combined", {
skip: (req, res) => {
- var skip = !(process.env["LOG_REQUESTS"]?.includes(res.statusCode.toString()) ?? false);
+ let skip = !(process.env["LOG_REQUESTS"]?.includes(res.statusCode.toString()) ?? false);
if (process.env["LOG_REQUESTS"]?.charAt(0) == "-") skip = !skip;
return skip;
}
})
);
- };
+ }
this.app.use(CORS);
this.app.use(BodyParser({ inflate: true, limit: "10mb" }));
@@ -87,8 +85,13 @@ export class FosscordServer extends Server {
this.app.use(ErrorHandler);
TestClient(this.app);
- if (logRequests) console.log(red(`Warning: Request logging is enabled! This will spam your console!\nTo disable this, unset the 'LOG_REQUESTS' environment variable!`));
-
+ if (logRequests)
+ console.log(
+ red(
+ `Warning: Request logging is enabled! This will spam your console!\nTo disable this, unset the 'LOG_REQUESTS' environment variable!`
+ )
+ );
+
return super.start();
}
-};
\ No newline at end of file
+}
|