- download and install Docker Desktop
- download and install Node JS
- Optional: install the npm package
typescript
globally to use thetsc
command without thenpx
prefix - Optional: install the VS Code extension Tasks
- Optional: restarting the Connector using the VSCode task
More Tasks > Restart
requires the tool socat. Make sure to install it on your system. This can be done for example usingapt-get install socat
on Ubuntu andbrew install socat
using Homebrew. - run
npm i
To configure the Connector for development you have to create an
.env
file in the.dev
folder.You can use the
.env.example
file as a template. The file can be named anything you want (it should be prefixed with.env
), but we recommend to use.env
as the name. If you want to use multiple.env
files 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-1
To 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 1
orRun 2
and 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-1
docker 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 1
orAttach to Connector 2
and 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/runtime
Afterwards 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
/.zshrc
or in the Windows environment variables.
To start a local backbone, execute the following command:
npm run start:backbone
Set 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
/.zshrc
or in the Windows environment variables.
To test the productive image you can use docker compose -f .dev/compose.prodtest.yml --env-file .dev/compose.backbone.env
.
For example to start the compose you can run it like
docker compose -f .dev/compose.prodtest.yml --env-file .dev/compose.backbone.env up --build -d
or to take it down again
docker compose -f .dev/compose.prodtest.yml --env-file .dev/compose.backbone.env 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:local
If 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": { "apiKey": "<api-key-or-empty-string>", "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 --workspaces
to build the changes for the Connector and its packages
The SDK is published, when you merge the project to main while having changed the package version.