From 2eb8683adae4226d2cc4e1aa740075a416cea9cb Mon Sep 17 00:00:00 2001 From: Rocky Murdoch Date: Mon, 6 Jan 2025 12:45:56 +0200 Subject: [PATCH] refactor: normalize request query for logging and fix linting issue --- src/routes/quote.js | 3 ++- test/unit/routes/capacity.js | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/routes/quote.js b/src/routes/quote.js index bd030e2..663849a 100644 --- a/src/routes/quote.js +++ b/src/routes/quote.js @@ -150,7 +150,8 @@ router.get( const period = BigNumber.from(req.query.period).mul(24 * 3600); const coverAsset = Number(req.query.coverAsset); - console.info('Request: ', inspect(req.query, { depth: null })); + const normalizedRequestQuery = { ...req.query, amount: BigNumber.from(req.query.amount).toString() }; + console.info('Request: ', inspect(normalizedRequestQuery, { depth: null })); const store = req.app.get('store'); const route = await quoteEngine(store, productId, amount, period, coverAsset); diff --git a/test/unit/routes/capacity.js b/test/unit/routes/capacity.js index b9b6a5e..73fa193 100644 --- a/test/unit/routes/capacity.js +++ b/test/unit/routes/capacity.js @@ -80,7 +80,7 @@ describe('Capacity Routes', () => { const invalidPeriod = 10; const poolId = 2; const url = `/v2/capacity/pools/${poolId}?period=${invalidPeriod}`; - const { body: response } = await server.get(url).expect('Content-Type', /json/).expect(400); + const { body: response } = await server.get(url).expect('Content-Type', /json/).expect(400); expect(response.error).to.be.equal('Invalid period: must be an integer between 28 and 365'); });