mirror of
				https://github.com/public-transport/db-vendo-client.git
				synced 2025-11-04 01:56:33 +02:00 
			
		
		
		
	make dbnav default for docker image, require setting of user agent
This commit is contained in:
		
							parent
							
								
									126077582b
								
							
						
					
					
						commit
						8d07b24604
					
				
					 6 changed files with 18 additions and 8 deletions
				
			
		| 
						 | 
					@ -1 +1 @@
 | 
				
			||||||
/docs/dumps
 | 
					/docs/dumps/
 | 
				
			||||||
							
								
								
									
										9
									
								
								api.js
									
										
									
									
									
								
							
							
						
						
									
										9
									
								
								api.js
									
										
									
									
									
								
							| 
						 | 
					@ -1,5 +1,6 @@
 | 
				
			||||||
import {createClient} from './index.js';
 | 
					import {createClient} from './index.js';
 | 
				
			||||||
import {profile as dbProfile} from './p/db/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 {createHafasRestApi as createApi} from 'hafas-rest-api';
 | 
				
			||||||
import {loyaltyCardParser} from 'db-rest/lib/loyalty-cards.js';
 | 
					import {loyaltyCardParser} from 'db-rest/lib/loyalty-cards.js';
 | 
				
			||||||
import {parseBoolean, parseInteger} from 'hafas-rest-api/lib/parse.js';
 | 
					import {parseBoolean, parseInteger} from 'hafas-rest-api/lib/parse.js';
 | 
				
			||||||
| 
						 | 
					@ -33,7 +34,7 @@ const config = {
 | 
				
			||||||
	name: 'db-vendo-client',
 | 
						name: 'db-vendo-client',
 | 
				
			||||||
	description: 'db-vendo-client',
 | 
						description: 'db-vendo-client',
 | 
				
			||||||
	homepage: 'https://github.com/public-transport/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',
 | 
						docsLink: 'https://github.com/public-transport/db-vendo-client',
 | 
				
			||||||
	openapiSpec: true,
 | 
						openapiSpec: true,
 | 
				
			||||||
	logging: true,
 | 
						logging: true,
 | 
				
			||||||
| 
						 | 
					@ -46,7 +47,11 @@ const config = {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const start = async () => {
 | 
					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);
 | 
						const api = await createApi(vendo, config);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	api.listen(config.port, (err) => {
 | 
						api.listen(config.port, (err) => {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										1
									
								
								index.js
									
										
									
									
									
								
							
							
						
						
									
										1
									
								
								index.js
									
										
									
									
									
								
							| 
						 | 
					@ -10,6 +10,7 @@ const FORBIDDEN_USER_AGENTS = [
 | 
				
			||||||
	'my-awesome-program', // previously used in readme.md, p/*/readme.md & docs/*.md
 | 
						'my-awesome-program', // previously used in readme.md, p/*/readme.md & docs/*.md
 | 
				
			||||||
	'hafas-client-example', // previously used in p/*/example.js
 | 
						'hafas-client-example', // previously used in p/*/example.js
 | 
				
			||||||
	'link-to-your-project-or-email', // now used throughout
 | 
						'link-to-your-project-or-email', // now used throughout
 | 
				
			||||||
 | 
						'db-vendo-client',
 | 
				
			||||||
];
 | 
					];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const isNonEmptyString = str => 'string' === typeof str && str.length > 0;
 | 
					const isNonEmptyString = str => 'string' === typeof str && str.length > 0;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										4
									
								
								package-lock.json
									
										
									
										generated
									
									
									
								
							
							
						
						
									
										4
									
								
								package-lock.json
									
										
									
										generated
									
									
									
								
							| 
						 | 
					@ -1,12 +1,12 @@
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	"name": "db-vendo-client",
 | 
						"name": "db-vendo-client",
 | 
				
			||||||
	"version": "6.2.0",
 | 
						"version": "6.3.0",
 | 
				
			||||||
	"lockfileVersion": 3,
 | 
						"lockfileVersion": 3,
 | 
				
			||||||
	"requires": true,
 | 
						"requires": true,
 | 
				
			||||||
	"packages": {
 | 
						"packages": {
 | 
				
			||||||
		"": {
 | 
							"": {
 | 
				
			||||||
			"name": "db-vendo-client",
 | 
								"name": "db-vendo-client",
 | 
				
			||||||
			"version": "6.2.0",
 | 
								"version": "6.3.0",
 | 
				
			||||||
			"license": "ISC",
 | 
								"license": "ISC",
 | 
				
			||||||
			"dependencies": {
 | 
								"dependencies": {
 | 
				
			||||||
				"@derhuerst/br2nl": "^1.0.0",
 | 
									"@derhuerst/br2nl": "^1.0.0",
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,7 +1,7 @@
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	"name": "db-vendo-client",
 | 
						"name": "db-vendo-client",
 | 
				
			||||||
	"description": "Client for bahn.de public transport APIs.",
 | 
						"description": "Client for bahn.de public transport APIs.",
 | 
				
			||||||
	"version": "6.2.0",
 | 
						"version": "6.3.0",
 | 
				
			||||||
	"type": "module",
 | 
						"type": "module",
 | 
				
			||||||
	"main": "index.js",
 | 
						"main": "index.js",
 | 
				
			||||||
	"files": [
 | 
						"files": [
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -57,10 +57,14 @@ Use it as a dependency, e.g. just replacing [hafas-client](https://github.com/pu
 | 
				
			||||||
npm i db-vendo-client
 | 
					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). 
 | 
					There are [community-maintained TypeScript typings available as `@types/hafas-client`](https://www.npmjs.com/package/@types/hafas-client). 
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		
		Reference in a new issue