tigerbay v1.1.3-beta.4
Tigerbay JS
JavaScript API Client for TigerBay. This API is designed primarily for use in NodeJS but can be used in the browser.
The API is built with TypeScript and so typings are provided out-of-the-box.
Usage
Simple Example (Javascript)
import * as TigerBay from 'tigerbay';
// Get the credentials from `TB_CLIENT_ID` and `TB_CLIENT_SECRET`
const credentials = TigerBay.Auth.EnvCredentials();
const client = new TigerBay.Client({
baseUrl: 'yourdomain.ontigerbay.com',
credentials: credentials
});
// Get a booking
client.Reservations.find('booking_ref').then(booking => {
console.log(`Booking Get`);
}).catch(error => {
console.error(`Unable to get booking: ${error.message}`)
});
Credential Providers
Authentication credentials (client_id
and client_secret
) are given to the Client
through a
CredentialProvider
, which is a function returning a promise of credentials.
The type signature for a provider is:
async (): Promise<ClientCredentials>
The following credential providers are provided out-of-the-box:
ConstantCredentials
Takes in a set of credentials and creates a provider which will always return those credentials.
const credentials = TigerBay.Auth.ConstantCredentials({clientId: 'client_id', clientSecret: 'client_secret'})
EnvCredentials
Gets the credentials from the process environment. An optional prefix can be given and defaults to TB
// Uses `REX_CLIENT_ID` and `REX_CLIENT_SECRET`
const credentials = TigerBay.Auth.EnvCredentials('REX');
Resources
The API surface is broken down into resource-oriented modules. These modules are accessed through
a TigerBay.Client
instance.
Interceptors
The API client is built on Axios and exposes methods to add or remove request and response interceptors:
25 days ago
2 months ago
1 month ago
3 months ago
1 month ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
1 month ago
1 month ago
3 months ago
3 months ago
3 months ago
4 months ago
3 months ago
3 months ago
5 months ago
5 months ago
5 months ago
4 months ago
4 months ago
6 months ago
6 months ago
7 months ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago