Creating triggers
**Guide to Contributing Triggers in Blok **
Note: Make sure you follow the recommendations on how to set up local environment and steps to complete before committing your changes. To learn more visit
Triggers in nanoservice-ts allow workflows to be executed automatically in response to specific events. This guide provides an overview of how to create, test, and contribute new triggers to the framework.
What Are Triggers?
Triggers define when and how a workflow starts. They listen for external or internal events, such as:
- HTTP Requests (e.g., API calls)
- Scheduled Events (e.g., cron jobs)
- Database Changes (e.g., new records in Postgres)
- Queue Messages (e.g., Kafka, RabbitMQ events)
- Custom Events (e.g., user-defined triggers)
Triggers are stored in the /triggers directory and are configurable via CLI.
Getting Started
Clone the repository and navigate to the triggers directory:
git clone https://github.com/deskree-inc/nanoservice-ts.git
cd triggers
npm installAdding a New Trigger
- Create a new directory in
/triggers - Use
http-triggeras a template or build your own - Make sure you are using the TriggerBase class as the base class
- Document your code, create interface definitions, and make sure you follow ESlint rules
- Make sure you have tests for your trigger and you achieve full coverage after running
pnpm test
Submitting a Pull Request
- Follow Branch Naming Convention
git checkout -b feature/add-my-new-trigger - Ensure Code Quality
npm run lint npm test - Submit a PR with:
- A clear description of the trigger.
- Tests and configuration examples.
- Proper documentation updates.
Best Practices
✅ Keep triggers modular and lightweight.
✅ Ensure proper error handling and logging.
✅ Write clear documentation and tests.
✅ Follow the project's TypeScript style guide.
Final Notes
Triggers are a key part of automation in nanoservice-ts. By contributing new triggers, you help expand the framework’s capabilities and enable more use cases. If you have any questions, open an issue or join the discussion! 🚀