WebHooks Microservice. Built with NodeJs
- Introduction
- Features
- Architecture
- Usage Instructions
- Check Routes
- Tasks
- Development
- Product
- NPM scripts
This is a Implementation Webhooks Service using Moleculer ( Progressive microservices framework for Node.js. ) and Express ( Back-End for Node.js )
In the terminal, try the following commands:
nodes- List all connected nodes.actions- List all registered service actions.call greeter.hello- Call thegreeter.helloaction.call greeter.welcome --name John- Call thegreeter.welcomeaction with thenameparameter.call "webhooks.trigger" --ipadr "192.12.445.55"- Call thewebhooks.triggeraction with theipadrparameter.
- Register, Update, Delete, and List Web-Hooks
- URL Validation on Web-Hooks
- on Register
- on Update
- Concurrent Requests
This is a Moleculer-based microservices project. Generated with the Moleculer CLI.
git clone https://github.com/Swarag-N/Webhooks-Microservice.git
cd Webhooks-MicroserviceTo start locally, you need to running a MongoDB server on localhost.
npm install
npm startOpen the http://localhost:3000/ URL in your browser.
Running as microservices All services are running in separated containers, communicate via NATS & use Traefik reverse proxy.
npm run dc:upOpen the http://docker-machine:3000/ URL in your browser.
Running MongoDB is required on localhost!
npm run devBasic HTTP Servers to capture the response
npm run targets- Open the http://localhost:4000/ URL in your browser.
- Open the http://localhost:4001/ URL in your browser.
- Open the http://localhost:4002/ URL in your browser.
- Open the http://localhost:4003/ URL in your browser.
- Open the http://localhost:4004/ URL in your browser.
- Install Dependencies (Dev and Production)
npm ci - Start Target Servers : 5 Http Servers will Start
- PORT [4000 ... 4004]
- Logs the request
- Health Check
http://localhost:4000/
npm run targets -
Import Postman collections of API Service from
docsfolder -
Start Service
npm run devStart the project with npm run dev command.
After starting, open the http://localhost:3000/list URL in your browser.
call "webhooks.trigger" --ipadr "192.12.445.55" - Call the webhooks.trigger action with the ipadr parameter
o/p
┌───────────┬─────────────────┐
│ (index) │ Values │
├───────────┼─────────────────┤
│ ipadr │ '192.12.445.55' │
│ timeStamp │ 1626537496624 │
└───────────┴─────────────────┘
┌───────────┬─────────────────┐
│ (index) │ Values │
├───────────┼─────────────────┤
│ ipadr │ '192.12.445.55' │
│ timeStamp │ 1626537496624 │
└───────────┴─────────────────┘-
Import Postman collections of API Service from
docsfolder -
Start Service
npm run dc:upNOTE: Local Network is different from Internal Network, give external sites as Input
- Collect Info
- Molecular
- Understand Problem Statement
- Development
- DB Seed
- Add WebHook Servers
Two Servers
- Microservice App to Store and Trigger WebHooks
- Web-Hooks Receiver
- API Gateway
- DB
- Message Broker
- Web-Hook Trigger Initiator
- Listens for Requests
- api: API Gateway services
- greeter: Sample service with
helloandwelcomeactions. - webhooks: Service with actions to register and create triggers on webHooks.
Microservice using Moleculer Framework with a Backend using Express framework implemneted Webhooks funtionality.
Check docs\demo.md for API response for bellow EndPoints
-
API Service- Routes
admin- Create :
/registeradd new webhooks - Read :
/listlist registerd webhooks - Update :
/updateupdate registerd webhook - Delete :
/deletedelete registerd webhook
- Create :
- Trigger :
/ipinitate requests to all registerd webhooks- Calls the
triggeraction exposed by thewebhooks microservice.
- Calls the
- Routes
-
webhooks microservice- Actions
-
webhooks.register- URL Validation before registering Webhook
-
webhooks.list -
webhooks.update- URL Validation before updating Webhook
-
webhooks.delete -
webhooks.trigger- Initate requests concurrently in batches
-
- Actions
An Introduction to Moleculer JS
moleculerjs/moleculer-examples
- Moleculer website: https://moleculer.services/
- Moleculer Documentation: https://moleculer.services/docs/0.14/
npm run dev: Start development mode (load all services locally with hot-reload & REPL)npm run start: Start production mode (setSERVICESenv variable to load certain services)npm run cli: Start a CLI and connect to production. Don't forget to set production namespace with--nsargument in scriptnpm run lint: Run ESLintnpm run ci: Run continuous test mode with watchingnpm test: Run tests & generate coverage report