fix: reduce local server status overhead
This commit is contained in:
+2
-1
@@ -18,6 +18,7 @@ export const createBootstrapRuntime = (dependencies) => {
|
||||
serverStartedAt,
|
||||
gracefulShutdown,
|
||||
getHealthSnapshot,
|
||||
verboseRequestLogs,
|
||||
uiPassword,
|
||||
tunnelAuthController,
|
||||
readSettingsFromDiskMigrated,
|
||||
@@ -60,7 +61,7 @@ export const createBootstrapRuntime = (dependencies) => {
|
||||
getHealthSnapshot,
|
||||
});
|
||||
|
||||
registerCommonRequestMiddleware(app, { express });
|
||||
registerCommonRequestMiddleware(app, { express, verboseRequestLogs });
|
||||
|
||||
const uiAuthController = createUiAuth({
|
||||
password: uiPassword,
|
||||
|
||||
@@ -451,7 +451,7 @@ export const registerSettingsUtilityRoutes = (app, dependencies) => {
|
||||
};
|
||||
|
||||
export const registerCommonRequestMiddleware = (app, dependencies) => {
|
||||
const { express } = dependencies;
|
||||
const { express, verboseRequestLogs = false } = dependencies;
|
||||
|
||||
app.use((req, res, next) => {
|
||||
if (req.path.startsWith('/api/behavior')) {
|
||||
@@ -492,7 +492,9 @@ export const registerCommonRequestMiddleware = (app, dependencies) => {
|
||||
app.use(express.urlencoded({ extended: true, limit: '50mb' }));
|
||||
|
||||
app.use((req, _res, next) => {
|
||||
console.log(`${new Date().toISOString()} - ${req.method} ${req.path}`);
|
||||
if (verboseRequestLogs) {
|
||||
console.log(`${new Date().toISOString()} - ${req.method} ${req.path}`);
|
||||
}
|
||||
next();
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user