Express + TypeScript API for the Fluxora treasury streaming protocol. Provides REST endpoints for streams, health checks, and (later) Horizon sync and analytics.
All amounts crossing the chain/API boundary are serialized as decimal strings to prevent precision loss in JSON.
depositAmount- Total deposit as decimal string (e.g., "1000000.0000000")ratePerSecond- Streaming rate as decimal string (e.g., "0.0000116")
- Amounts MUST be strings in decimal notation (e.g., "100", "-50", "0.0000001")
- Native JSON numbers are rejected to prevent floating-point precision issues
- Values exceeding safe integer ranges are rejected with
DECIMAL_OUT_OF_RANGEerror
| Code | Description |
|---|---|
DECIMAL_INVALID_TYPE |
Amount was not a string |
DECIMAL_INVALID_FORMAT |
String did not match decimal pattern |
DECIMAL_OUT_OF_RANGE |
Value exceeds maximum supported precision |
DECIMAL_EMPTY_VALUE |
Amount was empty or null |
| Actor | Capabilities |
|---|---|
| Public Clients | Read streams, submit valid decimal strings |
| Authenticated Partners | Create streams with validated amounts |
| Administrators | Full access, diagnostic logging |
| Internal Workers | Database operations, chain interactions |
| Scenario | Behavior |
|---|---|
| Invalid decimal type | 400 with DECIMAL_INVALID_TYPE |
| Malformed decimal string | 400 with DECIMAL_INVALID_FORMAT |
| Precision overflow | 400 with DECIMAL_OUT_OF_RANGE |
| Missing required field | 400 with VALIDATION_ERROR |
| Stream not found | 404 with NOT_FOUND |
Serialization events are logged with context for debugging:
Decimal validation failed {"field":"depositAmount","errorCode":"DECIMAL_INVALID_TYPE","requestId":"..."}
GET /health- Returns service health status- Request IDs enable correlation across logs
- Structured JSON logs for log aggregation systems
# Run all tests
npm test
# Run with coverage
npm test -- --coverage
# Build TypeScript
npm run build
# Start server
npm start- In-memory stream storage (production requires database integration)
- No Stellar RPC integration (placeholder for chain interactions)
- Rate limiting not implemented (future enhancement)
- API Gateway — REST API for stream CRUD and health
- Streams API — List, get, and create stream records (in-memory placeholder; will be replaced by PostgreSQL + Horizon listener)
- Ready to extend with JWT, RBAC, rate limiting, and streaming engine
- Node.js 18+
- TypeScript
- Express
- Node.js 18+
- npm or pnpm
npm install
npm run devAPI runs at http://localhost:3000.
npm run dev— Run with tsx watch (no build)npm run build— Compile todist/npm start— Run compileddist/index.js
| Method | Path | Description |
|---|---|---|
| GET | / |
API info |
| GET | /health |
Health check |
| GET | /api/streams |
List streams |
| GET | /api/streams/:id |
Get one stream |
| POST | /api/streams |
Create stream (body: sender, recipient, depositAmount, ratePerSecond, startTime) |
All responses are JSON. Stream data is in-memory until you add PostgreSQL.
src/
routes/ # health, streams
index.ts # Express app and server
Optional:
PORT— Server port (default: 3000)
Later you can add DATABASE_URL, REDIS_URL, HORIZON_URL, JWT_SECRET, etc.
- fluxora-frontend — Dashboard and recipient UI
- fluxora-contracts — Soroban smart contracts
Each is a separate Git repository.