Backend service for the Bitcoin Map application that provides APIs for Bitcoin-accepting locations.
# Install dependencies
npm install
# Start the development server
npm run dev
The development server will run at http://localhost:3001 with auto-reload enabled.
# Install dependencies
npm install
# Build the application
npm run build
# Start the production server
npm run start
The production server will run at http://localhost:3001.
The application includes a comprehensive test suite built with Jest:
# Run all tests
npm test
# Run tests in watch mode (for development)
npm run test:watch
# Generate test coverage report
npm run test:coverage
The test coverage report will be generated in the coverage/
directory.
Tests are automatically run on each pull request and push to the main branch using GitHub Actions. The workflow:
- Runs all tests
- Generates a coverage report
- Checks if coverage is above the threshold (75%)
- Comments on the PR with the coverage report
This ensures that all code changes maintain quality and don't break existing functionality.
For more details about the testing approach and structure, see the tests README.
Method | Route | Description |
---|---|---|
GET | /health |
Health check endpoint |
GET | /api/locations |
Get all Bitcoin-accepting locations with complete details |
GET | /api/coordinates |
Get only coordinates of all Bitcoin-accepting locations (optimized for initial map loading) |
GET | /api/locations/:id |
Get complete details of a specific Bitcoin-accepting location by ID |
GET | /api/stats |
Get statistics about Bitcoin locations including total count, location types, and country distribution |
The API has been optimized for better performance and user experience:
- Coordinates-Only Endpoint: The
/api/coordinates
endpoint returns only essential location data (id, type, lat, lon), reducing payload size by up to 90% compared to full location details. - On-Demand Location Details: The
/api/locations/:id
endpoint allows fetching complete details only when needed (e.g., when a user clicks on a map marker). - Efficient Data Loading: This two-step approach significantly improves initial map loading time, especially on slower connections or mobile devices.
- Reduced Bandwidth Usage: By loading only necessary data, the application uses less bandwidth and is more responsive.
The backend integrates with the following external services:
-
- Used to fetch Bitcoin-accepting locations worldwide
- Synchronized hourly using a cron job
- Provides essential location data, including coordinates and business details
-
- Used to fetch Bitcoin-accepting locations from OpenStreetMap
- Synchronized hourly along with BTCMap data
- Provides additional geographic and point-of-interest data
- Express.js: Web server framework
- SQLite: Database for storing location data
- Node Cron: For scheduling hourly data synchronization
- Axios: For HTTP requests to external APIs
- TypeScript: For type-safe code
- Jest: For testing
- ts-jest: For TypeScript support in Jest
Contributions are welcome! Please feel free to submit a Pull Request for bug fixes, new features, or improvements.
When contributing, please ensure:
- All tests pass (
npm test
) - New features include appropriate tests
- Code follows the existing style and conventions