refacator: read configuration from env variables

This commit is contained in:
Rainer Killinger
2021-09-07 10:20:06 +02:00
parent 581e60267d
commit 377435f3eb
2 changed files with 37 additions and 11 deletions

View File

@@ -1,23 +1,34 @@
# minimal-connector
## Prerequisites
* `node` and `npm` installed
* a backend, which is running locally (on http://localhost:3000)
* a backend, which is running locally (e.g. on http://localhost:3000)
## How to get started
To install all required `npm` packages:
```shell script
npm install
```
To prepare the script to be executed, run:
```shell script
npm run build
```
To start the plugin, you need to execute the code in "CLI" script:
```shell script
node lib/cli.js run <backendURL> <pluginName> <routeName> <URL> <port>
e.g.:
With fallback values being:
node lib/cli.js run http://localhost:3000 minimal-plugin minimalPlugin http://localhost 4000
```
## Creating your own plugin
* Modify the default values in `cli.ts` to your needs:
* update the name
* update the port
@@ -27,8 +38,11 @@ node lib/cli.js run http://localhost:3000 minimal-plugin minimalPlugin http://lo
* Delete the `sum` function in `minimal-plugin.ts` and write your own logic inside the `onRouteInvoke` function
* Define the layout of your http requests and responses inside the `/plugin/protocol` folder. The names of the interfaces
need to be the same as the request and response names you defined in the `cli.ts`
## Code structure
Folder `src` contains:
* Reference implementations for CLI and a plugin
* [/cli.ts](src/cli.ts)
* minimal CLI to start your connector, that uses CLI-args, so that there are no hard coded values for configuration