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 🙏

© 2026 – Pkg Stats / Ryan Hefner

drs-listener

v0.1.0

Published

An express SNS listener for DRS actions

Readme

The DRS SNS Listener

Build Status

This library will handle the DRS SNS messages that come in and pass the valid data to the call of your choice. This library is written in Typescript and targets ES2015 environments.

Dash Replenishment Service (DRS) is an Amazon automatic replenishment system that makes automatically replenishing supplies easy. At Wagz, we use to replenish food for our automatic feeders. You can learn more about them at our website, Wagz.Com.

DRS communicates with an SDK and reports events over SNS. If you are looking for a server-side HTTP SDK, we created on in Go that you can use. It's repository is here.

Installing

Installing the library is as simple as running

npm install --save drs-listener

If you are planning to develop against the project, we recommend you clone this repo and run npm install to pull all dev dependencies as well.

git clone [email protected]:GetWagz/drs-listener.git

cd drs-listener

npm install

npm build

Using

Due to a vaidation library used, the primary method is a callback. At some point we may create a promisified version but will give it a different name to preserve backwards compatibility.

You would first want to create a "handlers" object that will hold all of the methods you want to call based upon a message. You can handles as many or as few notification types as you would like. It's also probably a good idea to specify a generic handler in case the message is invalid, cannot be parsed, or otherwise cannot be handled

General Usage with Handlers

import { IHandlers, receiveRequest } from "drs-listener";

const myHandlers: IHandlers = {
  onError: (e: any) => {
    // handle the error here, such as logging or returning a response
  },
  onDeviceDeregistered: (customerId: string, modelId: string, serialNumber: string, message: any) => {
    // handle the device notification, optionally respond; remember, SNS is asynchronous and they will not
    // be listening for action responses
  }
  // and any of the other handlers
};

then, grab the JSON from the source (for example, req.body in an express endpoint):

const incoming = req.body;

receiveRequest(incoming, myHandlers);

If you only care about handling validation of the message:

const h: IHandlers = {
  onError: (e: any) => {
    // handle the error; it's not valid
  },
  onOnlyValidateMessage: (message: any) => {
    // called since since you used validate()
  }
};
// validate only seeks to validate the message is a legitimate SNS message
validate(invalidSignatureNotification, h);

Why this apporach?

This approach was developed to serve a specific use case for us. We had a DRS listener for one of our products. After some further development, a new business need arose and we needed to branch off and call a second API depending on the model and serial information. Rather than having conditionals in each of our handlers, we decided to create two handler objects that we could pass. This approach is not perfect, but served us well.

Testing and Building

Sample test messages were generated using the AWS SNS console. They are stored in the router.test.messages.ts file.

Jest is our testing framework. You can test the installation by running npm run test.

Notes

It is important to note that THIS IS NOT READY FOR PRODUCTION USE

We at Wagz decided to open source this part of our application, but are in the process of cleaning it up and shoring it up before releasing it to the world.

Hiring

Are you on the New Hampshire Seacoast and love Go, Typescript, Swift, or Java? Send an email to [email protected] and let's find out if we're a good match!

Contributing

Pull Requests are welcome! See our CONTRIBUTING.md file for more information.

Remaining TODOs

[ ] Add option to subscribe to URL with boolean

[ ] Break receiveMessage into separate calls for each notification

[ ] Improve documentation

[ ] Integrate with automated checks (CI/CD, etc)

[ ] More tests

[ ] Build promise-based method

[ ] Improve type checking