- download and install Docker Desktop
- download and install Node JS
- Optional: install the npm package
typescriptglobally to use thetsccommand without thenpxprefix - Optional: install the VS Code extension Tasks
- Optional: restarting the Connector using the VSCode task
More Tasks > Restartrequires the tool socat. Make sure to install it on your system. This can be done for example usingapt-get install socaton Ubuntu andbrew install socatusing Homebrew. - run
npm i - make sure to be logged in to
dhi.iocontainer registry usingdocker login dhi.io(you need a DockerHub personal access token as password)
To configure the Connector for development you have to create an
.envfile in the.devfolder.You can use the
.env.examplefile as a template. The file can be named anything you want (it should be prefixed with.env), but we recommend to use.envas the name. If you want to use multiple.envfiles for different environments, you can postfix the file name with the environment name (e.g..env.stage).
To run a single Connector instance, execute the following command:
docker compose -f .dev/compose.yml --env-file [path_to_your_env_file] up --build connector-1To run two Connector instances, execute the following command:
docker compose -f .dev/compose.yml --env-file [path_to_your_env_file] up --build connector-1 connector-2
⚠️ Replace[path_to_your_env_file]with e.g..dev/.env, depending on where your env file is located.
ℹ️ You can also use the VS Code task
Run 1orRun 2and configure the appropriate env file to start your Connector instances.
After a few seconds you should see the following output:
connector-1 | [2021-01-25T11:27:40.788] [INFO] Transport.Transport - Transport initialized
...
connector-1 | [2021-01-25T11:27:41.241] [INFO] HttpServerModule - Listening on port 80
...
connector-1 | [2021-01-25T11:27:41.241] [INFO] Runtime - Started all modules.You can access the Swagger UI of the Connector under http://localhost:3000/docs.
To use an local Backbone, that can be started with npm run start:backbone, you can use the .env.local in the .dev folder
docker compose -f .dev/compose.yml --env-file .env.local up --build connector-1docker compose -f .dev/compose.yml --env-file .env.local up --build connector-1 connector-2- Execute the VS Code task
Compile. This task executestsc -w(watches the code and compiles on change). - Run the Connector as described in the previous chapter.
- To attach the debugger, switch to the VS Code "Run" view, select the Run configuration
Attach to Connector 1orAttach to Connector 2and click the Run button.
If you're running on Linux (or wsl), every time you save a file, the server is restarted, as long as you don't cancel the Compile task.
If you're running on Windows you have to execute the Restart task after you saved a file. This is because when mounting a folder from the Windows file system into a Linux Docker container, the file system events are not being mapped properly.
To use a local Runtime you need to set the envvar $RUNTIME_PATH (e.g. inside a local .env file in the root folder of the project). The $RUNTIME_PATH needs to contain the path to the Runtime mono-repository root folder, either relative or absolute.
export RUNTIME_PATH=.../path/to/local/runtimeAfterwards you can run npm run link-runtime. This will copy the build result and sources from you local Runtime in you node_modules folder.
To use the npm version of the Runtime again you need to run npm run unlink-runtime this will restore the version in the package.json
Set the following environment variables:
- NMSHD_TEST_BASEURL (the Backbone baseUrl to test against)
- NMSHD_TEST_CLIENTID (the Backbone clientId for the configured baseUrl)
- NMSHD_TEST_CLIENTSECRET (the Backbone clientSecret for the configured baseUrl)
We recommend to persist these variables for example in your
.bashrc/.zshrcor in the Windows environment variables.
To start a local Backbone, execute the following command:
npm run start:backboneSet the following environment variables:
- NMSHD_TEST_BASEURL to
http://localhost:8090 - NMSHD_TEST_CLIENTID to
test - NMSHD_TEST_CLIENTSECRET to
test
We recommend to persist these variables for example in your
.bashrc/.zshrcor in the Windows environment variables.
To test the productive image you can use docker compose -f .dev/compose.prodtest.yml.
For example to start the compose you can run it like
docker compose -f .dev/compose.prodtest.yml up --build -d
or to take it down again
docker compose -f .dev/compose.prodtest.yml down
to check if the prod image still works you can run.
docker logs -f connector
to see the logs of the Connector.
Afterward you can use the connector-tui or an REST client to test the Connector.
npm run test:localIf you only want to run a single test suite you can use the following command:
npm run test:local -- testSuiteName-
clone this repository
git clone https://github.com/nmshd/connector.git -
change into the directory
cd connector -
install the npm dependencies
npm i -
build the Connector
npm run build -
create a config file (for example
local.config.json){ "debug": true, "transportLibrary": { "baseUrl": "<base-url>", "platformClientId": "<client-id>", "platformClientSecret": "<client-secret>" }, "database": { "driver": "lokijs", "folder": "./" }, "logging": { "categories": { "default": { "appenders": ["console"] } } }, "infrastructure": { "httpServer": { "authentication": { "apiKey": { "enabled": true, "keys": { "<an-api-key-name>": { "key": "<api-key>" } } } }, "port": 8080 } }, "modules": { "coreHttpApi": { "docs": { "enabled": true } } } } -
replace the placeholders in the config with real values
-
start the Connector using
CUSTOM_CONFIG_LOCATION=./local.config.json node dist/index.js start
It's now possible to access the Connector on port 8080. Validating this is possible by accessing http://localhost:8080/docs/swagger in the browser.
- run
npm ci(this will symlink the SDK in the node_modules of the Connector) - run
npm run build --workspacesto build the changes for the Connector and its packages