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 🙏

© 2026 – Pkg Stats / Ryan Hefner

gcp-function-mailer

v0.3.2

Published

Google Cloud Library that creates Cloud Functions for sending email via Sendgrid

Downloads

42

Readme

GCP Function Mailer

Sends an email using the Sendgrid API using a Google Cloud Platform (GCP) Function. The data and trigger for the email is a GCP Pubsub message. It gets formatted to HTML and/or Text using a given mustache template.

See the example under the example directory for usage.

Quickstart

mkdir your-mailer-directory
cd your-mailer-directory
npm init .
npm install gcp-function-mailer --save
cp config.json config.production.json
touch hello.text.mustache
touch hello.html.mustache

Edit the config.production.json file to include the Sendgrid API key you want to use in production. Then edit the two mustache templates. The first line of the template should be the subject as a string.

To deploy to Google Cloud, set up your gcloud environment and run:

gcloud beta functions deploy mailer --trigger-topic=mailer

You can trigger the function in either the Google Cloud Console or via the command line:

gcloud beta functions call mailer --data '{"template":"hello", "to":"[email protected]"}'

Configuration

Configuration data is taken from a number of sources. The code will attempt to load the local config.json and config.[NODE_ENV].json files. It will also load package.json and look for the "mailer key". These values are combined with any configuration supplied programattically. Generally all you will need is a config.json for local development and a production version.

Don't check in your production version. Right now there isn't an easy mechanism for secrets configuration for Google Cloud Functions. However, this is in progress with Google.

The configuraton must contain a sendgridApiKey, unless it can be sourced from the SENDGRID_API_KEY environment variable.

The configuration can contain: defaultCc, defaultBcc, defaultFrom, and defaultReplyTo values.

Invoking

To send an email, publish a message to the mailer pubsub topic.

Each invocation must have a to and template value. It can optionally contain cc, bcc, from and replyTo values.

The whole message is supplied to the Mustache template for rendering.

Templates

The code assumes the first line of the template is the subject line for the email. If you have both HTML and Text templates, the Text subject line takes precidence. So you can leave the HTML one blank if that suits - but the line must still be present.