Skip to content

[WIP] Enhance Cryptocurrency Details API with Improved Error Handling and Caching - #157

Draft
Bhing26 wants to merge 19 commits into
HermanKoii:mainfrom
Bhing26:29164f19-ce10-4f02-85c0-9568a4a29675-merged
Draft

[WIP] Enhance Cryptocurrency Details API with Improved Error Handling and Caching#157
Bhing26 wants to merge 19 commits into
HermanKoii:mainfrom
Bhing26:29164f19-ce10-4f02-85c0-9568a4a29675-merged

Conversation

@Bhing26

@Bhing26 Bhing26 commented Jun 7, 2025

Copy link
Copy Markdown

Enhance Cryptocurrency Details API with Improved Error Handling and Caching

Description

Summary of Work

This pull request introduces improvements to the cryptocurrency details API, focusing on:

  1. Robust error handling for coin detail retrieval
  2. Implementing caching mechanism for performance optimization
  3. Preparing for potential future expansion of coin data sources

Key objectives:

  • Provide clear, consistent error responses for different scenarios
  • Improve API reliability and response times
  • Create a flexible architecture for future enhancements

The current implementation uses a mock data approach with in-memory caching, which serves as a solid foundation for further development.

Changes Made

  • Added comprehensive error handling in coinDetails route
  • Implemented NodeCache for caching cryptocurrency details
  • Created input validation for coin ID
  • Established consistent error response format
  • Added mock data for initial coin details (Bitcoin and Ethereum)

Architectural improvements:

  • Separated error handling into a dedicated middleware
  • Used lowercase normalization for coin ID lookups
  • Implemented a 10-minute cache TTL to balance data freshness and performance

Tests and Verification

Verification steps:

  • Manually tested coin details retrieval for existing coins
  • Validated error handling for:
    • Empty coin ID
    • Non-existent coin ID
    • Malformed input
  • Confirmed caching mechanism works as expected
  • Ensured consistent error response formats

Recommended next steps:

  • Add comprehensive unit tests for all route scenarios
  • Implement actual cryptocurrency data fetching from external API
  • Add more robust error logging and monitoring

PRs Merged

The following pull requests have been merged:

Signatures

Staking Key

9yp3ZWyDXaMnp3cDbBT7ALUELNx7AqyrBP3tUmyiTee2: 2sfieFrqQcJfBDp2646aRecay89ZNbH6jastjeBcnYx7YVj6qXPCZMtaMwKQDxVRdeN14EfnRHwrwY4hWVR7dDzXXe7yj8egoWsgcrtZsjBiLfFkU8aHTg4da3FoT5CF5QY2wF79eMv4LrWT4AtBMCMmZeppjum1ANpoH275kwWRDaMy2E8vnNHVc77AGThoLvM5qVrWm5RyhEDZv8CCynMYKMAu9dSJPAYzBQgAvDBmohzJydQAYfTU9vDKzcyGSovmeMdb8F6MBYriYA7jdKTVVrosJnCQ7vfhdF3542T7cfPxbMV3AfZWDvyNDm9289E1Dhg7BfRwrzQEfDQKWhjwY8Hb3Zb6fCmK2wMPeD5awCt8eNoRiCoV4pAGqiQy35GJf6XkPRsnYsVdhK7mvcZq1SW5xvHr

Public Key

66oeEjuoK4X6yRibgmFsyAYYVVTP6yzBy5ARMaVbkKm8: 2c2sJRpPLsL4wWAx6UEuybuR5Ae7yqYFLqeB5cU6CgD7utp5wsypht3FLs8Jznjd5bfLHkvDkFJxRoGUfdmi5aBHauDRdQqkTFqHgzJQAJ4WsjbhPc8T5vxnCdozqCJcgKovfTRieTuh7kpAHxQ65eBN11qM9GUE3Xmb5wBvf2yMyMDj4WjYWztJFKLznxTMLGMXtn4EVaEic5qLaPMDVGyMtEmDM3PDMQFfLaXWAjHUf7vHTsM6YnvP2h6p1ATHi6exVWTP6yq9zxhPKSWvfZXTb27nVsEQFpq7eDid77Enb24pMnVSaxD7kgPs55Hg63tXruRPbDPPnjBj7mn73q3jhuXvkmWQqKtkZDo4S3PVghSMmALbH5haZR7v2hnWzSpX96Soxem1bhy9yhjxDK1zuQ9i6HU8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants