![Introducing Dashboard Analytics](https://cdn.sanity.io/images/cgdhsj6q/production/af327c5bd94708db501516a75da6870aef894c64-2286x1522.png?w=400&fit=max&auto=format)
Product
Introducing Dashboard Analytics
We're introducing a new Analytics feature in the Socket dashboard so you can view changes in your organization's and repositories' alerts over time.
hafas-rest-api
Advanced tools
Expose a hafas-client@6
instance as an HTTP REST API.
npm install hafas-rest-api
import {createClient as createHafas} from 'hafas-client'
import {profile as dbProfile} from 'hafas-client/p/db/index.js'
import {createHafasRestApi as createApi} from 'hafas-rest-api'
const config = {
hostname: 'example.org',
name: 'my-hafas-rest-api',
homepage: 'https://github.com/someone/my-hafas-rest-api',
version: '1.0.0',
aboutPage: false
}
const hafas = createHafas(dbProfile, 'my-hafas-rest-api')
const api = await createApi(hafas, config)
api.listen(3000, (err) => {
if (err) console.error(err)
})
config
keyskey | description | mandatory? | default value |
---|---|---|---|
hostname | The public hostname of the API. | ✔︎ | os.hostname() |
name | The name of the API. Used for the X-Powered-By header and the about page. | ✔︎ | – |
description | Used for the about page. | ✔︎ (with aboutPage: true ) | – |
docsLink | Used for the about page. | ✔︎ (with aboutPage: true ) | – |
cors | Enable CORS? | ✗ | true |
etags | Express config for ETag headers | ✗ | weak |
csp | The Content Security Policy (CSP) sent as an HTTP header | ✗ | default-src 'none' |
handleErrors | Handle errors by sending 5** codes and JSON. | ✗ | true |
logging | Log requests using pino ? | ✗ | false |
healthCheck | A function that returning Promises that resolve with true (for healthy) or false . | ✗ | – |
version | Used for the X-Powered-By and X-API-Version headers. | ✗ | – |
homepage | Used for the X-Powered-By header. | ✗ | – |
aboutPage | Enable the about page on GET / ? | ✗ | true |
openapiSpec | Generate and serve an OpenAPI spec of the API? | ✗ | false |
addHafasOpts | Computes additional hafas-client opts. (opt, hafasClientMethod, httpReq) => additionaOpts | ✗ | – |
modifyRoutes | Extend or modify the default routes. | ✗ | routes => routes |
Pro Tip: Use hafas-client-health-check
for config.healthCheck
.
If 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.
FAQs
Expose a HAFAS client via an HTTP REST API.
The npm package hafas-rest-api receives a total of 22 weekly downloads. As such, hafas-rest-api popularity was classified as not popular.
We found that hafas-rest-api demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
We're introducing a new Analytics feature in the Socket dashboard so you can view changes in your organization's and repositories' alerts over time.
Security News
A new OpenSSF report uncovers critical gaps in secure software training, with 75% of new developers unfamiliar with secure practices, highlighting urgent educational needs.
Security News
The 2023 Python Developers Survey reveals key trends in packaging, web frameworks, and developer demographics, highlighting a shift toward innovative tools as the Python community diversifies and grows among less experienced developers.