Skip to content

Feat/Currency Conversion#15

Merged
ngodi merged 9 commits into
devfrom
feat/currency-conversion
May 31, 2025
Merged

Feat/Currency Conversion#15
ngodi merged 9 commits into
devfrom
feat/currency-conversion

Conversation

@mickey4653
Copy link
Copy Markdown
Contributor

Bitnob API Integration

Overview

This PR implements a Node.js API service that integrates with the Bitnob API to provide currency conversion and exchange rate functionality. The implementation follows a clean architecture pattern with proper separation of concerns and robust error handling.

Features Implemented

1. Currency Conversion

  • Endpoint: POST /api/currency/convert
  • Converts between different currencies using Bitnob's exchange rates
  • Input validation using Zod schema
  • Supports conversion between any supported currency pairs

2. Exchange Rate Information

  • Endpoint: GET /api/currency/rates
  • Retrieves all available exchange rates from Bitnob
  • Returns comprehensive rate information for all supported currencies

3. Specific Currency Rate

  • Endpoint: GET /api/currency/rate/:currency
  • Retrieves exchange rate information for a specific currency
  • Supports any currency code supported by Bitnob

Technical Implementation Details

Architecture

  • Follows MVC pattern with clear separation of concerns:
    • Controllers: Handle request/response logic
    • Services: Implement business logic and API integration
    • Routes: Define API endpoints and routing

Key Components

Currency Service

  • Implements Bitnob API integration
  • Handles all currency-related operations
  • Includes comprehensive error handling and logging
  • Uses Axios for HTTP requests

Input Validation

  • Implements Zod schema validation
  • Validates currency codes and amounts
  • Provides detailed error messages

Error Handling

  • Global error handling middleware
  • Detailed error responses
  • Proper HTTP status codes
  • Comprehensive error logging

Dependencies

  • Express.js for API framework
  • Axios for HTTP requests
  • Zod for input validation
  • Dotenv for environment configuration
  • Jest for testing
  • ESLint for code quality

Testing

  • Jest configuration set up
  • Test directory structure in place
  • Ready for implementing unit and integration tests

Security

  • API key management through environment variables
  • Input validation and sanitization
  • Proper error handling to prevent information leakage

Documentation

  • Clear code comments
  • README.md with setup instructions
  • API endpoint documentation

	- added currency conversion routes, controller, services
	- work in progress
	- added currency conversion correct endpoints
	- all endpoints are working now
	- still working on writing tests
	- all tests are passing successfully
Comment thread src/services/currencyService.js Outdated
Comment thread src/services/currencyService.js Outdated
Copy link
Copy Markdown
Contributor

@ngodi ngodi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please review suggestions

	- resolved all lint errors
	- created BaseBitnobService class so it can reused in currencyService
	- removed duplicated code
Merge branch 'feat/currency-conversion' of https://github.com/internPulse-cohort8/bitnob-api-nodejs into feat/currency-conversion
	- Duplicate imports and app initialization
	- Inconsistent port configuration
	- Missing error handling middleware
	- Missing currency routes
	- removed lint errors
@ngodi ngodi merged commit f63f11e into dev May 31, 2025
3 checks passed
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