A small Rest Client to connect to a BPTK Backend
Simple example using promises and callbacks
import bptkConnector from('bptkConnector')
const bptkApi = new bptkConnector(process.env.API_KEY)
TODO
Same example (as the above) using async/await, destructuring, and template strings
TODO
Table of Contents:
Features
Rate Limiting
TODO
All Endpoints Covered
Caching
Currently supports a basic JS cache (for simple scripts), node-lru-cache.
Compatible with Callbacks, Promises, Async / Await
TypeScript Support
Works immediately upon installation.
Methods
Check out ENDPOINTS.md to see bptk's methods, as well as the endpoints, covered.
Documentation
TODO
Installation and Usage
The minimum required Node.js version is v7.6.0 for native async/await support (there's only a mere line in the codebase, though).
npm
npm i --save @transentis/bptk-connector
yarn
yarn add @transentis/bptk-connector
Quick Setup with [Default Config]
TODO SINCE NO
Note: Any config passed in is deeply merged with the default config.
Environment Variables
const bptkApi = new bptkAPi(process.env.API_KEY)
Although it is possible to manually pass in the API key, it is preferable to store the key in a secret file (which should not be committed).
This allows bptk-connector
to be constructed like in the above code.
# filename: .env
API_KEY=RGAPI-my-api-key
Callbacks
TODO
Promises
bptkApi
.requestModel(myModel)
.then((data) => doSomething(data))
.then(console.log)
.catch((error) => console.error(error))
Async / Await
const main = async () => {
const requestedModel = await bptkApi.requestModel(myModel)
}
Request Errors
Errors as of v1.0.0 return the following error object:
{
statusCode: 42, // some random number
url: '', // the debug URL that is used in logging as well
error: {} // the rest of the error object
}
Bugs
TODO
FAQ
TODO