Skip to content

Commit

Permalink
make dbnav default for docker image, require setting of user agent
Browse files Browse the repository at this point in the history
  • Loading branch information
traines-source committed Jan 9, 2025
1 parent 1260775 commit 8d07b24
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .npmignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
/docs/dumps
/docs/dumps/
9 changes: 7 additions & 2 deletions api.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {createClient} from './index.js';
import {profile as dbProfile} from './p/db/index.js';
import {profile as dbnavProfile} from './p/dbnav/index.js';
import {createHafasRestApi as createApi} from 'hafas-rest-api';
import {loyaltyCardParser} from 'db-rest/lib/loyalty-cards.js';
import {parseBoolean, parseInteger} from 'hafas-rest-api/lib/parse.js';
Expand Down Expand Up @@ -33,7 +34,7 @@ const config = {
name: 'db-vendo-client',
description: 'db-vendo-client',
homepage: 'https://github.com/public-transport/db-vendo-client',
version: '6.2.0',
version: '6.3.0',
docsLink: 'https://github.com/public-transport/db-vendo-client',
openapiSpec: true,
logging: true,
Expand All @@ -46,7 +47,11 @@ const config = {


const start = async () => {
const vendo = createClient(dbProfile, process.env.USER_AGENT || process.env.HOSTNAME || 'link-to-your-project-or-email', config);
const vendo = createClient(
process.env.DB_PROFILE == 'db' ? dbProfile : dbnavProfile,
process.env.USER_AGENT || 'link-to-your-project-or-email',
config,
);
const api = await createApi(vendo, config);

api.listen(config.port, (err) => {
Expand Down
1 change: 1 addition & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const FORBIDDEN_USER_AGENTS = [
'my-awesome-program', // previously used in readme.md, p/*/readme.md & docs/*.md
'hafas-client-example', // previously used in p/*/example.js
'link-to-your-project-or-email', // now used throughout
'db-vendo-client',
];

const isNonEmptyString = str => 'string' === typeof str && str.length > 0;
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "db-vendo-client",
"description": "Client for bahn.de public transport APIs.",
"version": "6.2.0",
"version": "6.3.0",
"type": "module",
"main": "index.js",
"files": [
Expand Down
8 changes: 6 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,14 @@ Use it as a dependency, e.g. just replacing [hafas-client](https://github.com/pu
npm i db-vendo-client
```

See an example in [api.js](api.js). It shows how you can use `db-vendo-client` together with [hafas-rest-api](https://github.com/public-transport/hafas-rest-api/) in order to run a [FPTF](https://github.com/public-transport/friendly-public-transport-format) API server. The [Dockerfile](Dockerfile) serves this API (using the `db` profile):
See an example in [api.js](api.js). It shows how you can use `db-vendo-client` together with [hafas-rest-api](https://github.com/public-transport/hafas-rest-api/) in order to run a [FPTF](https://github.com/public-transport/friendly-public-transport-format) API server. The [Dockerfile](Dockerfile) serves this API (using the `dbnav` profile):

```
docker run -e USER_AGENT=my-awesome-program -p 3000:3000 ghcr.io/public-transport/db-vendo-client
docker run \
-e USER_AGENT=my-awesome-program \
-e DB_PROFILE=dbnav \
-p 3000:3000 \
ghcr.io/public-transport/db-vendo-client
```

There are [community-maintained TypeScript typings available as `@types/hafas-client`](https://www.npmjs.com/package/@types/hafas-client).
Expand Down

0 comments on commit 8d07b24

Please sign in to comment.