Skip to content

brunopenso/multi-integration-library

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

86 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Node js module to create multi integration to run on kubernets, google cloud functions, aws lambda and express for local testing

Resources

License

Stars

Watchers

Forks

Packages

No packages published