New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

pronto-notification-service

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pronto-notification-service

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

  • 0.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

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)?

FAQs

Package last updated on 22 Mar 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc