All Projects → dimapaloskin → micro-chain

dimapaloskin / micro-chain

Licence: other
🤝 Helps to build chains from your micro services.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to micro-chain

Micro
Asynchronous HTTP microservices
Stars: ✭ 9,987 (+41512.5%)
Mutual labels:  micro, await
Micro Router
🚉 A tiny and functional router for Zeit's Micro
Stars: ✭ 621 (+2487.5%)
Mutual labels:  micro, await
Qian
A minimalist file-explorer using Electron via Elm !
Stars: ✭ 198 (+725%)
Mutual labels:  micro
dockerpkg-example
Example app running in small docker container using dockerpkg
Stars: ✭ 54 (+125%)
Mutual labels:  micro
tcl-modules
A collection of pure Tcl, production-ready micro packages
Stars: ✭ 25 (+4.17%)
Mutual labels:  micro
prismy
🌈 Simple and fast type safe server library for now.sh v2 and API routes of next.js.
Stars: ✭ 46 (+91.67%)
Mutual labels:  micro
Mvvmicro
Minimalist MVVM framework for .NET.
Stars: ✭ 22 (-8.33%)
Mutual labels:  micro
Go Os
Stars: ✭ 185 (+670.83%)
Mutual labels:  micro
micro-starter
Micro 微服务实践
Stars: ✭ 391 (+1529.17%)
Mutual labels:  micro
m.test
m(icro)test is a lightweight test runner for node.js written in es6+
Stars: ✭ 17 (-29.17%)
Mutual labels:  micro
micro-query
Simple query string parser for Vercel's Micro
Stars: ✭ 23 (-4.17%)
Mutual labels:  micro
s3-example
Simple example using micro for uploading stuff to AWS S3.
Stars: ✭ 45 (+87.5%)
Mutual labels:  micro
micro-superstruct
A Superstruct wrapper for Micro to validate your request body and query parameters
Stars: ✭ 15 (-37.5%)
Mutual labels:  micro
try-to-catch
functional try-catch wrapper for promises
Stars: ✭ 30 (+25%)
Mutual labels:  await
Reshader
A micro, highly-customisable JavaScript library to get shades of colors
Stars: ✭ 214 (+791.67%)
Mutual labels:  micro
micro-cacheable
A micro utility for data caching
Stars: ✭ 35 (+45.83%)
Mutual labels:  micro
Unfurl
Scraper for oEmbed, Twitter Cards and Open Graph metadata - fast and Promise-based ⚡️
Stars: ✭ 193 (+704.17%)
Mutual labels:  micro
ember-await
Await component for Ember Applications. Resolve your data on demand, just when needed.
Stars: ✭ 54 (+125%)
Mutual labels:  await
micro
abp+micro+typescript+vue+element
Stars: ✭ 92 (+283.33%)
Mutual labels:  micro
do
Simplest way to manage asynchronicity
Stars: ✭ 33 (+37.5%)
Mutual labels:  await

micro-chain

Helps to build chains from your micro services.

XO code style Build Status Greenkeeper badge

Overview

Module provides simple ability to build chains like:

first.api.your-domain.com
  -> second.api.your-domain.com
    -> third.api.your-domain.com
      -> final.api.your-domain.com

Install

npm install --save micro-chain

Example

index.js

  const chain = require('micro-chain');
  
  const options = {
    micro: 'app.js', // or just your micro async function required before
    location: /\/some-path$/, // optional. chain will be executed only if request url matched
    chain: [{
      target: 'account.api.your-domain.com',
      mergeJson: true // response json will be merged with
                      // request json and will be passed down the chain
     }, {
      target: 'storage.api.your-domain.com/s3/save',
      mergeJson: true,
      allowedStatuses: [200, 201], // array of allowed statuses. 
                                   // request will rejected if target's response has not included status
                                   // rejected response will be equal target's response

      // transformRequestBody will modify request data and return result if declared
      // receive Buffer
      transformRequestBody: body => {
        if (!body || !body.length) return body;
        body = JSON.parse(body);
        delete body.secret;
        return body;
      },

      // transformReponseBody will modify response body if declared
      // receive Buffer
      transformReponseBody: body => {
        if (!body || !body.length) return body;
        body = JSON.parse(body);
        body.newProp = true;
        delete body.token;
        return body;
      }
     }, {
       // if host is not declared will extract host from original request
       target: '/notify'
     }, {
       target: 'some-stuff.api.your-domain.com',
       sendOriginalBody: true // modifed body passed down the chain.
                              // use this option if you want send original data
     }]
  };
  
  module.exports = chain(options);

Run:

micro index.js

See in action

Clone this repo

Install dependencies

npm install

Build project

npm run build

Run npm start

Make POST request

curl http://localhost:3000/public -XPOST -d '{"what": "you want", "message": "ping"}'

Author

Dmitry Pavlovsky

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].