From e9a2aae87402ff97918bbaa9388f9cd355f964ef Mon Sep 17 00:00:00 2001 From: Manos Kouvarakis Date: Fri, 21 Jun 2024 16:29:53 +0300 Subject: [PATCH] Pass host field name to riviere to be able to use custom host PROD-43442 (#385) * Use new hostFieldName for riviere * Use latest riviere * Fix tests --- __snapshots__/diamorphosis.test.ts.js | 21 ++++++++++++++------- package-lock.json | 12 ++++++------ src/initializers/diamorphosis.ts | 1 + src/initializers/riviere.ts | 1 + 4 files changed, 22 insertions(+), 13 deletions(-) diff --git a/__snapshots__/diamorphosis.test.ts.js b/__snapshots__/diamorphosis.test.ts.js index 248baee2..148262c0 100644 --- a/__snapshots__/diamorphosis.test.ts.js +++ b/__snapshots__/diamorphosis.test.ts.js @@ -100,7 +100,8 @@ exports['Diamorphosis Test should set json/console loggingvariables when nothing }, "color": true, "styles": [], - "headersRegex": "(^X-.*)|cf-ray" + "headersRegex": "(^X-.*)|cf-ray", + "hostFieldName": "host" }, "healthCheck": { "kafka": false, @@ -326,7 +327,8 @@ exports['Diamorphosis Test should set json/console loggingvariables when console "styles": [ "json" ], - "headersRegex": "(^X-.*)|cf-ray" + "headersRegex": "(^X-.*)|cf-ray", + "hostFieldName": "host" }, "healthCheck": { "kafka": false, @@ -552,7 +554,8 @@ exports['Diamorphosis Test should set json/console loggingvariables when console "styles": [ "json" ], - "headersRegex": "(^X-.*)|cf-ray" + "headersRegex": "(^X-.*)|cf-ray", + "hostFieldName": "host" }, "healthCheck": { "kafka": false, @@ -778,7 +781,8 @@ exports['Diamorphosis Test should set json/console loggingvariables when console "styles": [ "json" ], - "headersRegex": "(^X-.*)|cf-ray" + "headersRegex": "(^X-.*)|cf-ray", + "hostFieldName": "host" }, "healthCheck": { "kafka": false, @@ -931,7 +935,8 @@ exports['Diamorphosis Test should set json/console loggingvariables when console "styles": [ "simple" ], - "headersRegex": "(^X-.*)|cf-ray" + "headersRegex": "(^X-.*)|cf-ray", + "hostFieldName": "host" }, "nodeEnv": "development", "app": { @@ -1283,7 +1288,8 @@ exports['Diamorphosis Test should set json/console loggingvariables when console }, "color": true, "styles": [], - "headersRegex": "(^X-.*)|cf-ray" + "headersRegex": "(^X-.*)|cf-ray", + "hostFieldName": "host" }, "queue": { "url": "", @@ -1516,7 +1522,8 @@ exports['Diamorphosis Test should set json/console loggingvariables when console "styles": [ "json" ], - "headersRegex": "(^X-.*)|cf-ray" + "headersRegex": "(^X-.*)|cf-ray", + "hostFieldName": "host" }, "queue": { "url": "", diff --git a/package-lock.json b/package-lock.json index 163e3527..2cfbf0c0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1147,9 +1147,9 @@ "dev": true }, "node_modules/@workablehr/riviere": { - "version": "1.16.1", - "resolved": "https://registry.npmjs.org/@workablehr/riviere/-/riviere-1.16.1.tgz", - "integrity": "sha512-0C9W3i/onOnVE1Q8hRu57HguMA2rN76ZiYWb9MayrtpRpMkCUcbfJgq8ioFg8zYjDMhxoe7akydXot/VBDE0GQ==", + "version": "1.18.0", + "resolved": "https://registry.npmjs.org/@workablehr/riviere/-/riviere-1.18.0.tgz", + "integrity": "sha512-/Y/l1GYUAaaBaAuKvLoD8VGYGrfjt6SSNLhz7ZI2s2dvcefLV2Yxj4Phwslizeyg37bKGZV2W+SrTItUqVBA8A==", "dependencies": { "chalk": "^2.4.2", "flat": "^5.0.2", @@ -9547,9 +9547,9 @@ "dev": true }, "@workablehr/riviere": { - "version": "1.16.1", - "resolved": "https://registry.npmjs.org/@workablehr/riviere/-/riviere-1.16.1.tgz", - "integrity": "sha512-0C9W3i/onOnVE1Q8hRu57HguMA2rN76ZiYWb9MayrtpRpMkCUcbfJgq8ioFg8zYjDMhxoe7akydXot/VBDE0GQ==", + "version": "1.18.0", + "resolved": "https://registry.npmjs.org/@workablehr/riviere/-/riviere-1.18.0.tgz", + "integrity": "sha512-/Y/l1GYUAaaBaAuKvLoD8VGYGrfjt6SSNLhz7ZI2s2dvcefLV2Yxj4Phwslizeyg37bKGZV2W+SrTItUqVBA8A==", "requires": { "chalk": "^2.4.2", "flat": "^5.0.2", diff --git a/src/initializers/diamorphosis.ts b/src/initializers/diamorphosis.ts index 8a46ef2f..94e4496a 100644 --- a/src/initializers/diamorphosis.ts +++ b/src/initializers/diamorphosis.ts @@ -93,6 +93,7 @@ export default (config, orkaOptions: Partial) => { styles: [], headersRegex: '(^X-.*)|cf-ray', maxBodyValueChars: undefined, + hostFieldName: 'host', ...config.riviere }; diff --git a/src/initializers/riviere.ts b/src/initializers/riviere.ts index ce3c7fd6..47b9a3a9 100644 --- a/src/initializers/riviere.ts +++ b/src/initializers/riviere.ts @@ -48,6 +48,7 @@ const init = (config, orkaOptions) => { bodyKeysRegex: config.riviere.bodyKeysRegex && new RegExp(config.riviere.bodyKeysRegex, 'i'), bodyKeysCallback: config.riviere.bodyKeysCallback, color: config.riviere.color, + hostFieldName: config.riviere.hostFieldName, context: (ctx: Koa.Context) => { return { visitor: ctx.state.visitor,