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

@tsdiapi/email

v0.4.0

Published

Email plugin for TSDIAPI-Server providing a simple and extensible way to send emails.

Downloads

43

Readme

@tsdiapi/email: Email Plugin for TSDIAPI-Server

The @tsdiapi/email plugin provides seamless email integration for TSDIAPI-Server applications. It supports both Nodemailer and SendGrid, enabling flexibility in email delivery.

With the latest update, the plugin is now usable both as a TSDIAPI plugin and as a standalone package, allowing developers to integrate email functionality in different contexts.


Installation

Install via NPM

npm install @tsdiapi/email

Or Add via CLI

tsdiapi plugins add email

Usage

Registering the Plugin in TSDIAPI

Include the plugin in your server setup:

import createPlugin from "@tsdiapi/email";
import { createApp } from "@tsdiapi/server";

createApp({
  plugins: [
    createPlugin({
      provider: "sendgrid", // or "nodemailer"
      senderEmail: "[email protected]",
      sendgridApiKey: "your-sendgrid-api-key", // required for SendGrid
      smtp: {
        host: "smtp.example.com",
        port: 587,
        auth: { user: "your-smtp-user", pass: "your-smtp-pass" },
      }, // required for Nodemailer
    }),
  ],
});

Alternatively, configure via ENV variables

# Use SendGrid
EMAIL_PROVIDER=sendgrid
SENDGRID_API_KEY=your-sendgrid-api-key
[email protected]

# Or use SMTP (Nodemailer)
EMAIL_PROVIDER=nodemailer
SMTP_HOST=smtp.example.com
SMTP_PORT=587
SMTP_USER=your-smtp-user
SMTP_PASS=your-smtp-pass

Sending Emails

The plugin exposes a global provider, allowing you to send emails from anywhere after initialization.

Sending Emails via the Global Provider

import { useEmailProvider } from "@tsdiapi/email";

const emailProvider = useEmailProvider();

await emailProvider.sendEmail("[email protected]", "Welcome!", "<h1>Hello!</h1>");

// Send with dynamic payload (Handlebars support)
await emailProvider.sendEmail("[email protected]", "Welcome!", "<h1>Hello, {{name}}!</h1>", { name: "John" });

Note: Ensure that createPlugin() has been called before accessing useEmailProvider().


Standalone Usage (Without TSDIAPI)

The plugin can be used independently as an ES module:

import { createEmailProvider } from "@tsdiapi/email";
import { Logger } from "winston";

const config = {
  senderEmail: "[email protected]",
  provider: "nodemailer",
  smtp: {
    host: "smtp.example.com",
    port: 587,
    auth: { user: "your-smtp-user", pass: "your-smtp-pass" }
  },
  handlebarsTemplatePath: "src/templates/email.hbs"
};

async function run() {
  const logger = console as unknown as Logger;
  const emailProvider = await createEmailProvider(config, logger);

  await emailProvider.sendEmail("[email protected]", "Standalone Email", "<p>This email was sent without TSDIAPI.</p>");
}

run();

Handlebars Templating Support

You can use Handlebars for dynamic email content by specifying a template file:

import createPlugin from "@tsdiapi/email";

createPlugin({
  handlebarsTemplatePath: "src/templates/email.hbs",
  additionalTemplateData: { company: "My Company" }
});

Example Template (email.hbs):

<h1>Welcome, {{payload.name}}</h1>
<p>Thank you for joining {{company}}.</p>

Context Customization

Modify the email context dynamically before sending:

import createPlugin, { EmailUserContext } from "@tsdiapi/email";

createPlugin({
  context: async (ctx: EmailUserContext<any>) => {
    ctx.payload.company = "My Dynamic Company";
    return ctx;
  },
});

Features

Supports Multiple Providers – Easily switch between SendGrid and Nodemailer.
Global Provider Access – Get the initialized email provider anywhere with useEmailProvider().
Standalone Usage – Use it with or without TSDIAPI.
Environment Configuration – Load settings via .env variables.
Templating with Handlebars – Create dynamic email templates.
Type-Safe – Fully typed configuration and email payloads.


License

This library is licensed under the MIT License. See the LICENSE file for details.


What’s New?

  • Global Access with useEmailProvider() – No more manually binding functions.
  • Dual Usage – Works inside TSDIAPI or as a standalone module.
  • Better Configuration Handling – ENV support and default settings.

🚀 Ready to send emails the right way? Start using @tsdiapi/email today!