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

pidash-email-npm-module

v2.1.2

Published

Email library for the mailer jobs and admin of the PIDashboard

Downloads

32

Readme

PI dashboard email NPM module

Email library for the PI Dashboard's mailer jobs and admin site. (Email Constructor, Email Sender, and Admin site)

Setup

The module expects the following environment variables to be defined:

  • AWS_REGION
  • EMAIL_BATCH_DYNAMODB (if Email#create or Email#getBatches are used)
  • EMAIL_METADATA_DYNAMODB
  • EMAIL_BODY_DYNAMODB
  • For Email#send:
    • EMAIL_SENDER_LAMBDA
    • EMAIL_SENDER_QUEUE
    • EMAIL_SENDER_SERVICE
    • EMAIL_SENDER_CLUSTER
    • EMAIL_SENDER_TASKNAME
  • For Email#construct:
    • EMAIL_CONSTRUCTOR_LAMBDA
    • EMAIL_CONSTRUCTOR_QUEUE
    • EMAIL_CONSTRUCTOR_SERVICE
    • EMAIL_CONSTRUCTOR_CLUSTER
    • EMAIL_CONSTRUCTOR_TASKNAME

Include this in your project by adding:

    "dependencies": {
        "pidash-email": "raisdev/pidash-email-npm-module#v1.0.8"
    }

Testing/linting

Run tests with npm test, and linting with npm run lint. Make sure that you have all the dependencies installed.

Architecture

AWS organization chart

When we want to create an email, we go through the following process:

Create emails on admin site -> (pushes to DynamoDB)
Click 'build' on admin site ->
Launches a lambda for each email, which:
    adds an item to an SQS queue
    creates (or updates) a AWS ECS service ->
The service starts up some tasks, each of which:
    Pulls an email off the queue(or quits the service if the queue is empty)
    Builds an email
    Updates its status
    Uploads the complete email to DynamoDB

The person waiting on the admin site can reload the page and
sees the email's status change (from 'generating' to 'generated')
they can review the email.

Click on 'send' on admin site ->
Launches (the same) lambda for each email, which:
    adds an item to an SQS queue
    creates (or updates) a AWS service ->
Each of the service's tasks:
    Pulls an email off the queue (or quits the service if the queue is empty)
    Sends the email (after some basic validating)
    Updates the email's status

One of the unexpected side effects is that, to change the ECS service, you need to delete the existing ECS services and then modify the Lambda to use the new service.

Amazon has put together [an example repository (Lambda ECS Worker Pattern)][ecs-worker-pattern] that has a somewhat similar architecture. [ecs-worker-pattern]: https://github.com/awslabs/lambda-ecs-worker-pattern

AWS resources

Lambda

  • emailLambda (ECS & SQS permissions)

SQS

  • emailSenderQueue
  • emailConstructorQueue

ECS (each of these need to be in some cluster)

  • some-admin-service
    • some-admin-task
      • admin container
  • emailConstructors service
    • constructEmail task
      • emailConstructor container
  • emailSenders service
    • sendEmail task
      • emailSender container

DynamoDB

  • email_batch (batch, date)
  • email_body (netid, date, batch, status)
  • email_metadata (netid, date, body)
  • pidash-admin-sessions (setup by admin)
  • pidash-admin-users (setup by admin

SES

  • fromEmailAddress@cornell.edu Email Address Identity

IAM

  • ECS instance role
    • DynamoDB full access
    • SES full access
    • EC2 Container Service for EC2
    • SQS full access (reading from queue, removing from queue)
  • Lambda Role
    • ECS full access (create, update, describe, etc...)
    • SQS full access (only uses adding to queue)