@tributary-so/api
v1.0.0
Published
Tributary API - Modular Express API for subscription and payment services
Readme
@tributary-so/api
Modular Express API for Tributary subscription and payment services.
Features
- Modular Architecture: Clean separation of routes, middleware, services, and types
- Easy to Split: Designed to easily split individual API endpoints into separate microservices
- RESTful Design: Standard REST API with
/api/v1prefix - Subscription Status: Check subscription status by tracking ID using the PaymentTracker
- Health Monitoring: Built-in health check endpoint
- Error Handling: Centralized error handling and logging
- Type Safety: Full TypeScript support with comprehensive types
Project Structure
api/
├── src/
│ ├── routes/ # Individual route modules (easy to split into separate services)
│ │ ├── health.ts # Health check endpoint
│ │ ├── skill.ts # Lando skill markdown generation
│ │ └── subscription.ts # Subscription status checking
│ ├── middleware/ # Shared middleware
│ │ ├── errorHandler.ts
│ │ └── requestLogger.ts
│ ├── services/ # Business logic services
│ │ ├── solana.ts # Solana connection management
│ │ └── subscription.ts # Subscription status tracking
│ ├── types/ # TypeScript types
│ └── index.ts # Main application entry point
├── package.json
├── tsconfig.json
└── DockerfileAPI Endpoints
Health
GET /api/v1/health- Health check endpoint
Skill
GET /api/v1/skill/:encoded- Generate Lando skill markdown from encoded subscription data
Subscription
GET /api/v1/subscription/status/:trackingId- Check subscription status- Query params:
userPublicKey(optional): User's public key for user-based lookupgatewayPublicKey(optional): Gateway's public key for gateway-based lookuptokenMint(optional): Token mint address
- Query params:
GET /api/v1/subscription/:trackingId- Get full subscription details- Query params:
userPublicKey(optional): User's public key for user-based lookupgatewayPublicKey(optional): Gateway's public key for gateway-based lookuptokenMint(optional): Token mint address
- Query params:
Development
Install Dependencies
cd api
pnpm installDevelopment Mode
pnpm devBuild
pnpm buildStart Server
pnpm startEnvironment Variables
PORT- Server port (default: 3002)SOLANA_RPC- Solana RPC URL (default: https://api.mainnet-beta.solana.com)
Microservice Splitting
The modular structure makes it easy to split individual APIs into separate projects:
- Each route module (
src/routes/*.ts) is self-contained - Services and types can be extracted into shared packages
- Middleware can be reused across services
- Each endpoint can be deployed independently
Example: To split /api/v1/subscription into a separate service:
- Copy
src/routes/subscription.tsto new project - Copy required services (
src/services/subscription.ts,src/services/solana.ts) - Copy types (
src/types/index.ts) - Copy middleware (
src/middleware/*) - Adjust imports and deploy
License
MIT
