npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

node-bubbleio

v0.0.6

Published

Bubble.io Data and Workflow API client for node.js

Downloads

9

Readme

node-bubbleio

NPM

Bubble.io Data and Workflow API client for node.js

Installation & Setup

Install

npm i node-bubbleio --save

Configuration

Configure your application by passing these values into BubbleIO.init:

  • apiToken: Your API token
  • domain: Full domain to your API (include .bubbleapps.io if not using a custom domain)
  • isLive: Whether to use the live version of your API
BubbleIO.init({
  domain: 'my-amazing-app.bubbleapps.io',
  apiToken: 'a6se92a9dd6cb69979128a6969c98c89'
});

Or you can set these via environment variables and just run BubbleIO.init:

//.env
BUBBLE_DOMAIN=my-amazing-app.bubbleapps.io
BUBBLE_API_TOKEN=a6se92a9dd6cb69979128a6969c98c89
BUBBLE_LIVE=false
BubbleIO.init()

Data API

Define your Things

Each Data API endpoint needs to be defined as its own class:

const BubbleIO = require('node-bubbleio');

class Thing extends BubbleIO.DataAPI {
  _type = 'thing'; // This is the object name
}

In Typescript, you also pass in the custom attributes of your thing

class Thing extends BubbleIO.DataAPI {
  _type = 'thing';

  title_text: string;
}

Retrieve a thing by ID

If you already know the ID of a thing, you can get the thing from the server using the static get method:

const thing = await Thing.get('1449154312665x293260311940684900');

Modify a thing

After creating or getting a thing, you can edit the thing directly and then save your changes using the save method:

thing.title_text = 'My new thing';
await thing.save()

The original thing in your code will be updated with the latest version from the API. For example, the Modified Date will be up to date.

Delete a thing

To delete a thing use delete method:

await thing.delete()

Create a new thing

To create a thing, you can use the static create method:

const newThing = await Thing.create({
  title_text: 'My new thing'
});

Or you can create a new thing and use the save method:

const newThing = new Thing({
  title_text: 'My new thing'
})
await newThing.save();

newThing will have all the updated fields from the Data API like _id and Created Date.

Bulk create things

If you need to create many new things in a single operation, you can do that using the bulkCreate method:

const newThings = await Thing.bulkCreate([{
  title_text: 'Thing 1'
}, {
  title_text: 'Thing 2'
}]);
console.log(newThings[0].title_text) // Thing 1

This will return an array of things.

Getting a list of things and search

To retrieve a list of things, optionally using search constraints, use the find method:

const found = await Thing.find({
  constraints: [
    {
      key: 'title_text',
      constraint_type: 'text contains',
      value: 'Test',
    },
  ],
  limit: 1,
  cursor: 2,
  sort_field: 'Created Date',
  descending: true
});

This method supports all pagination, search constraints, and sorting options.

Workflow API

Define your Workflow

Each Workflow API endpoint needs to be defined using the BubbleIO.WorkflowAPI class:

const BubbleIO = require('node-bubbleio');

class MyAPI = new BubbleIO.WorkflowAPI({
  name: 'myworkflow'
})

Triggering a Workflow

A Workflow API call can send a JSON body and querystring parameters.

// Using just JSON in the body
await MyAPI.send({
  value: 23
});

// Sending a `param` querystring as well
await MyAPI.send({
  value: 23
}, {
  param: true
});

License

MIT