mirror of
https://github.com/spacebarchat/server.git
synced 2026-05-24 10:15:25 +00:00
Add request logging (with env var: log-requests)
Request logging is enabled when the log-request environment variable is set.
This commit is contained in:
@@ -11,6 +11,7 @@ import path from "path";
|
||||
import { initRateLimits } from "./middlewares/RateLimit";
|
||||
import TestClient from "./middlewares/TestClient";
|
||||
import { initTranslation } from "./middlewares/Translation";
|
||||
import morgan from "morgan";
|
||||
|
||||
export interface FosscordServerOptions extends ServerOptions {}
|
||||
|
||||
@@ -36,6 +37,11 @@ export class FosscordServer extends Server {
|
||||
await Config.init();
|
||||
await initEvent();
|
||||
|
||||
let logRequests = process.env["log-requests"] != undefined;
|
||||
if(logRequests) {
|
||||
this.app.use(morgan("combined"));
|
||||
}
|
||||
|
||||
this.app.use(CORS);
|
||||
this.app.use(BodyParser({ inflate: true, limit: "10mb" }));
|
||||
|
||||
@@ -65,6 +71,9 @@ export class FosscordServer extends Server {
|
||||
this.app.use(ErrorHandler);
|
||||
TestClient(this.app);
|
||||
|
||||
if(logRequests){
|
||||
console.log("Warning: Request logging is enabled! This will spam your console!\nTo disable this, unset the 'log-requests' environment variable!");
|
||||
}
|
||||
return super.start();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user