Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: reduce logging #159

Merged
merged 4 commits into from
Jan 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 }));
shark0der marked this conversation as resolved.
Show resolved Hide resolved

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