{"id":13573131,"url":"https://github.com/public-transport/hafas-rest-api","last_synced_at":"2025-04-04T11:31:16.654Z","repository":{"id":43012120,"uuid":"114441465","full_name":"public-transport/hafas-rest-api","owner":"public-transport","description":"Expose a HAFAS client via an HTTP REST API.","archived":false,"fork":false,"pushed_at":"2024-01-29T18:05:46.000Z","size":299,"stargazers_count":23,"open_issues_count":6,"forks_count":3,"subscribers_count":7,"default_branch":"master","last_synced_at":"2024-04-14T07:11:20.207Z","etag":null,"topics":["api","fptf","hafas","public-transport","transit"],"latest_commit_sha":null,"homepage":"https://github.com/public-transport/hafas-rest-api#hafas-rest-api","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/public-transport.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"license.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2017-12-16T07:09:12.000Z","updated_at":"2024-03-30T18:02:24.000Z","dependencies_parsed_at":"2024-02-16T07:46:39.236Z","dependency_job_id":null,"html_url":"https://github.com/public-transport/hafas-rest-api","commit_stats":{"total_commits":154,"total_committers":4,"mean_commits":38.5,"dds":"0.038961038961038974","last_synced_commit":"2550e4e63f9223f3a2087c8a5a8687f89cf942e4"},"previous_names":[],"tags_count":56,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/public-transport%2Fhafas-rest-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/public-transport%2Fhafas-rest-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/public-transport%2Fhafas-rest-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/public-transport%2Fhafas-rest-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/public-transport","download_url":"https://codeload.github.com/public-transport/hafas-rest-api/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247129633,"owners_count":20888433,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","fptf","hafas","public-transport","transit"],"created_at":"2024-08-01T15:00:30.326Z","updated_at":"2025-04-04T11:31:16.620Z","avatar_url":"https://github.com/public-transport.png","language":"JavaScript","funding_links":["https://github.com/sponsors/derhuerst"],"categories":["Uncategorized","Producing Data"],"sub_categories":["Uncategorized","Software for Creating APIs"],"readme":"# hafas-rest-api\n\n**Expose a [`hafas-client@6`](https://github.com/public-transport/hafas-client/tree/6) instance as an HTTP REST API.**\n\n[![npm version](https://img.shields.io/npm/v/hafas-rest-api.svg)](https://www.npmjs.com/package/hafas-rest-api)\n![ISC-licensed](https://img.shields.io/github/license/public-transport/hafas-rest-api.svg)\n[![support Jannis via GitHub Sponsors](https://img.shields.io/badge/support%20Jannis-donate-fa7664.svg)](https://github.com/sponsors/derhuerst)\n[![chat with Jannis on Twitter](https://img.shields.io/badge/chat%20with%20Jannis-on%20Twitter-1da1f2.svg)](https://twitter.com/derhuerst)\n\n\n## Installing\n\n```shell\nnpm install hafas-rest-api\n```\n\n\n## Usage\n\n```js\nimport {createClient as createHafas} from 'hafas-client'\nimport {profile as dbProfile} from 'hafas-client/p/db/index.js'\nimport {createHafasRestApi as createApi} from 'hafas-rest-api'\n\nconst config = {\n\thostname: 'example.org',\n\tname: 'my-hafas-rest-api',\n\thomepage: 'https://github.com/someone/my-hafas-rest-api',\n\tversion: '1.0.0',\n\taboutPage: false\n}\n\nconst hafas = createHafas(dbProfile, 'my-hafas-rest-api')\nconst api = await createApi(hafas, config)\n\napi.listen(3000, (err) =\u003e {\n\tif (err) console.error(err)\n})\n```\n\n### `config` keys\n\nkey | description | mandatory? | default value\n----|-------------|------------|--------------\n`hostname` | The public hostname of the API. | ✔︎ | –\n`name` | The name of the API. Used for the `X-Powered-By` header and the about page. | ✔︎ | –\n`description` | Used for the about page. | ✔︎ (with `aboutPage: true`) | –\n`docsLink` | Used for the about page. | ✔︎ (with `aboutPage: true`) | –\n`cors` | Enable [CORS](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS)? | ✗ | `true`\n`etags` | [Express config](https://expressjs.com/en/4x/api.html#etag.options.table) for [`ETag` headers](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/ETag) | ✗ | `weak`\n`handleErrors` | Handle errors by sending `5**` codes and JSON. | ✗ | `true`\n`logging` | Log requests using [`pino`](https://npmjs.com/package/pino)? | ✗ | `false`\n`healthCheck` | A function that returning [Promises](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/promise) that resolve with `true` (for healthy) or `false`. | ✗ | –\n`version` | Used for the `X-Powered-By` and `X-API-Version` headers. | ✗ | –\n`homepage` | Used for the `X-Powered-By` header. | ✗ | –\n`aboutPage` | Enable the about page on `GET /`? | ✗ | `true`\n`openapiSpec` | Generate and serve an [OpenAPI spec](https://en.wikipedia.org/wiki/OpenAPI_Specification) of the API? | ✗ | `false`\n`addHafasOpts` | Computes additional `hafas-client` opts. `(opt, hafasClientMethod, httpReq) =\u003e additionaOpts` | ✗ | –\n`modifyRoutes` | Extend or modify the [default routes](routes/index.js). | ✗ | `routes =\u003e routes`\n\n*Pro Tip:* Use [`hafas-client-health-check`](https://github.com/public-transport/hafas-client-health-check) for `config.healthCheck`.\n\n\n## Contributing\n\nIf you have a question or have difficulties using `hafas-rest-api`, please double-check your code and setup first. If you think you have found a bug or want to propose a feature, refer to [the issues page](https://github.com/public-transport/hafas-rest-api/issues).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpublic-transport%2Fhafas-rest-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpublic-transport%2Fhafas-rest-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpublic-transport%2Fhafas-rest-api/lists"}