diff --git a/cli.js b/cli.js index 6ff38d0..e94fedd 100755 --- a/cli.js +++ b/cli.js @@ -26,6 +26,10 @@ const { type: 'string', short: 'l', }, + 'their-leitstelle': { + type: 'string', + short: 'L', + }, 'endpoint': { type: 'string', short: 'e', @@ -62,6 +66,9 @@ Options: client, a bit like an HTTP User-Agent. Must be agreed- upon with the provider of the VDV-453 API. Default: $VDV_453_LEITSTELLE + --their-leitstelle -L VDV-453 Leitstellenkennung of the server. Must be agreed- + upon with the provider of the VDV-453 API. + Default: $VDV_453_THEIR_LEITSTELLE --endpoint -e HTTP(S) URL of the VDV-453 API. Default: $VDV_453_ENDPOINT --port -p Port to listen on. VDV-453 requires the *client* to run @@ -123,6 +130,13 @@ if ('leitstelle' in flags) { } else { abortWithError('missing/empty --leitstelle/-l/$VDV_453_LEITSTELLE') } +if ('their-leitstelle' in flags) { + cfg.theirLeitstelle = flags['their-leitstelle'] +} else if ('VDV_453_THEIR_LEITSTELLE' in process.env) { + cfg.theirLeitstelle = process.env.VDV_453_THEIR_LEITSTELLE +} else { + abortWithError('missing/empty --their-leitstelle/-L/$VDV_453_THEIR_LEITSTELLE') +} if ('endpoint' in flags) { cfg.endpoint = flags.endpoint diff --git a/index.js b/index.js index 0c656bd..b47ed9c 100644 --- a/index.js +++ b/index.js @@ -6,11 +6,13 @@ import {connectToNats, JSONCodec} from './lib/nats.js' const sendVdv453DataToNats = async (cfg, opt = {}) => { const { leitstelle, + theirLeitstelle, endpoint, port, subscriptions, } = cfg ok(leitstelle, 'missing/empty cfg.leitstelle') + ok(theirLeitstelle, 'missing/empty cfg.theirLeitstelle') ok(endpoint, 'missing/empty cfg.endpoint') ok(Number.isInteger(port), 'cfg.port must be an integer') ok(Array.isArray(subscriptions), 'cfg.subscriptions must be an array') @@ -37,6 +39,7 @@ const sendVdv453DataToNats = async (cfg, opt = {}) => { const client = createClient({ ...vdv453ClientOpts, leitstelle, + theirLeitstelle, endpoint, }) const { diff --git a/package.json b/package.json index a9b43be..6745e78 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "dependencies": { "luxon": "^3.4.4", "nats": "^2.22.0", - "vdv-453-client": "^1.0.0" + "vdv-453-client": "^2.0.0-alpha.0" }, "devDependencies": { "@eslint/js": "^9.0.0", diff --git a/readme.md b/readme.md index f1110db..a2a9dca 100644 --- a/readme.md +++ b/readme.md @@ -20,20 +20,22 @@ Please note the limitations imposed by the underlying library [`vdv-453-client`] > > *Note:* This client supports neither the latest 2.x spec versions ([VDV-453 v2.6.1](https://www.vdv.de/vdv-schrift-453-v2.6.1-de.pdfx?forced=true)/[VDV-454 v2.2.1](https://www.vdv.de/454v2.2.1-sd.pdfx?forced=true)) nor the latest 3.x spec versions ([VDV-453 v3.0](https://www.vdv.de/downloads/4337/453v3.0%20SDS/forced)/[VDV-454 v3.0](https://www.vdv.de/downloads/4336/454v3.0%20SDS/forced)). -With the organisation providing the VDV 453 API, you will have to agree upon a *Leitstellenkennung*, which is a bit like an HTTP User-Agent: +With the organisation providing the VDV 453 API, you will have to agree upon a *Leitstellenkennung* you'll use, which is a bit like an HTTP User-Agent: > 6.1.3 Leitstellenkennung > > Um Botschaften verschiedener Kommunikationspartner innerhalb eines Dienstes unterscheiden zu können, enthält jede Nachricht eine eindeutige Leitstellenkennung (Attribut `Sender`) des nachfragenden Systems. […] -Then, configure access to the VDV-453 system and run the adapter: +Then, configure access to the VDV-453 system, and run the adapter: ```bash send-vdv-453-data-to-nats \ # must have a trailing `/` --endpoint 'http://example.org:1234/api/' \ - # as agreed-upon between the VDV-453 API's operator and you - --leitstelle '…' + # your Leitstellenkennung, as agreed-upon between the VDV-453 API's operator and you + --leitstelle '…' \ + # their Leitstellenkennung, as agreed-upon between the VDV-453 API's operator and you + --their-leitstelle '…' ``` @@ -50,6 +52,9 @@ Options: client, a bit like an HTTP User-Agent. Must be agreed- upon with the provider of the VDV-453 API. Default: $VDV_453_LEITSTELLE + --their-leitstelle -L VDV-453 Leitstellenkennung of the server. Must be agreed- + upon with the provider of the VDV-453 API. + Default: $VDV_453_THEIR_LEITSTELLE --endpoint -e HTTP(S) URL of the VDV-453 API. Default: $VDV_453_ENDPOINT --port -p Port to listen on. VDV-453 requires the *client* to run