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

mailery

v0.5.1

Published

Embedded, MongoDB-backed email automation for Node.js. Triggered flows, broadcasts, tracking, suppression, and an admin UI you mount inside your Express app.

Readme

mailery

Embedded, MongoDB-backed email automation for Node.js. Triggered flows, broadcasts, tracking, suppression, compliance, and a React admin UI you mount inside your Express app.

npm

Status: v0.1.x — Phase 0 spike. Core engine working end-to-end (flow runner, send pipeline, tracking, unsubscribe, admin UI). Single-host production deployments next. Spec in plans/.

Install

yarn add mailery
# or
npm install mailery

Peer dependencies (host-provided): express ^4 || ^5 plus one queue driver — either bullmq + ioredis (default) or agenda + @agendajs/mongo-backend + bottleneck. Runtime deps brought in by mailery: mongodb, mjml, handlebars, @sendgrid/mail, zod.

Quickstart

import express from 'express'
import { MongoClient } from 'mongodb'
import {
  Mailer,
  MongoContactAdapter,
  SendGridProvider,
  createAdminRouter,
  createPublicRouter,
} from 'mailery'

const mongo = await MongoClient.connect(process.env.MONGODB_URI!)
const db = mongo.db()

const adapter = new MongoContactAdapter({
  db,
  collection: 'users',
  emailField: 'email',
  idField: '_id',
  tagsField: 'tags',
  tagsWritable: true,
})

const mailer = await Mailer.init({
  db,
  adapter,
  queue: { driver: 'bull', redis: { url: process.env.REDIS_URL! } },
  providers: {
    sendgrid: new SendGridProvider({
      apiKey: process.env.SENDGRID_API_KEY!,
      webhookVerificationKey: process.env.SENDGRID_WEBHOOK_KEY!,
    }),
  },
  defaultProvider: 'sendgrid',
  publicUrl: 'https://yourdomain.com',
  unsubscribeSecret: process.env.MAILER_UNSUB_SECRET!,
  senderAddress: '12 Main Street, Brooklyn NY 11201, USA',
  fromDefaults: { name: 'Jeff', email: '[email protected]' },
})

mailer.registerEvent({ name: 'Created', dedupePolicy: 'once-per-contact' })

const app = express()
app.use('/admin/mailer', requireAdmin, createAdminRouter(mailer))   // SPA + REST
app.use('/m', createPublicRouter(mailer))                            // tracking + unsub + webhooks

// Then from your business logic:
await mailer.upsertSubscription({ externalId: user._id.toString(), source: 'signup' })
await mailer.fire('Created', user._id.toString())

Run a separate worker process for queue jobs:

const mailer = await Mailer.init({ /* same config */ })
await mailer.startWorkers()  // queue consumers (Bull or Agenda, per your queue.driver)

See examples/express-mongo/ for a complete working example.

What it is

A self-hosted library you npm install into your Express + MongoDB app. Fire events from your code, define flows + templates as documents in MongoDB, mount the admin UI on a route gated by your existing auth.

  • Embedded, not external. No third-party sync, no per-contact pricing.
  • Both transactional and marketing in one engine. Right defaults per kind (suppression scope, sender identity, circuit-breaker behavior).
  • Provider-agnostic. SendGrid + NullProvider ship; Postmark / SES / Resend pluggable.
  • Pluggable queue — BullMQ + Redis (default) or Agenda + Mongo (no Redis required).
  • mailery setup-sendgrid CLI that wires up domain auth, Cloudflare DNS records, Signed Event Webhook key, and Event Webhook URL in one idempotent command. See docs/guide/deliverability.
  • MJML templates with click + open tracking, plain-text auto-derivation, scope-aware suppression at send time.
  • React admin SPA (Vite-bundled, served as static assets — no build step in your app).

Status & roadmap

V0.1 ships:

  • Mailer class with fire, upsertSubscription, unsubscribe, tag, suppress, forget, sendOneOff, audit.
  • Flow runner state machine (wait, condition, branch, send, tag, fire_event, webhook, exit).
  • SendGrid provider with webhook signature verification, NullProvider for tests.
  • MongoContactAdapter with read methods + optional narrow tag writes.
  • Tracking endpoints (open pixel, click redirect), HMAC-signed unsubscribe tokens with disk fallback.
  • React admin SPA + REST API surface (14-admin-api.md).
  • Test harness (mailery/testing): MemoryContactAdapter, NullProvider, createTestMailer().

Phase 1+ (in roadmap, not yet shipped):

  • Daily webhook reconciliation, soft→hard bounce promotion, circuit-breaker auto-tripping.
  • Broadcast streaming dispatch + rate-limit shaping.
  • Double opt-in flow, lead promotion.
  • Maily WYSIWYG editor in the template editor.
  • Domain auth verification.

See plans/13-roadmap.md.

Docs

License

MIT © Jeff Jassky