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

@santospatrick/notify

v0.0.4

Published

Effortless Email and SMS Notification System using Third-Party Providers with Node.js

Downloads

44

Readme

@santospatrick/notify

This library provides an easy-to-use notification system that supports sending notifications via email and SMS using third-party providers.

TypeScript ESLint Babel npm version Alpha Codecov

Disclaimer: This library is currently in alpha version and should not be used in production environments. Use it at your own risk.

Table of Contents

Features

  • [x] Send Email notifications
  • [ ] Send SMS notifications
  • [x] Centralized notification management
  • [x] Flexible architecture for extending to other notification channels

Installation

You can install this library using any of the following package managers:

Using npm

npm install @santospatrick/notify

Using yarn

yarn add @santospatrick/notify

Using pnpm

pnpm add @santospatrick/notify

Usage

Example: Sending an email

Here’s a basic example of how to send an email using the NotificationManager from the library:

Configuration: Setting up NotificationManager

First, create a file named notificationConfig.ts to configure the NotificationManager:

// notificationConfig.ts
import { NotificationManager, EmailProviders } from '@santospatrick/notify';

// Create a new instance of NotificationManager
const notificationManager = new NotificationManager();

// Setup email service to use Twilio SendGrid (more to come!)
notificationManager.addEmailService({
  provider: EmailProviders.SENDGRID,
  apiKey: 'YOUR_API_KEY_HERE', // Your Twilio SendGrid API key that starts with "SG."
});

export { notificationManager };

Usage: Sending an email

Now, create another file named sendEmail.ts to use the notificationManager object for sending an email:

// sendEmail.ts
import { notificationManager } from './notificationConfig';

// Send notification
notificationManager
  .send({
    from: '[email protected]', // Needs to be a "Single Sender" verified in SendGrid.
    to: '[email protected]',
    subject: 'Hello from my application!',
    html: '<strong>Hi there! Using @santospatrick/notify lib.</strong>',
  })
  .then(() => {
    console.log('Email sent!');
  })
  .catch((error) => {
    console.error(error);
  });

Third-Party Providers

Email Providers

How to get Twilio Sendgrid Grid API Key

This library uses SendGrid to send email notifications. To set up the SendGrid API key:

  1. Sign up for a Twilio SendGrid account.
  2. Go to Settings > Sender Authentication > Verify a Single Sender > "Create New Sender".
  3. Fill out the form and click "Create".
  4. Go to Settings > API Keys > "Create API Key".
  5. Give it a name and select "Restricted Access", click "Mail Send" and enable "Mail Send" (this is the only permission needed). Notification System Diagram
  6. Click "Create & View" and copy the API key.

Local Development

To test the library locally while developing, you can use npm link. This allows you to symlink your local development version of the library into another project.

Step-by-Step Guide

  1. In the root directory of your library, run:
npm link

This will create a global symlink to your library.

  1. In the project where you want to test the library, run:
npm link @santospatrick/notify

This will create a symlink from the global @santospatrick/notify to the node_modules of your project.

  1. Make changes to this library and run yarn build to compile the TypeScript code.

  2. Run your project and test the changes.

Publishing to npm, yarn and pnpm

To publish the library to npm, follow these steps:

  1. Ensure your code is ready for publishing by running the build command:
yarn build
  1. Update the version number in the package.json file.
{
  "version": "0.0.3" // Next version to be published
}
  1. Once the build is successful, publish the package to npm with public access:
npm publish --access public

This will publish your library to the npm registry, making it available for others to install and use.

Made with ❤️ by Patrick Santos