From 183a025a83a1ba56e98886112582ed08fb3974f6 Mon Sep 17 00:00:00 2001 From: Christian Paul Date: Mon, 14 Mar 2022 20:48:42 +0100 Subject: [PATCH 1/2] Update app-service.ts --- src/app-service.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/app-service.ts b/src/app-service.ts index 4121de5..90d3d30 100644 --- a/src/app-service.ts +++ b/src/app-service.ts @@ -194,8 +194,12 @@ export class AppService extends EventEmitter { } private onMorganLog(str: string) { - const redactedStr = str.replace(/access_token=.*?(&|\s|$)/, "access_token=$1"); - this.emit("http-log", redactedStr); + // The dependency `morgan` expects to write to a stream and adds a new line at the end. + // Listeners of the `http-log` event expect there not to be a new line, so the string + // can be handed to a logger like `console.log()` without displaying empty lines. + str = str.replace(/\n$/, ""); + str = str.replace(/access_token=.*?(&|\s|$)/, "access_token=$1"); + this.emit("http-log", str); } private isInvalidToken(req: Request, res: Response): boolean { From 08417bbafde8227f0dbe44bb47872eca8c1e5b25 Mon Sep 17 00:00:00 2001 From: Christian Paul Date: Mon, 14 Mar 2022 21:15:24 +0100 Subject: [PATCH 2/2] Create 50.bugfix --- changelog.d/50.bugfix | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/50.bugfix diff --git a/changelog.d/50.bugfix b/changelog.d/50.bugfix new file mode 100644 index 0000000..b60bb25 --- /dev/null +++ b/changelog.d/50.bugfix @@ -0,0 +1 @@ +Remove tailing new line on http-log events