Skip to content

Commit

Permalink
Merge pull request #4 from notEduardo/debug
Browse files Browse the repository at this point in the history
better error logs
  • Loading branch information
notEduardo authored Dec 1, 2024
2 parents cf85bb7 + c2f62c0 commit ebbf345
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/routes/rateLimitRoute.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ router.post('/rate-limits', async (req, res, next) => {
const newRateLimit = await rateLimits.createRateLimit(key, timestamps);
res.status(201).json(newRateLimit);
} catch (error) {
console.error(`Error creating rate limit for key "${key}":`, error);
next(error); // Pass errors to global error handler
}
});
Expand All @@ -24,9 +25,11 @@ router.get('/rate-limits/:key', async (req, res, next) => {
if (rateLimit) {
res.status(200).json(rateLimit);
} else {
console.warn(`Rate limit not found for key "${key}"`);
res.status(404).json({ message: 'Rate limit not found' });
}
} catch (error) {
console.error(`Error retrieving rate limit for key "${key}":`, error);
next(error);
}
});
Expand All @@ -41,9 +44,11 @@ router.put('/rate-limits/:key', async (req, res, next) => {
if (updatedRateLimit) {
res.status(200).json(updatedRateLimit);
} else {
console.warn(`Rate limit not found for key "${key}"`);
res.status(404).json({ message: 'Rate limit not found' });
}
} catch (error) {
console.error(`Error updating rate limit for key "${key}":`, error);
next(error);
}
});
Expand Down
4 changes: 3 additions & 1 deletion src/routes/solanaBalancesRoute.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ router.post('/solana-balances', async (req, res, next) => {
const newBalance = await solanaBalances.createSolanaBalance(account, balance);
res.status(201).json(newBalance);
} catch (error) {
console.error(`Error creating Solana balance for account: ${account}, Error: ${error.message}`);
next(error);
}
});
Expand All @@ -23,6 +24,7 @@ router.get('/solana-balances/account/:account', async (req, res, next) => {
const balances = await solanaBalances.getSolanaBalancesByAccount(account);
res.status(200).json(balances);
} catch (error) {
console.error(`Error retrieving Solana balances for account: ${account}, Error: ${error.message}`);
next(error);
}
});
Expand All @@ -33,9 +35,9 @@ router.get('/solana-balances/recent', async (req, res, next) => {
const recentBalances = await solanaBalances.getRecentBalances();
res.status(200).json(recentBalances);
} catch (error) {
console.error(`Error retrieving recent Solana balances, Error: ${error.message}`);
next(error);
}
});


export default router;

0 comments on commit ebbf345

Please sign in to comment.