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

brewery-notif

v1.0.1

Published

A Notification Library for Brewery Project

Downloads

7

Readme

brewery-notif

A Notification Library for Brewery Project

Installation

npm install brewery-notif

Usage

const BreweryNotif = require('brewery-notif');

BreweryNotif.initNotif({
    sms: {
        service: 'twilio',
        aws: {
            accessKeyId: 'XXXXXXXXXXXXXXXXXXXX',
            secretAccessKey: 'XXXXXXXXXXXXXXXXXXXX',
            region: 'ap-southeast-1'
        },
        twilio: { 
            accountSid: 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', 
            authToken: 'xxxXXXXXXXXXXXXXXXXXXXXXXXXX',
            fromPhoneNumber: '+12341234123'
        },
    },
    email: {
        service: 'aws',
        aws: { 
            accessKeyId: 'XXXXXXXXXXXXXXXXXXXX', 
            secretAccessKey: 'XXXXXXXXXXXXXXXXXXXX',
            region: 'us-east-1',
            sourceEmail: '[email protected]',
            senderName: 'Brewery Notif',
        },
        tempDir: 'file_attachments',
    },
});

const message = 'Hi, Welcome to Brewery.';
let data = {
    message: message,
    phoneNumber: '+43214321432'
};

BreweryNotif.sendSms(data);

data = {
    message: {
        subject: 'Welcome to Brewery',
        body: message
    },
    destinations: ['[email protected]']
};
BreweryNotif.sendEmail(data);

API

BreweryNotif

.initNotif([config]) - Initialize the Brewery Notif

  • config ( Type: Object, Properties: sms, email )

.sendSms([details]) - Sends an SMS message

  • details ( Type: Object, Properties: message, phoneNumber)
  • Note: phoneNumber must be in E.164 Phone Number Format.

.sendEmail([details], dir) - Sends an email

  • details ( Type: Object, Properties: message, destinations)
  • dir ( Type: String)
  • Note: -destinations should be an array. -dir is the temporary directory of file attachments.

Notifications

The core notification transports that are currently available to BreweryNotif are:

  • Email - sends a simple email with no attachment

USAGE

BreweryNotif.initNotif({
    email: {
        service: 'aws',
        aws: { 
            accessKeyId: 'XXXXXXXXXXXXXXXXXXXX', 
            secretAccessKey: 'XXXXXXXXXXXXXXXXXXXX',
            region: 'us-east-1',
            sourceEmail: '[email protected]',
            senderName: 'Brewery Notif',
        },
    },
});

const message = 'Hi, Welcome to Brewery.';
let data = {
    message: {
        subject: 'Welcome to Brewery',
        body: message
    },
    destinations: ['[email protected]']
};
const response = BreweryNotif.sendEmail(data);
return response;

OUTPUT

{ "body": "MessageID is \"01234123aa1a1111-a1234567-aaa1-1a19-aa1a-aaa11a1111aa-000000\"" }
  • Email with Attachment - sends an email with file attachment

USAGE

Your node.js code:

const multer = require('multer');
const fs = require('fs');
const { Router, static } = require('express');

const router = Router();

const config = {
    email: {
        service: 'aws',
        aws: {
            accessKeyId: 'XXXXXXXXXXXXXXXXXXXX',
            secretAccessKey: 'XXXXXXXXXXXXXXXXXXXX',
            region: 'us-east-1',
            sourceEmail: '[email protected]',
            senderName: 'Brewery Notif',
        },
        tempDir: 'file_attachments',
    },
};

BreweryNotif.initNotif(config);

const dir = path.join(__dirname, './' + config.email.tempDir);
if (!fs.existsSync(dir)){
    fs.mkdirSync(dir);
}

const storage = multer.diskStorage({
destination: function (req, file, cb) {
    cb(null, dir);
},
filename: function (req, file, cb) {
    cb(null, file.originalname);
}
});
const upload = multer({storage: storage});

router.post('/send-email', upload.any(), function(req, res) {
    const success = BreweryNotif.sendEmail(req, dir);
    success.then(
        function(data) {
            res.json(data);
        }).catch(
        function(err) {
            console.error(err);
        });
});

Your HTML code:

<html>
    <body>  
        <form action="/send-email" method="post" enctype="multipart/form-data">
            <input type="file" name="file-attached">
            <br />
            <label>To:</label>
            <input type="text" name="destinations[0]">
            <label>Subject:</label>
            <input type="text" name="subject">
            <label>Body:</label>
            <input type="text" name="body">
            <input type="submit" value="Submit">
        </form>
    </body>
</html>

OUTPUT

{ "body": "MessageID is \"01234123aa1a1111-a1234567-aaa1-1a19-aa1a-aaa11a1111aa-000000\"" }
  • SMS - sends an SMS message

USAGE

BreweryNotif.initNotif({
    sms: {
        service: 'aws',
        aws: {
            accessKeyId: 'XXXXXXXXXXXXXXXXXXXX',
            secretAccessKey: 'XXXXXXXXXXXXXXXXXXXX',
            region: 'ap-southeast-1'
        },
        twilio: { 
            accountSid: 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', 
            authToken: 'xxxXXXXXXXXXXXXXXXXXXXXXXXXX',
            fromPhoneNumber: '+12341234123'
        },
    },
});

const message = 'Hi, Welcome to Brewery.';
let data = {
    message: message,
    phoneNumber: '+43214321432'
};

const response = BreweryNotif.sendSms(data);
return response;

OUTPUT

{ "body": "MessageID is \"123aa1aa-a11a-1234-11a1-11aa12345678\"" }

Contributors

  • Aviel Caña
  • Kristaleen dela Cruz

License

MIT © Stratpoint Technologies Inc.