Skip to content

Commit

Permalink
chore: reduce logging (#159)
Browse files Browse the repository at this point in the history
  • Loading branch information
shark0der authored Jan 8, 2025
2 parents 9407e6c + 5b20a47 commit c2d2818
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 14 deletions.
6 changes: 6 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ const main = async () => {
next();
});

// log incoming requests
app.use((req, res, next) => {
console.info(`${req.method} ${req.originalUrl}`);
next();
});

// initiate routes
app.use('/v2', capacityRouter);
app.use('/v2', quoteRouter);
Expand Down
10 changes: 1 addition & 9 deletions src/routes/capacity.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,6 @@ router.get(
asyncRoute(async (req, res) => {
const periodQuery = Number(req.query.period) || 30;

console.info(`Request: periodQuery=${periodQuery}`);

if (!Number.isInteger(periodQuery) || periodQuery < 28 || periodQuery > 365) {
return res.status(400).send({ error: 'Invalid period: must be an integer between 28 and 365', response: null });
}
Expand Down Expand Up @@ -171,8 +169,6 @@ router.get(
const productId = Number(req.params.productId);
const periodQuery = Number(req.query.period) || 30;

console.info(`Request: productId=${productId}, periodQuery=${periodQuery}`);

if (!Number.isInteger(periodQuery) || periodQuery < 28 || periodQuery > 365) {
return res.status(400).send({ error: 'Invalid period: must be an integer between 28 and 365', response: null });
}
Expand Down Expand Up @@ -273,8 +269,6 @@ router.get(
const poolId = Number(req.params.poolId);
const periodQuery = Number(req.query.period) || 30;

console.info(`Request: poolId=${poolId}, periodQuery=${periodQuery}`);

if (!Number.isInteger(periodQuery) || periodQuery < 28 || periodQuery > 365) {
return res.status(400).send({ error: 'Invalid period: must be an integer between 28 and 365', response: null });
}
Expand All @@ -292,7 +286,7 @@ router.get(
utilizationRate: poolCapacity.utilizationRate.toNumber(),
productsCapacity: poolCapacity.productsCapacity.map(productCapacity => formatCapacityResult(productCapacity)),
};
console.info('Response: ', inspect(response, { depth: null }));
console.debug('Response: ', inspect(response, { depth: null }));

res.json(response);
} catch (error) {
Expand Down Expand Up @@ -351,8 +345,6 @@ router.get(
const productId = Number(req.params.productId);
const periodQuery = Number(req.query.period) || 30;

console.info(`Request: poolId=${poolId}, productId=${productId}, periodQuery=${periodQuery}`);

if (!Number.isInteger(periodQuery) || periodQuery < 28 || periodQuery > 365) {
return res.status(400).send({ error: 'Invalid period: must be an integer between 28 and 365', response: null });
}
Expand Down
2 changes: 0 additions & 2 deletions src/routes/pricing.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@ router.get(
asyncRoute(async (req, res) => {
const productId = Number(req.params.productId);

console.info(`Request: productId=${productId}`);

if (!Number.isInteger(productId) || productId < 0) {
return res.status(400).send({ error: 'Invalid productId: must be an integer', response: null });
}
Expand Down
3 changes: 0 additions & 3 deletions src/routes/quote.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,6 @@ router.get(
const period = BigNumber.from(req.query.period).mul(24 * 3600);
const coverAsset = Number(req.query.coverAsset);

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);

Expand Down

0 comments on commit c2d2818

Please sign in to comment.