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-dweetproio

v1.0.1

Published

A node.js client for dweetpro.io

Downloads

10

Readme

node-dweetio

A node.js module for interacting with http://dweet.io — a free, easy-to-use messaging platform for the Internet of Things.

Installation

via npm:

$ npm install node-dweetio --save

Use It

var dweetClient = require("node-dweetio");
var dweetio = new dweetClient();

Dweeting

Send a dweet and let dweet.io make up a name for you. Subsequent calls to this will result in the same name being used.

dweetio.dweet({some:"data"}, function(err, dweet){

    console.log(dweet.thing); // The generated name
    console.log(dweet.content); // The content of the dweet
    console.log(dweet.created); // The create date of the dweet

});

Send a dweet with a name you define.

dweetio.dweet_for("my-thing", {some:"data"}, function(err, dweet){

    console.log(dweet.thing); // "my-thing"
    console.log(dweet.content); // The content of the dweet
    console.log(dweet.created); // The create date of the dweet

});

Getting Dweets

Get the latest dweet.

dweetio.get_latest_dweet_for("my-thing", function(err, dweet){

    var dweet = dweet[0]; // Dweet is always an array of 1

    console.log(dweet.thing); // The generated name
    console.log(dweet.content); // The content of the dweet
    console.log(dweet.created); // The create date of the dweet

});

Get all dweets (up to 500 in the last 24 hours).

dweetio.get_all_dweets_for("my-thing", function(err, dweets){

    // Dweets is an array of dweets
    for(theDweet in dweets)
    {
        var dweet = dweets[theDweet];

        console.log(dweet.thing); // The generated name
        console.log(dweet.content); // The content of the dweet
        console.log(dweet.created); // The create date of the dweet
    }

});

Alerts

Set an alert.

                              // Email addresses can also be an array
dweetio.set_alert("my-thing", "[email protected],[email protected]", "if(dweet.some_data > 100) return 'something wrong';", "my-key", function(err){

    // If there was a problem, err will be returned, otherwise setting the alert was successful.

});

Get an alert

dweetio.get_alert("my-thing", "my-key", function(err, alertData){

    // If there was a problem, err will be returned, otherwise the data for the alert will be returned in alertData

});

Remove an alert

// Email addresses can also be an array
dweetio.remove_alert("my-thing", "my-key", function(err){

    // If there was a problem, err will be returned, otherwise the alert will have been successfully removed.

});

Pubsub

Listen for all dweets from a thing.

dweetio.listen_for("my-thing", function(dweet){

    // This will be called anytime there is a new dweet for my-thing

});

Stop listening for dweets from a thing.

dweetio.stop_listening_for("my-thing");

Stop listening for dweets from everything.

dweetio.stop_listening();

Locking & Security

By default, all things are publicly accessible if you know the name of the thing. You can also lock things so that they are only accessible to users with valid security credentials. To purchase locks, visit https://dweet.io/locks. The locks will be emailed to you.

To use purchased locks:

// To lock a thing
dweetio.lock("my-thing", "my-lock", "my-key", function(err){

    // If there was a problem, err will be returned, otherwise the lock was successful.

});

// To unlock a thing
dweetio.unlock("my-thing", "my-key", function(err){

    // If there was a problem, err will be returned, otherwise the lock was successful.

});

// To remove a lock no matter what it's attached to
dweetio.remove_lock("my-lock", "my-key", function(err){

    // If there was a problem, err will be returned, otherwise the lock was successful.

});

Once a thing has been locked, you must pass the key to the lock with any call you make to other functions in this client library. The key will be passed as a parameter before the callback function. For example:

dweetio.dweet_for("my-locked-thing", {some:"data"}, "my-key", callback);

dweetio.get_latest_dweet_for("my-locked-thing", "my-key", callback);

dweetio.get_all_dweets_for("my-locked-thing", "my-key", callback);

dweetio.listen_for("my-locked-thing", "my-key", callback);

Failure to pass a key or passing an incorrect key for a locked thing will result in an error being returned in the callback.

Copyright & License

Copyright © 2013 Jim Heising (https://github.com/jheising) Copyright © 2013 Bug Labs, Inc. (http://buglabs.net) Licensed under the MIT license.