Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@buildable/messages

Package Overview
Dependencies
Maintainers
5
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@buildable/messages

Custom Events for Buildable

Source
npmnpm
Version
1.0.0
Version published
Weekly downloads
11
-73.17%
Maintainers
5
Weekly downloads
 
Created
Source

@buildable/messages

Buildable npm version GitHub contributors GitHub license Twitter Follow

Buildable is the easiest way to collect, transform, send and action your backend system messages. Buildable simplifies the process of collecting message data from your disparate systems and connecting new tools to action those messages, allowing you to spend more of your engineering time on things that matter.

This library allows you to quickly and easily emit and listen on messages via Node.js.

Setup

In order to use emit and listen on messages, you'll need a Buildable account and Secret Key. Follow these steps:

  • Create an account at messages.buildable.dev
  • Head over to the Secret Keys section in the Settings page
  • Click the + Create secret key button
  • Name your Secret Key
  • Click Create

Ensure you store the test and live keys somewhere safe (like a password manager).

Install Package

Install the @buildable/messages NPM package in your working code space:

> npm install @buildable/messages

Emitting Messages

Once a message is emitted, it will be visible immediately in the Messages Stream on your Buildable account.

NodeJS

const { createClient } = require('@buildable/messages');

const client = createClient(process.env.BUILDABLE_SECRET_KEY);

client.emit("my-message", { 
  salutation: "Hello world ⚡️"
});

Using cURL

curl --location --request POST 'https://events.buildable.dev/emit' \
  --header 'X-Buildable-Secret: <YOUR SECRET KEY>' \
  --header 'Content-Type: application/json' \
  --data-raw '{
    "event": "my-message",
    "payload": {
      "salutation": "Hello world ⚡️"
    }
}'

Listening on Messages

There are two cases for transacting on messages:

  • Messages from internal apps using the Buildable SDK
  • Messages from third-party cloud apps using Buildable Connections

Messages from internal apps using the Buildable SDK

const { createClient } = require('@buildable/messages');

const client = createClient(process.env.BUILDABLE_SECRET_KEY);

// Listen on `my-message`
client.on("my-message", async ({ event, payload }) => {
  console.log("Receieved message with payload: ", payload);
});

Messages from third-party cloud apps using Buildable Connections

All Connections act as a source of events, leveraging the power of WebHooks. Once you’ve created a Connection in Buildable and subscribed to at least 1 message type, messages will continually enter the Messages Stream. In most cases, once you create a Connection once, you can forget about it!

When listening on messages from cloud apps, simply add two additional options to the listener:

const { createClient } = require('@buildable/messages');

const client = createClient(process.env.BUILDABLE_SECRET_KEY);

// Listen on `customer.created` from Stripe
client.on("customer.created", async ({ event, payload }) => {
  console.log("Receieved message with payload: ", payload);
}, {
  platform: "stripe", // Platform name
  label: "my-stripe-connection" // Connection name
});

Need More Help?

💻 Website: https://buildable.dev/messages

📄 Docs: https://hub.buildable.dev

💬 Discord: https://discord.com/invite/47AJ42Wzys

🐦 Twitter: https://twitter.com/BuildableHQ

License

© 2022, Buildable Technologies Inc. - Released under the MIT License

Keywords

buildable

FAQs

Package last updated on 29 Sep 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts