From fcc923f628bf4cc00ad360d67b43119a94da49cd Mon Sep 17 00:00:00 2001 From: Evan Jones Date: Tue, 30 Jul 2024 16:43:29 -0400 Subject: [PATCH] feat(example): fix karapace-router logging --- example/karapace-router.js | 21 ++++++++++++--------- package.json | 2 +- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/example/karapace-router.js b/example/karapace-router.js index 835616b..aac788e 100644 --- a/example/karapace-router.js +++ b/example/karapace-router.js @@ -17,20 +17,20 @@ * under the License. */ -const commander = require('commander'); -const { program } = require('commander'); -const express = require('express'); -const bodyParser = require('body-parser'); +const commander = require("commander"); +const { program } = require("commander"); +const express = require("express"); +const bodyParser = require("body-parser"); // Functions. -const myParseInt = (value, _dummyPrevious) => { +const myParseInt = (value, _dummyPrevious) => { // parseInt takes a string and a radix const parsedValue = parseInt(value, 10); if (isNaN(parsedValue)) { - throw new commander.InvalidArgumentError('Not a number.'); + throw new commander.InvalidArgumentError("Not a number."); } return parsedValue; -} +}; const configureCors = (req, res, next) => { res.header("Access-Control-Allow-Origin", "*"); @@ -60,14 +60,17 @@ const transformAndForward = async (req, res) => { Object.keys(body).length === 0; if (isEmptyArray || isEmptyObject) return; + if (options.verbose) console.log(JSON.stringify(body, null, 3)); + const transformedPayload = { - records: body.forEach((log) => ({ + records: body.map((log) => ({ key: log["sessionId"], value: log, })), }; - if (options.verbose) console.log(transformedPayload); + if (options.verbose) + console.log(JSON.stringify(transformedPayload, null, 3)); const response = await fetch(options.forwardTo, { method: "POST", diff --git a/package.json b/package.json index 1657233..d53742e 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,7 @@ "clean": "rm -rf ./build", "test": "npm run test:unit && npm run test:e2e", "test:unit": "jest -c ./test/unit/jest.config.ts", - "test:e2e": "xvfb-run playwright test -c ./test/e2e/playwright.config.ts", + "test:e2e": "playwright test -c ./test/e2e/playwright.config.ts", "pretest:e2e": "rm -rf ./test/e2e/chromeData/*", "posttest:e2e": "rm -rf ./test/e2e/chromeData/*", "example:run": "node example/server.js",