Webhooks Microservice API
WebHooks Microservice. Built with NodeJs
   
   
Table of Contents
- Introduction
 - Features
 - Architecture
 - Usage Instructions
 - Check Routes
 - Tasks
 - Development
    
- 1. Product
 - 
        
[2. Helper (Tester Target)](#2-helper-testertarget)  
 - Product
 - NPM scripts
 
Introduction
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.
Features
- Register, Update, Delete, and List Web-Hooks
 - URL Validation on Web-Hooks
    
- on Register
 - on Update
 
 - Concurrent Requests
 
Architecture
Usage Instructions
This is a Moleculer-based microservices project. Generated with the Moleculer CLI.
Install
git clone https://github.com/Swarag-N/Webhooks-Microservice.git
cd Webhooks-Microservice
Start locally
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.
Start in Docker
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.
Development locally
Running MongoDB is required on localhost!
npm run dev
Target Server
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.
 
Check Routes
Locally
- 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 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  │
└───────────┴─────────────────┘
Docker Service
- 
    
Import Postman collections of API Service from
docsfolder - 
    
Start Service
 
npm run dc:up
NOTE: Local Network is different from Internal Network, give external sites as Input
Tasks
- Collect Info
    
- Molecular
 
 - Understand Problem Statement
 - Development
 - DB Seed
 - Add WebHook Servers
 
Development
Two Servers
- Microservice App to Store and Trigger WebHooks
 - Web-Hooks Receiver
 
1. Product
- API Gateway
 - DB
 - Message Broker
 - Web-Hook Trigger Initiator
 
2. Helper (Tester|Target)
- Listens for Requests
 
Product
- api: API Gateway services
 - greeter: Sample service with 
helloandwelcomeactions. - webhooks: Service with actions to register and create triggers on webHooks.
    
Services
 
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.listwebhooks.update- URL Validation before updating Webhook
 
webhooks.deletewebhooks.trigger- Initate requests concurrently in batches
 
 
- Actions
        
 
Actions
Resources
An Introduction to Moleculer JS
moleculerjs/moleculer-examples
Useful links
- Moleculer website: https://moleculer.services/
 - Moleculer Documentation: https://moleculer.services/docs/0.14/
 
NPM scripts
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