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

pronto-notification-service

v0.0.2

Published

Support for notifications across platforms (email, sms, push). Pluggable platform providers. Boilerplate for checking user settings. Standardized templating from platform events.

Downloads

10

Readme

Notification Service

Support for notifications across platforms (email, sms, push). Pluggable platform providers. Boilerplate for checking user settings. Standardized templating from platform events.

Usage

You build a Notification Service with a configuration and a set of notification templates.

Configuration

Configure the service and any platforms it will use.

in ./config.coffee

module.exports =
    id_key: 'id'
    platform_slug: 'tryna'
    email:
        # email service config
    (sms):
        # sms service config...
    (push):
        # push service config...

Templates

Set up templates for each notification type for notification providers you are using.

in ./templates.coffee

module.exports =
    'announcements:created': (announcement) ->
        {body} = announcement

        return {
            'email':
                type: "text" #or html
                subject: "New announcement from Platform Name."
                body: "#{body}"
            'sms': "Platform Name announcement: #{body}"
        }

If you want to send an html email, compile the html in your templates.coffee file and pass it into the body of your template.

Run the Service

somata = require 'somata'

templates = require './templates'
config = require './config'

Notifications = require('notification-service')(config, templates)
{notifyUser, notifyUsers, notifyContacts} = Notifications

client = new somata.Client
DataService = client.remote.bind client, 'tryna:data'

# Set up any schema update notifications
# -----------------------------------------------------------------------------

applySubscriptions = (S) ->
    Object.keys(S).map (s_k) ->
        client.subscribe 'tryna:data', s_k, S[s_k]

subscriptions = {

    "announcements:created": (event) ->
        {
            DataService 'find', 'users', {}, (err, all_users) ->
                notifyUsers all_users, "app_invites:created", event.item, ->
        }
}

applySubscriptions(subscriptions)

# Export any utility functions you'd like from the service
# -----------------------------------------------------------------------------

service = new somata.Service 'tryna:notification', {
    notifyUser
    notifyContact
}

API

A user is a person who has signed up / logged into an app.

A contact is a person with a record that has at least an email/phone and maybe more data. Currently the Notification Service can view a User or pieces of the user as a Contact if it needs to. Notification kinds should look as much as possible like "[type]:[event]", like "invite:created" or "tryna:updated", keyed off of raw schema notifications. More custom kinds like "my-special-invite" may also be appropriate as long as you think you can keep the templates file scalable.

notifyUser(user, kind, context, cb)
notifyUsers(users, kind, context, cb)
notifyContact(contact, kind, context, cb)
notifyContacts(contacts, kind, context, cb)

You can send an HTML email by setting the type to 'html' and compiling html from the context within your templates.coffee file.

TODO:

Consider being able to specify the type of notification to send (email vs. sms, etc). Though this will be mostly contextual or based off user settings.

Pass in custom checking of user setting and app context to stop or send notifications.

Is it necessary to have sms and push be pluggable like email is (for ses/mailgun/etc)?