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.hello
action.call greeter.welcome --name John
- Call thegreeter.welcome
action with thename
parameter.call "webhooks.trigger" --ipadr "192.12.445.55"
- Call thewebhooks.trigger
action with theipadr
parameter.
- 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-Microservice
To start locally, you need to running a MongoDB server on localhost.
npm install
npm start
Open 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:up
Open the http://docker-machine:3000/ URL in your browser.
Running MongoDB is required on localhost!
npm run dev
Basic 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
docs
folder -
Start Service
npm run dev
Start 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
docs
folder -
Start Service
npm run dc:up
NOTE: 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
hello
andwelcome
actions. - 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 :
/register
add new webhooks - Read :
/list
list registerd webhooks - Update :
/update
update registerd webhook - Delete :
/delete
delete registerd webhook
- Create :
- Trigger :
/ip
initate requests to all registerd webhooks- Calls the
trigger
action 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 (setSERVICES
env variable to load certain services)npm run cli
: Start a CLI and connect to production. Don't forget to set production namespace with--ns
argument in scriptnpm run lint
: Run ESLintnpm run ci
: Run continuous test mode with watchingnpm test
: Run tests & generate coverage report