multi-integration
Node.js module to create multi integration code that will run on some providers, for local or remote environments.
Providers
- [x] Express.js
- [x] fastify - Doing
- [x] 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
- Change package.json version
- Commit and wait the CI to finish
- Create a release on github interface
- Wait for the CD to finish
- Check npmjs.com for the package