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

freetier

v1.0.1

Published

A JavaScript SDK for free services on the Internet.

Downloads

9

Readme

freetier

A JavaScript SDK for free services on the Internet.

This SDK package allows developers to consume only free tier plans from internet service vendors(AWS SES, SendGrid etc.). It will automatically swith to other services when one is exceeding the free tier usage quota.

It's highly recommended that you should switch to the paid plans for more stable and comprehensive services from the vendors once your project/business starts to have decent traffic. And you can still use this SDK as a service integration tool for paid plans.

Sending email

const { sendEmail } = require('freetier');

/** This function will send email using only freetier plans provided by ElasticEmail and SendGrid
 * Make sure you have both ElasticEmail and SendGrid accounts setup and timezone configured before
 * using this function
 */
sendEmail({
  to: 'RECIPIENT_EMAIL',
  from: 'SENDER_EMAIL',
  subject: 'subject',
  message: 'message',
  recipient: 'recipient',
  sender: 'sender',
}, {
    elasticEmail: { apiKey: elasticemailApiKey, dailyLimit: elasticemailDailyLimit },
    sendGrid: { apiKey: sendgridApiKey, dailyLimit: sendgridDailyLimit },
  }).then(data => {
    console.log(data);
  }).catch(err => {
    console.log(err);
  });

You can also use ElasticEmail or SendGrid client directly

const { ElasticEmail, SendGrid } = require('freetier/email');

const ee = new ElasticEmail('API_KEY');

ee.getUsage(from, to).then(data=>{
    ...
}).catch(err=>{
    ...
})

ee.sendEmail(to, from, subject, message, recipient, sender, replyTo).then(data=>{
    ...
}).catch(err=>{
    ...
})



const sg = new SendGrid('API_KEY');

sg.getUsage(from, to).then(data=>{
    ...
}).catch(err=>{
    ...
})

sg.sendEmail(to, from, subject, message, recipient, sender, replyTo).then(data=>{
    ...
}).catch(err=>{
    ...
})

| Class | Method | Arguments | Return | |-------|--------|-----------|--------| | email/elasticemail/ElasticEmail | getUsage | from: String|Required|YYYY-MM-DDto: String|Required|YYYY-MM-DD | Promise | | email/elasticemail/ElasticEmail | sendEmail | to: String|Required|recipient emailfrom: String|Required|Sender emailsubject: String|Required|Email subjectmessage: String|Required|Email content (HTML allowed)recipient: String|Optional|Recipient namesender: String|Optional|Sender namereplyTo: String|Optional|Reply-to email | Promise | | email/sendgrid/SendGrid | getUsage | from: String|Required|YYYY-MM-DDto: String|Required|YYYY-MM-DD | Promise | | email/sendgrid/SendGrid | sendEmail | to: String|Required|recipient emailfrom: String|Required|Sender emailsubject: String|Required|Email subjectmessage: String|Required|Email content (HTML allowed)recipient: String|Optional|Recipient namesender: String|Optional|Sender namereplyTo: String|Optional|Reply-to email | Promise |

Integrations with vendors

Make sure you have the correct timezone setting on all vendors' dashboard page, otherwise the auto switch of email providers won't work properly

Unit testing

Make sure you have a .env file with api keys configured.

sendgridApiKey=OBTAIN_THIS_FROM_SENDGRID_DASHBOARD
elasticemailApiKey=OBTAIN_THIS_FROM_ELASTICEMAIL_DASHBOARD