Giter VIP home page Giter VIP logo

multi-integration-library's Introduction

multi-integration

Quality Gate Status Bugs Code Smells Coverage

Node.js module to create multi integration code that will run on some providers, for local or remote environments.

Providers

  • Express.js
  • fastify - Doing
  • Google Cloud Run - Done
  • Aws Lambda - Wait List

How it Works?

This lib basic enable the creation of routes that will be interpreted on the entry point of each technology.

The structure is:

const routes = [
    {
        "pattern": "/path",
        "method": "get",
        "exec": (params) => fPath(params)
    },
    {
        "pattern": "/queryParam",
        "method": "get",
        "exec": (params) => fQueryString(params)
    },
    {
        "pattern": "/pathParam/:x/value/:y",
        "method": "get",
        "exec": (params) => fParams(params)
    },
    {
        "pattern": "/a/b/c/d/ee/ff/zz",
        "method": "get",
        "exec": (params) => fCompletePathparams)
    }
]

The params parameter have this properties:

  {
    "path": "url",
    "method": "http method",
    "queryString": "object with all query string values",
    "body": "body json message",
    "headers": "object with all headers",
    "pathParamsAttr": "object with all path params according to the route defined"
  }

All exec functions should be async.

Behaviour

When you define the routes, the paths will be interpreted in the order of declaration and it will execute the function associated to the exec property.

Have a look to the multi-integration-library-test on how to implement a multi technology integration that will enable you to port your code from local to any providers without changing any code.

Local testing

To test in a local environment you need to make this module available for other projects in your machine.

Execute this steps:

cd multi-integration-library
npm link

In the multi-integration-library-test:

cd multi-integration-library-test
npm link multi-integration-library

History

I decided to create this lib to make my tests, POCs and POAs easier to run.

In March 2021, I came across to this text from infoq that is related to my idea

How to publish new version to NPM

  1. Change package.json version
  2. Commit and wait the CI to finish
  3. Create a release on github interface
  4. Wait for the CD to finish
  5. Check npmjs.com for the package

multi-integration-library's People

Contributors

brunopenso avatar dependabot[bot] avatar

Watchers

James Cloos avatar  avatar

multi-integration-library's Issues

Wrong log error message

When informing a http method in lower case in the routes this error cames up

...../node_modules/multi-integration-library/src/runtime.js:154
throw new Error(The only methods supported are ${methods})

${methods} should return with all method available

Make error clear

When defining a invalid path like /test/{id} this error occurs Error: Pattern should be a string in the pattern /path/path2/:param

The message is not clear, that for using parameters it should use the :something

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.