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

@cloudprinter/cloudsignal

v1.0.1

Published

The library that help developers easily integrate with CloudPrinter CloudSignal.

Downloads

5

Readme

CloudSignal NodeJS SDK

The Cloudprinter.com CloudSignal NodeJS SDK is a package that helps your app respond to events from Cloudprinter.com

We at Cloudprinter.com have connected 150+ printers to print & ship print products in almost any country in the world. Whether this is around the corner or at the other side of the globe, we've got you covered: we can deliver 500+ different products in more than 100 countries currently.

Our platform makes use of smart routing algoritms to route any print job to the most local and qualified printer. Based on location, performance, price and production options, your print job is routed by these algorithms to the nearest printing facility near your delivery address to help you save on transit times and costs.

Visit our website for more information on all the products and services that we offer.

Installation

The CloudSignal SDK can be installed with NPM. Run this command:

npm i @cloudprinter/cloudsignal

Prerequisites

  • npm (for installation)
  • node 6.0 or above
  • Cloudprinter.com Print API account

Your RESTful API endpoint

Each client can have one RESTful API endpoint for use with CloudSignal Webhooks. You need a public URL where the app can begin receiving events. To register this url need to the Cloudprinter.com Dashboard.

CloudSignal Api Key

To each account is associated an API key, which is used as authentication in all API calls. Each webhook request includes a Webhook API key, which is different from the account API key. This Webhook API key sould be validated on each request. It can be found in the Cloudprinter.com Dashboard.

Usage

These examples show how to get started using the most common features. You'll find more information in CloudSignal documentation

Initialize the event handler.

Event handler starts the server. Starting the server requires a port for it to listen on.

const CloudSignal = require('@cloudprinter/cloudsignal');

// The port the server is going to listen on. Defaults to 8100.
const port = 8100;

const cloudSignalApiKey = '*';
const eventHandler = new CloudSignal.EventHandler(cloudSignalApiKey, port);

Handle CloudSignal events.

// handle ItemShipped signal
eventHandler.on('ItemShipped', (signalData) => {
    // handle
});

// handle ItemCanceled signal
eventHandler.on('ItemCanceled', (signalData) => {
    // handle
});

// handle ItemError signal
eventHandler.on('ItemError', (signalData) => {
    // handle
});

// handle ItemPacked signal
eventHandler.on('ItemPacked', (signalData) => {
    // handle
});

// handle ItemProduced signal
eventHandler.on('ItemProduced', (signalData) => {
    // handle
});

// handle CloudprinterOrderCanceled signal
eventHandler.on('CloudprinterOrderCanceled', (signalData) => {
    // handle
});

// handle CloudprinterOrderValidated signal
eventHandler.on('CloudprinterOrderValidated', (signalData) => {
    // handle
});

Handle more than one event.

eventHandler.onAny(['ItemShipped', 'ItemCanceled'], (signalData) => {
    // handle
});

Handle errors

In case an error is thrown inside a listener, it must be handled, to prevent your application from terminating unexpectedly. This event handler allows you to define an error handler for catching errors thrown inside any of the listeners, using the .on(‘error’, handlerFn) method. It is best practice to log any errors.

eventHandler.on('error', (errorData) => {
    // handle
});