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

urihooks

v1.0.1

Published

A package to push data to a variety of URIs and services.

Downloads

5

Readme

Uri Hooks

URI Hooks are a library that given a URI (http/https, mailto, tel, sms, etc) will figure out the best way of calling that URI or schema. The schema is automatically identified from the URI (in addition to the service). Currently the following schema and services are supported:

  • email - (mail:, mailto:, email: - Sends an email to the address in the uri).
  • CircleCI - Kicks off a circleci job
  • Slack - Sends a message to a slack channel.
  • Opsgenie - Fires an alert in ops genie.
  • Microsoft Teams - Sends a message to a microsoft teams channel.
  • Rollbar - Fires a new error in rollbar.
  • http/https - Sends a HTTPS POST message.

Usage

Hooks Object

  1. handler = hooks.find(uri string)

Return the first hook handler that can manage the specified URI, otherwise return null.

  1. result = hooks.fire(id string|number, uri string, type string, incoming object[, hmac string, headers string, token string])

Fire a hook.

  • id - The identifier for this webhook, can be anything, its used to identify the hook in debug logs only (the uri is not printed for security reasons).
  • uri - The URI for this hook.
  • type - The type of event being fired as a string. This is interpretted and used differently by different handlers. Should be an alpha numeric identifier.
  • incoming - A JSON object of the payload to send. For systems that don't accept JSON objects the object is generally serialized and pretty printed into a string.
  • hmac - For HTTP/HTTPS payloads the SHA1 hmac to added to the header x-akkeris-signature: sha1=... if the payload must be validated using a signature. This is optional.
  • headers - Headers to include (for http/https headers to the request, for email headers to the smtp system). This is optional.
  • token - A token to send as part of the payload. For http/https this becomes the header x-akkeris-token: .... This is optional
  1. handlers[] = hooks.hooks

Get all known hooks (even if some cannot be used).

  1. handlers[] = hooks.available()

Get all available hooks (only those that can be used).

Handler Object

  1. handler.fire - same signature as hooks.fire above.
  2. handler.test(uri) - returns a true or false if the handler can fire a hook for the uri specified.
  3. handler.enabled() - returns whether or not the handler is allowed to fire.
  4. handler.name - A string human readable name
  5. handler.description - A human readable description of the hook
  6. handler.format - An example human readable format of the hook
  7. handler.image - A string containing a data uri with an icon (PNG transparent) of the handler.
  8. obj = handler.formatter(incoming) - The default formatter for the hook (modifies the incoming payload to the payload dested). Can be set to override default formatting.

Result Object

{
  "sent_metadata":{},
  "sent_data":{},
  "received_code":200,
  "received_metadata":{},
  "received_data":{},
}

Special Incoming Formats

For email you can specify a text, html and subject by adding the respective fields to the incoming object passed.

Environment Variables

  • SMTP - Should be smtps://mail.example.com or smtp://mail.example.com:25 (if a username/password is added it will use it as authentication)
  • SMTP_FROM - The email address to send from.
  • SMTP_HTML_TEMPLATE_[type] - Set the HTML format to use where [type] is the type event name passed into hooks.fire. Use {field} to represent a value in the incoming object passed into hooks.fire.
  • WEBHOOK_DISABLE_[handler] - Set to true to disallow any handler from being used. E.g., WEBHOOK_DISABLE_EMAIL=true to disable sending emails.

Example

const hooks = require('urihooks');
hooks.fire(1, 'mailto:[email protected]', 'some-event-name', {"html":"<b>Hello!</b>", "subject":"Oh hello", "text":"Hello"});