StreamPay API backend — stream management, usage metering, and settlement services.
Node.js + Express (TypeScript) service that will power the StreamPay API gateway: health checks, stream listing, and (later) metering and Stellar settlement integration.
- Node.js 18+
- npm (or yarn/pnpm)
-
Clone and enter the repo
git clone <repo-url> cd streampay-backend
-
Install dependencies
npm install
-
Verify setup
npm run build npm test -
Run locally
npm run dev # dev with hot reload # or npm run build && npm start
API will be at http://localhost:3001 (or PORT env). Try GET /health and GET /api/streams.
The backend now exposes POST /webhooks/indexer for trusted chain-indexer events such as stream_created and settled.
Set INDEXER_WEBHOOK_SECRET before running the service. The sender must compute an HMAC SHA-256 signature over the raw JSON request body and send it in the x-indexer-signature header using either the raw hex digest or the sha256=<digest> format.
Example payload:
{
"eventId": "evt_123",
"eventType": "stream_created",
"streamId": "stream_456",
"occurredAt": "2026-03-23T10:00:00.000Z",
"chainId": "stellar-testnet",
"transactionHash": "abc123",
"data": {
"amount": "42"
}
}Security notes:
- Signature verification uses the raw request body and
crypto.timingSafeEqual. - Replay protection is enforced by deduplicating
eventIdvalues in the ingestion service. - Duplicate deliveries are treated as safe no-ops and return
202 Accepted.
All new features and endpoints must be mounted under the /api/v1 prefix.
Deprecation and Sunset Policy: We use HTTP headers to signal end-of-life for specific API versions:
X-API-Version: Indicates the current version of the API responding to the request.Deprecation: A boolean flag (trueorfalse) indicating if the API version is deprecated. Whentrue, developers should migrate to a newer version as soon as possible.
| Command | Description |
|---|---|
npm run build |
Compile TypeScript |
npm start |
Run production build |
npm run dev |
Run with ts-node-dev |
npm test |
Run Jest tests |
npm run lint |
Run ESLint |
On every push/PR to main, GitHub Actions runs:
- Install:
npm ci - Build:
npm run build - Tests:
npm test
Keep the default branch green before merging.
streampay-backend/
├── src/
│ ├── api/ # Versioned API routes
│ ├── db/ # Drizzle ORM schema and client
│ ├── metrics/ # Prometheus metrics logic and tests
│ ├── repositories/ # Data access layer
│ └── routes/ # Webhooks and other handlers
├── package.json
├── tsconfig.json
├── jest.config.js
├── .github/workflows/ci.yml
└── README.md
MIT
To run the E2E smoke tests against a local Docker stack:
docker-compose up -d./scripts/smoke.sh http://localhost:3000
Prerequisites: curl must be installed.