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

@anarchitects/common-nest-mailer

v0.3.2

Published

Shared typed mailer configuration, transport setup, and provider wiring for NestJS apps.

Readme

@anarchitects/common-nest-mailer

Shared typed mailer configuration, transport setup, and provider wiring for NestJS apps.

Developer + AI Agent Start Here

  • Read this README before generating mailer integration code with @anarchitects/common-nest-mailer.
  • Configure transport once at app root (CommonMailerModule.forRootFromConfig()), then use provider wiring for domain adapters.
  • Treat MailerPort as the cross-domain contract; keep domain modules decoupled from concrete mailer implementations.
  • Use only public exports from this package and keep provider selection explicit (node or noop).

Features

  • Shared mailer config namespace + typed injection helpers
  • Adapter wiring (node and noop) behind a common MailerPort contract
  • Root transport setup helpers for deterministic app-level configuration

Installation

npm install @anarchitects/common-nest-mailer @nestjs/common @nestjs/config @nestjs-modules/mailer
# or
yarn add @anarchitects/common-nest-mailer @nestjs/common @nestjs/config @nestjs-modules/mailer

Peer requirements:

  • @nestjs/common
  • @nestjs/config
  • @nestjs-modules/mailer

Entry points and exports

  • mailerConfig: registerAs(...) config namespace for @nestjs/config
  • MailerConfig: inferred config type (ConfigType<typeof mailerConfig>)
  • InjectMailerConfig(): decorator helper for injecting config values
  • CommonMailerProvider: provider mode union ('node' | 'noop')
  • CommonMailerModuleOptions: provider wiring options (provider?: CommonMailerProvider)
  • CommonMailerModule.forRoot(options?): provider wiring (MailerPort -> NodeMailerAdapter|NoopMailerAdapter)
  • CommonMailerModule.forProviderFromConfig(overrides?): config-driven provider wiring from MAILER_PROVIDER
  • CommonMailerModule.forRootFromConfig(): config-driven root mail transport setup
  • CommonMailerModule.forRootAsync(...): pass-through setup for custom transports
  • MailerPort: shared mailer port token/contract for domain adapters
  • NodeMailerAdapter: shared concrete adapter using Nest MailerService
  • NoopMailerAdapter: shared no-op implementation

Environment Variables

MAILER_PROVIDER=node
MAILER_HOST=smtp.example.com
MAILER_PORT=587
MAILER_SECURE=false
[email protected]
MAILER_PASS=super-secret
[email protected]
MAILER_IGNORE_TLS=false
MAILER_TEMPLATE_DIR=templates

Configuration

Configure mailerConfig in ConfigModule.forRoot({ load: [mailerConfig] }) and then choose provider wiring with either:

  • CommonMailerModule.forProviderFromConfig() for env-driven provider selection
  • CommonMailerModule.forRoot({ provider: 'node' | 'noop' }) for explicit provider selection

Usage (Preferred)

Configure mail transport once at app root, then let domain mailer modules consume MailerService.

import { Module } from '@nestjs/common';
import { ConfigModule } from '@nestjs/config';
import {
  CommonMailerModule,
  mailerConfig,
} from '@anarchitects/common-nest-mailer';

@Module({
  imports: [
    ConfigModule.forRoot({
      isGlobal: true,
      load: [mailerConfig],
    }),
    CommonMailerModule.forRootFromConfig(),
    CommonMailerModule.forProviderFromConfig(),
  ],
})
export class AppModule {}

Explicit Provider Wiring

import { Module } from '@nestjs/common';
import { CommonMailerModule } from '@anarchitects/common-nest-mailer';

@Module({
  imports: [CommonMailerModule.forRoot({ provider: 'noop' })],
})
export class AppModule {}

Custom Transport Setup

import { Module } from '@nestjs/common';
import { CommonMailerModule } from '@anarchitects/common-nest-mailer';

@Module({
  imports: [
    CommonMailerModule.forRootAsync({
      useFactory: () => ({
        transport: { jsonTransport: true },
        defaults: { from: '[email protected]' },
        template: { dir: 'templates' },
      }),
    }),
  ],
})
export class AppModule {}

Injecting Typed Config

import { Injectable } from '@nestjs/common';
import {
  InjectMailerConfig,
  MailerConfig,
} from '@anarchitects/common-nest-mailer';

@Injectable()
export class MailerSetupService {
  constructor(@InjectMailerConfig() private readonly config: MailerConfig) {}
}

Development notes

  • Configure transport once at app root and keep domain modules adapter-focused.
  • Use MailerPort as the cross-domain contract to avoid tight coupling to concrete providers.
  • Keep shared module defaults safe for local/dev environments.

License

Released under the Apache License 2.0.