ts-downstream-boilerplate
v1.2.0
Published
A Node.js + TypeScript boilerplate for calling downstream APIs using Controller → Service → Adapter pattern with Circuit Breaker.
Downloads
87
Maintainers
Readme
ts-downstream-boilerplate
A Node.js + TypeScript boilerplate generator for creating downstream API applications using the Controller → Service → Adapter pattern with Circuit Breaker implementation.
Features
- 🏗️ Clean Architecture: Controller → Service → Adapter pattern
- 🔄 Circuit Breaker: Built-in fault tolerance for downstream API calls
- 🔒 TypeScript: Full TypeScript support with strict configuration
- 🚀 Express.js: Fast and minimal web framework
- 📦 Ready to use: Includes HTTP client and error handling
- 🎯 Template replacement: Automatically replaces
__APP_NAME__placeholders
Installation & Usage
Global Installation (Recommended)
npm install -g ts-downstream-boilerplateCreate a new project
# Using global installation
ts-downstream-boilerplate my-awesome-api
# Or using npx (no installation required)
npx ts-downstream-boilerplate my-awesome-apiSetup your new project
cd my-awesome-api
npm install
npm run devYour server will start on port 4001!
Generated Project Structure
my-awesome-api/
├── src/
│ ├── app.ts # Express app configuration
│ ├── server.ts # Server entry point
│ └── Api/
│ └── Resources/
│ └── User/
│ ├── User.Controller.ts # Request handling
│ ├── User.Router.ts # Route definitions
│ ├── User.Service.ts # Business logic
│ ├── Adapters/
│ │ └── ndml.adapter.ts # External API adapter
│ └── Integration/
│ ├── circuitBreaker.ts # Circuit breaker implementation
│ └── httpClient.ts # HTTP client wrapperAvailable Scripts
npm run dev- Start development server with hot reloadnpm run build- Build TypeScript to JavaScriptnpm start- Start production server
Environment Setup
The generated project includes a .env file template. Update it with your API endpoints:
NDML_BASE_URL=https://your-api.example.comArchitecture Pattern
This boilerplate implements a clean, scalable architecture:
- Controller: Handles HTTP requests/responses
- Service: Contains business logic
- Adapter: Manages external API communication
- Circuit Breaker: Provides fault tolerance
Contributing
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
License
ISC License - see LICENSE file for details
Author
Madhuri Badgujar
- Email: [email protected]
- GitHub: @madhubadgujar
