diff options
Diffstat (limited to 'src/api/Server.ts')
-rw-r--r-- | src/api/Server.ts | 32 |
1 files changed, 8 insertions, 24 deletions
diff --git a/src/api/Server.ts b/src/api/Server.ts index 472ab1d6..b99c9721 100644 --- a/src/api/Server.ts +++ b/src/api/Server.ts @@ -41,13 +41,7 @@ import { initRateLimits } from "./middlewares/RateLimit"; import { initTranslation } from "./middlewares/Translation"; import { initInstance } from "./util/handlers/Instance"; -const PUBLIC_ASSETS_FOLDER = path.join( - __dirname, - "..", - "..", - "assets", - "public", -); +const PUBLIC_ASSETS_FOLDER = path.join(__dirname, "..", "..", "assets", "public"); export type SpacebarServerOptions = ServerOptions; @@ -84,16 +78,11 @@ export class SpacebarServer extends Server { this.app.use( morgan("combined", { skip: (req, res) => { - let skip = !( - process.env["LOG_REQUESTS"]?.includes( - res.statusCode.toString(), - ) ?? false - ); - if (process.env["LOG_REQUESTS"]?.charAt(0) == "-") - skip = !skip; + let skip = !(process.env["LOG_REQUESTS"]?.includes(res.statusCode.toString()) ?? false); + if (process.env["LOG_REQUESTS"]?.charAt(0) == "-") skip = !skip; return skip; }, - }), + }) ); } @@ -112,10 +101,7 @@ export class SpacebarServer extends Server { await initRateLimits(api); await initTranslation(api); - this.routes = await registerRoutes( - this, - path.join(__dirname, "routes", "/"), - ); + this.routes = await registerRoutes(this, path.join(__dirname, "routes", "/")); // 404 is not an error in express, so this should not be an error middleware // this is a fine place to put the 404 handler because its after we register the routes @@ -137,9 +123,7 @@ export class SpacebarServer extends Server { app.use("/api/v9", api); app.use("/api", api); // allow unversioned requests - app.get("/", (req, res) => - res.sendFile(path.join(PUBLIC_ASSETS_FOLDER, "index.html")), - ); + app.get("/", (req, res) => res.sendFile(path.join(PUBLIC_ASSETS_FOLDER, "index.html"))); this.app.use(ErrorHandler); @@ -150,8 +134,8 @@ export class SpacebarServer extends Server { if (logRequests) console.log( red( - `Warning: Request logging is enabled! This will spam your console!\nTo disable this, unset the 'LOG_REQUESTS' environment variable!`, - ), + `Warning: Request logging is enabled! This will spam your console!\nTo disable this, unset the 'LOG_REQUESTS' environment variable!` + ) ); return super.start(); |