Get the Callora backend running in 5 minutes.
- Node.js 18+ installed
- npm or yarn package manager
- (Optional) Stellar account for testing
# Clone the repository
git clone <repository-url>
cd callora-backend
# Install dependencies
npm install
# Copy environment template
cp .env.example .envnpm run devServer starts at http://localhost:3000
npm run build
npm startcurl http://localhost:3000/api/healthExpected response:
{
"status": "ok",
"service": "callora-backend"
}curl http://localhost:3000/api/deposits/healthExpected response:
{
"success": true,
"circuitBreaker": {
"state": "CLOSED",
"consecutiveFailures": 0,
"totalSuccesses": 0
}
}curl -X POST http://localhost:3000/api/deposits/build \
-H "Content-Type: application/json" \
-d '{
"sourcePublicKey": "GABC123...",
"vaultPublicKey": "GDEF456...",
"amount": "100"
}'Note: Use valid Stellar public keys. You can generate test keys at: https://laboratory.stellar.org/#account-creator?network=test
# Run all tests
npm test
# Run with coverage
npm test -- --coverage
# Run specific test file
npm test -- retry.test.ts# .env
HORIZON_URL=https://horizon-testnet.stellar.org
STELLAR_NETWORK=Test SDF Network ; September 2015# .env
HORIZON_URL=https://horizon.stellar.org
STELLAR_NETWORK=Public Global Stellar Network ; September 2015For faster feedback during development:
# .env
CIRCUIT_BREAKER_THRESHOLD=2
CIRCUIT_BREAKER_COOLDOWN_MS=5000
RETRY_MAX_ATTEMPTS=2
RETRY_BASE_DELAY_MS=500For production deployment:
# .env
CIRCUIT_BREAKER_THRESHOLD=10
CIRCUIT_BREAKER_COOLDOWN_MS=60000
RETRY_MAX_ATTEMPTS=5
RETRY_BASE_DELAY_MS=2000-
Configure low threshold:
export CIRCUIT_BREAKER_THRESHOLD=2 export RETRY_MAX_ATTEMPTS=1
-
Use invalid Horizon URL:
export HORIZON_URL=http://invalid-horizon.example.com -
Restart server:
npm run dev
-
Make multiple requests:
# First request (fails) curl -X POST http://localhost:3000/api/deposits/build \ -H "Content-Type: application/json" \ -d '{"sourcePublicKey":"GABC","vaultPublicKey":"GDEF","amount":"100"}' # Second request (fails, trips circuit) curl -X POST http://localhost:3000/api/deposits/build \ -H "Content-Type: application/json" \ -d '{"sourcePublicKey":"GABC","vaultPublicKey":"GDEF","amount":"100"}' # Third request (fast-fails with 502) curl -X POST http://localhost:3000/api/deposits/build \ -H "Content-Type: application/json" \ -d '{"sourcePublicKey":"GABC","vaultPublicKey":"GDEF","amount":"100"}'
-
Check circuit breaker state:
curl http://localhost:3000/api/deposits/health
Expected response:
{ "circuitBreaker": { "state": "OPEN", "consecutiveFailures": 2 } }
- Read RESILIENCE.md for detailed resilience patterns documentation
- Review README.md for complete API documentation
- Explore test files for usage examples
- Configure environment variables for your deployment
# Change port in .env
PORT=3001Or kill the process using port 3000:
# Windows
netstat -ano | findstr :3000
taskkill /PID <PID> /F
# Linux/Mac
lsof -ti:3000 | xargs kill -9# Clean install
rm -rf node_modules package-lock.json
npm install# Check types without building
npm run typecheck
# Clean build
rm -rf dist
npm run build# Clear Jest cache
npm test -- --clearCache
# Run tests in verbose mode
npm test -- --verboseFor issues or questions:
- Check existing documentation
- Review test files for examples
- Open an issue on GitHub
- Contact the development team
[Your License Here]