Skip to content

This is a Implementation Webhooks Service using Moleculer ( Progressive microservices framework for Node.js. ) and Express ( Back-End for Node.js )

Notifications You must be signed in to change notification settings

Swarag-N/Webhooks-Microservice

Repository files navigation

Webhooks Microservice API


Webhooks Microservice API


WebHooks Microservice. Built with NodeJs

NodeJS     Moleculer     Docker

Table of Contents

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 the greeter.hello action.
  • call greeter.welcome --name John - Call the greeter.welcome action with the name parameter.
  • call "webhooks.trigger" --ipadr "192.12.445.55" - Call the webhooks.trigger action with the ipadr parameter.

Features

  • Register, Update, Delete, and List Web-Hooks
  • URL Validation on Web-Hooks
    • on Register
    • on Update
  • Concurrent Requests

Architecture

Webhooks Microservice Architecture

Usage Instructions

This is a Moleculer-based microservices project. Generated with the Moleculer CLI.

Moleculer

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

Check Routes

Locally

  • Install Dependencies (Dev and Production)
npm ci     
  • Start Target Servers : 5 Http Servers will Start
    1. PORT [4000 ... 4004]
    2. Logs the request
    3. 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  │
└───────────┴─────────────────┘

Docker Service

  • 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

Tasks

  • Collect Info
    • Molecular
  • Understand Problem Statement
  • Development
  • DB Seed
  • Add WebHook Servers

Development

Two Servers

  1. Microservice App to Store and Trigger WebHooks
  2. Web-Hooks Receiver

1. Product

  1. API Gateway
  2. DB
  3. Message Broker
  4. Web-Hook Trigger Initiator

2. Helper (Tester|Target)

  • Listens for Requests

Product

  • api: API Gateway services
  • greeter: Sample service with hello and welcome actions.
  • 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 : /register add new webhooks
      • Read : /list list registerd webhooks
      • Update : /update update registerd webhook
      • Delete : /delete delete registerd webhook
    • Trigger : /ip initate requests to all registerd webhooks
      • Calls the trigger action exposed by the webhooks microservice.
  • 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

Actions of Webhooks Microservice API

Resources

An Introduction to Moleculer JS

moleculerjs/moleculer-examples

What are webhooks?

Useful links

NPM scripts

  • npm run dev: Start development mode (load all services locally with hot-reload & REPL)
  • npm run start: Start production mode (set SERVICES 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 script
  • npm run lint: Run ESLint
  • npm run ci: Run continuous test mode with watching
  • npm test: Run tests & generate coverage report

About

This is a Implementation Webhooks Service using Moleculer ( Progressive microservices framework for Node.js. ) and Express ( Back-End for Node.js )

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages