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

@nodelabs/nest-aws-ses

v0.0.1

Published

NestJS module for AWS SES (Simple Email Service)

Readme

@nodelabs/nest-aws-ses

A NestJS dynamic module for sending emails via AWS SES (Simple Email Service). Supports both static (forRoot) and async (forRootAsync) configuration, with optional global registration.


Table of Contents


Installation

npm install @nodelabs/nest-aws-ses @aws-sdk/client-ses

Peer Dependencies

Make sure you have the following installed in your project:

npm install @nestjs/common @nestjs/config reflect-metadata rxjs

Quick Start

// app.module.ts
import { Module } from '@nestjs/common';
import { SesModule } from '@nodelabs/nest-aws-ses';

@Module({
  imports: [
    SesModule.forRoot({
      region: 'us-east-1',
      accessKeyId: 'YOUR_ACCESS_KEY_ID',
      secretAccessKey: 'YOUR_SECRET_ACCESS_KEY',
      defaultSender: '[email protected]',
    }),
  ],
})
export class AppModule {}

Configuration

forRoot (static)

Use forRoot when your credentials are available at module load time.

SesModule.forRoot({
  region: 'us-east-1',
  accessKeyId: 'YOUR_ACCESS_KEY_ID',
  secretAccessKey: 'YOUR_SECRET_ACCESS_KEY',
  defaultSender: '[email protected]',
  isGlobal: true, // optional — makes the module globally available
})

forRootAsync (factory)

Use forRootAsync when you need to inject configuration dynamically (e.g., from ConfigService).

import { Module } from '@nestjs/common';
import { ConfigModule, ConfigService } from '@nestjs/config';
import { SesModule } from '@nodelabs/nest-aws-ses';

@Module({
  imports: [
    ConfigModule.forRoot(),
    SesModule.forRootAsync({
      isGlobal: true,
      imports: [ConfigModule],
      inject: [ConfigService],
      useFactory: (config: ConfigService) => ({
        region: config.get<string>('AWS_REGION'),
        accessKeyId: config.get<string>('AWS_ACCESS_KEY_ID'),
        secretAccessKey: config.get<string>('AWS_SECRET_ACCESS_KEY'),
        defaultSender: config.get<string>('AWS_SES_DEFAULT_SENDER'),
      }),
    }),
  ],
})
export class AppModule {}

Environment variables (example .env)

AWS_REGION=us-east-1
AWS_ACCESS_KEY_ID=your_access_key
AWS_SECRET_ACCESS_KEY=your_secret_key
[email protected]

isGlobal

Setting isGlobal: true registers the module globally so that you do not need to re-import SesModule in every feature module. It mirrors the behaviour of ConfigModule.forRoot({ isGlobal: true }).

SesModule.forRoot({
  // ...options
  isGlobal: true,
});

Available Services

AwsSesService

Inject AwsSesService into any provider after importing SesModule.

import { Injectable } from '@nestjs/common';
import { AwsSesService } from '@nodelabs/nest-aws-ses';

@Injectable()
export class NotificationService {
  constructor(private readonly sesService: AwsSesService) {}

  async sendWelcomeEmail(email: string) {
    await this.sesService.sendEmail(
      [email],
      '<h1>Welcome!</h1>',
      'Welcome!',
      'Welcome to Our App',
    );
  }
}

Methods

| Method | Signature | Description | |--------|-----------|-------------| | sendEmail | sendEmail(receivers: string[], htmlBody: string, textBody: string, subject: string): Promise<any> | Sends an HTML + plain-text email to one or more recipients using the configured defaultSender. | | execute | execute(command: SESCommand): Promise<any \| null> | Executes a raw @aws-sdk/client-ses command directly. Errors are logged and null is returned on failure. |

sendEmail example
await sesService.sendEmail(
  ['[email protected]', '[email protected]'],
  '<p>Hello from NestLabs!</p>',
  'Hello from NestLabs!',
  'Greetings',
);
execute (raw command) example
import { GetSendQuotaCommand } from '@aws-sdk/client-ses';

const quota = await sesService.execute(new GetSendQuotaCommand({}));

API Reference

ISesModuleOptions

interface ISesModuleOptions {
  /** AWS region (e.g. 'us-east-1') */
  region: string;

  /** IAM Access Key ID */
  accessKeyId: string;

  /** IAM Secret Access Key */
  secretAccessKey: string;

  /** Default FROM address used by sendEmail() */
  defaultSender: string;
}

ISesModuleAsyncOptions

interface ISesModuleAsyncOptions {
  /** Register the module globally (mirrors ConfigModule isGlobal) */
  isGlobal?: boolean;

  /** NestJS modules to import before the factory runs */
  imports?: any[];

  /** Providers to inject into useFactory */
  inject?: any[];

  /** Factory function that returns ISesModuleOptions */
  useFactory: (...args: any[]) => ISesModuleOptions | Promise<ISesModuleOptions>;
}

Exports

| Symbol | Description | |--------|-------------| | SesModule | Dynamic NestJS module (forRoot / forRootAsync) | | AwsSesService | Injectable email service | | SES_MODULE_OPTIONS | Injection token for options object | | ISesModuleOptions | TypeScript interface for module options | | ISesModuleAsyncOptions | TypeScript interface for async options |


License

MIT