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

glados

v1.0.1

Published

Monitor remote resource for changes

Downloads

52

Readme

Build Status

glados

Monitor remote resource for changes

  • Use the cli wrapper to send an email notification or POST to a url when the resource has changed
  • Diffs are calculated using kpdecker's diff
  • Will not start polling until client binds to 'change'
  • Use the CLI Wrapper to take action on 'change'
    • POST to an endpoint, or
    • send email notification (supports Gmail and SES)

App

var glados = require('glados')

var watcher = glados('http://example.com/sensitive_data.html', 1000*60)
.on('change',function(diff){
	// do something with diff
})
.on('error',function(err){
	// we have some problem connecting with resource
})

CLI Wrapper

See api notes below for opts

node ./bin/cli.js http://example.com/sensitive_data.html -n60000 \
-p http://myapi.example.com/notify_change \
-m [email protected]

Forever Wrapper

Make sure this thing never goes down. Wraps cli.js with sturdiness. Kill the process, stop the forever, reboot the instance. Baby will still be kickin. Most recently polled data is saved to tmp file in case process dies and reboots.

./bin/forever.sh http://example.com/sensitive_data.html -n60000 \
-p http://myapi.example.com/notify_change \
-m [email protected]
Kill Forever

Shut down what you started with forever.sh

./bin/kill_forever.sh http://example.com/sensitive_data.html
# or kill processes that contain -s (softmatch):
./bin/kill_forever.sh -s sensitive_data.html

App Api

glados( url [, pollInterval] )

returns a watcher that will monitor changes of url url string - remote resource to watch pollInterval int - interval in ms to check resource for changes. defaults to 1 minute

watcher.stop()

Stop watching. No further events will be fired after this is called.

watcher.on('change', function(diff, data){})

Fired when a change has been detected in remote resource diff Array - an array of data comprising added, removed, and unchanged chunks data Buffer - the new data, unadulterated

watcher.on('connection', function(data){})

Fired on response from initial poll data Buffer - the response data

watcher.on('poll', function(){})

Fired immediately prior to each poll. The first 'poll' event occurs before 'connection'

watcher.on('error', function(err){})

Catch errors in the stream

CLI Api

Arguments

Applies to both cli.js and forever.sh

  • [target]
    • url of resource to watch
  • -n or --interval
    • pollInterval
    • optional, defaults to 1 minute
  • -p or --post
    • endpoint to post diff on change event
    • optional
    • supports multiple
  • -m or --email
    • email address to send diff on change event
    • optional
    • supports multiple

Email

Copy config.json to config.local.json and add credentials

Gmail

Set mailTransport to 'gmail' Use an application password (not your personal account password)

SES

Set mailTransport to 'ses' Set your AWS secret and key, along with an approved From address

To Do

  • Using the softmatch option (kill_forever.sh -s "substring") currently kills only the first match found, but deletes all matching saved data
    • Update script to kill all matches as advertised in readme
  • Add screenshot of pretty email to readme