A Node.js client for hull.io APIs
This provides utility functions to use hull.io APIs within Node.js apps.
import Hull from 'hull';const hull =platformId: 'YOUR_HULL_PLATFORM_ID'platformSecret: 'YOUR_HULL_PLATFORM_SECRET'orgUrl: 'YOUR_HULL_ORG_URL';
Once you have instanciated a client, you can use one of the
delete methods to perform actions of our APIs.
The first parameter is the route, the second is the set of parameters you want
to send with the request, the third is a callback.
//hull.api.get works too.hullgetpath /*, params*/thenconsole.logresponse;console.logerr;;
For convenience, we add
wrapped=true to all requests that return a Collection as an Array. You will receive an object in the form :
If you want to un-nest the response and receive raw arrays, without pagination, add
wrapped:false to your query
var user = hullas'userId';userget'/me'useruserToken//user is an instance of Hull, scoped to a specific user. it will act as if the user performed the action
hull.configuration(): Returns the global configuration
hull.as(userId): create a new Hull client acting as the user
hull.userToken(userHash, claims): Creates a signed id for the user passed in hash. It allows to connect your own users to hull.io services. userHash needs an
hull.currentUserId(userId, userSig): Checks the validity of the signature relatively to a user id
hull.currentUserMiddleware(): Generates a middleware to add to your Connect/Express apps. It will check if a user is onnected.
hull.webhookMiddleware(): Generates a middleware to answer to webhooks
const app = express;// a middleware with no mount path; gets executed for every request to the appappusehullcurrentUserMiddleware;appuseconsole.logreqhulluserId // Should exist if there is a user logged in;appusehullwebhookMiddleware;//Responds to webhooksappuseconsole.logreqbody // Webhook payload, decrypted.