@braustin-holdings/homebase-node-sdk

0.0.2342 • Public • Published

homebase-node-sdk

A node SDK for interacting with braustin-holdings/homebase. Provides an authenticated for the Homebase React Client.

Installation

npm i @braustin-holdings/homebase-node-sdk

Usage

Instantiate a new HomeBaseSDK object by passing it your app's clientId and clientSecret.

const HomeBaseSDK = require('@braustin-holdings/homebase-node-sdk')
const hb = new HomeBaseSDK('CLIENT_ID_HERE', 'CLIENT_SECRET_HERE')

Authentication with Homebase

There are two ways of obtaining a JSONwebtoken to gain access to the Homebase data. Choose whichever is most convenient for your app.

The getAuthToken method

For use in your controllers or scripts.

const tokenData = await hb.getAuthToken()
console.log(tokenData) // { token: '39fp...', graphqlUrl: 'https://homebase-api.herokuapp.com' }

As an Express middleware

If you're using express and the HomeBase React Client, you can easily obtain the token by including this middlware. NOTE you will want this to be one of the earlier middleware in the chain.

The Homebase React Client looks for the url used in the middelware.

const app = express()

app.use(hb.middleware.getAuthToken) // res.json({ token: '39fp...', graphqlUrl: 'https://homebase-api.herokuapp.com' })

Readme

Keywords

none

Package Sidebar

Install

npm i @braustin-holdings/homebase-node-sdk

Weekly Downloads

6

Version

0.0.2342

License

ISC

Unpacked Size

19.7 kB

Total Files

7

Last publish

Collaborators

  • itadmins_braustin
  • cwollak
  • 8ctopotamus