/webhooks-microservice-dyte

A Webhooks Microservice using Node and Moleculer

Primary LanguageJavaScript

Moleculer

Webhooks Microservice Logo

Webhooks Microservice

A Webhooks Microservice using Node and Moleculer


πŸ“– Table of Contents

Table of Contents
  1. ➀ About The Project
  2. ➀ Features
  3. ➀ Folder Structure
  4. ➀ Running Locally
  5. ➀ RESTful URLs
  6. ➀Requests and Responses
  7. ➀ Feedback

-----------------------------------------------------

πŸ“ About The Project

This is a Webhook Microservice project. Moleculer, a microservices framework, was used to create this microservice. The goal of this project is to create an API that allows many webhooks to be invoked at the same time.

-----------------------------------------------------

🍴 Features

The following are the features provided by this microservice:

  • Registers new target URL's into system
  • Lists out all the target URL's
  • Updates the specific target URL
  • Invokes all the target URL's parallely

-----------------------------------------------------

🌡 Folder Structure

└── webhooks-microservice-dyte/
    β”œβ”€β”€ data/
    β”‚   └── webhooks.db
    β”œβ”€β”€ mixins/
    β”‚   └── db.mixin.js
    β”œβ”€β”€ public/
    β”‚   └── index.html
    β”œβ”€β”€ services/
    β”‚   β”œβ”€β”€ api-service.js
    β”‚   └── webhooks.service.js
    β”œβ”€β”€ utils/
    β”‚   └── sendRequest.js
    β”œβ”€β”€ .dockerignore
    β”œβ”€β”€ .editorconfig
    β”œβ”€β”€ .eslintrc.js
    β”œβ”€β”€ .gitignore
    β”œβ”€β”€ docker-compose.env
    β”œβ”€β”€ docker-compose.yml
    β”œβ”€β”€ Dockerfile
    β”œβ”€β”€ k8s.yaml
    β”œβ”€β”€ moleculer.config.js
    β”œβ”€β”€ package-lock.json
    β”œβ”€β”€ package.json
    └── README.md

-----------------------------------------------------

πŸ’Ύ Running Locally

Make sure you have NodeJS and the Mongodb installed.

git clone https://github.com/SreemanthG/webhooks-microservice-dyte.git

cd webhooks-microservice-dyte

npm install

Development

npm run dev

Production

npm run start

Docker

docker-compose up

-----------------------------------------------------

🎯 RESTful URLs

Good URL examples

Bad URL examples


-----------------------------------------------------

πŸ”¨ Requests and Responses

API Resources

POST /register

Example: http://localhost:3000/api/webhooks/register

Request body(JSON):

  {
  
    "targetUrl":"http://www.google.com"
  
  }

Response body:

  {
    "_id": "iEKJVNnLPYGwPvVk"
  }

POST /list

Example: http://localhost:3000/api/webhooks/register

Request body(JSON):

  {}

Response body:

  {
    "rows": [
        {
            "_id": "iEKJVNnLPYGwPvVk",
            "targetUrl": "http://www.google.com/"
        }
    ]
    "total": 1,
    "page": 1,
    "pageSize": 10,
    "totalPages": 1
  }

PUT /update/:id

Example: http://localhost:3000/api/webhooks/update/JAP611ZUF0yaVaLt

Request body(JSON):

  {
    "newTargetUrl":"http://www.youtube.com"
  }

Response body:

  {
    "_id": "JAP611ZUF0yaVaLt",
    "targetUrl": "http://www.google.com/"
  }

GET /ip

Example: http://localhost:3000/api/webhooks/ip

Request body(JSON):

  {
    "ipAddress":"198.168.0.1"
  }

Response body:

  [
    {
        "targetUrl": "http://www.google.com/",
        "_id": "JAP611ZUF0yaVaLt",
        "status": 201,
        "retries": 0
    }
  ]

-----------------------------------------------------

πŸ’  Feedback

Feel free to send feedback on [Twitter](https://twitter.com/GSreemanth) or [file an issue](https://github.com/SreemanthG/webhooks-microservice-dyte/issues/new). Feature requests are always welcome. You can contact me at sreemanth2001@gmail.com