From e78b6c4fbc03a3cedc100ed856be68550683e0cd Mon Sep 17 00:00:00 2001 From: Simon J Date: Sun, 12 Mar 2023 09:21:49 +1100 Subject: [PATCH] Ability to configure whether to log http requests (#149) --- README.md | 1 + src/app.ts | 2 +- src/config.ts | 1 + tests/config.test.ts | 9 +++++++++ 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 9be2dce..98cc2ae 100644 --- a/README.md +++ b/README.md @@ -146,6 +146,7 @@ BNB_PORT | 4534 | Default http port for bonob to listen on BNB_URL | http://$(hostname):4534 | URL (including path) for bonob so that sonos devices can communicate. **This must be either the public IP or DNS entry of the bonob instance so that the sonos devices can communicate with it.** BNB_SECRET | bonob | secret used for encrypting credentials BNB_AUTH_TIMEOUT | 1h | Timeout for the sonos auth token, described in the format [ms](https://github.com/vercel/ms), ie. '5s' == 5 seconds, '11h' == 11 hours. In the case of using Navidrome this should be less than the value for ND_SESSIONTIMEOUT +BNB_SERVER_LOG_REQUESTS | false | Whether or not to log http requests BNB_SONOS_AUTO_REGISTER | false | Whether or not to try and auto-register on startup BNB_SONOS_DEVICE_DISCOVERY | true | Enable/Disable sonos device discovery entirely. Setting this to 'false' will disable sonos device search, regardless of whether a seed host is specified. BNB_SONOS_SEED_HOST | undefined | sonos device seed host for discovery, or ommitted for for auto-discovery diff --git a/src/app.ts b/src/app.ts index 4dc1eb2..4b4c645 100644 --- a/src/app.ts +++ b/src/app.ts @@ -88,7 +88,7 @@ const app = server( clock, iconColors: config.icons, applyContextPath: true, - logRequests: true, + logRequests: config.logRequests, version, smapiAuthTokens: new JWTSmapiLoginTokens(clock, config.secret, config.authTimeout), externalImageResolver: artistImageFetcher diff --git a/src/config.ts b/src/config.ts index 2e33b8c..7a65623 100644 --- a/src/config.ts +++ b/src/config.ts @@ -85,6 +85,7 @@ export default function () { validationPattern: COLOR, }), }, + logRequests: bnbEnvVar("SERVER_LOG_REQUESTS", { default: false, parser: asBoolean }), sonos: { serviceName: bnbEnvVar("SONOS_SERVICE_NAME", { default: "bonob" })!, discovery: { diff --git a/tests/config.test.ts b/tests/config.test.ts index 25206d3..1988410 100644 --- a/tests/config.test.ts +++ b/tests/config.test.ts @@ -270,6 +270,15 @@ describe("config", () => { expect(config().authTimeout).toEqual("33s"); }); }); + + describe("logRequests", () => { + describeBooleanConfigValue( + "logRequests", + "BNB_SERVER_LOG_REQUESTS", + false, + (config) => config.logRequests + ); + }); describe("sonos", () => { describe("serviceName", () => {