Skip to content

Commit

Permalink
[email protected], make --their-leitstelle/$VDV_453_THEIR_…
Browse files Browse the repository at this point in the history
…LEITSTELLE mandatory 💥📝
  • Loading branch information
derhuerst committed Oct 4, 2024
1 parent 55eea17 commit ee1c9b9
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 5 deletions.
14 changes: 14 additions & 0 deletions cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ const {
type: 'string',
short: 'l',
},
'their-leitstelle': {
type: 'string',
short: 'L',
},
'endpoint': {
type: 'string',
short: 'e',
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -37,6 +39,7 @@ const sendVdv453DataToNats = async (cfg, opt = {}) => {
const client = createClient({
...vdv453ClientOpts,
leitstelle,
theirLeitstelle,
endpoint,
})
const {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
13 changes: 9 additions & 4 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 ''
```


Expand All @@ -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
Expand Down

0 comments on commit ee1c9b9

Please sign in to comment.