Provides an injectable Postmark client to nestjs modules
npm install nestjs-postmarknestjs-postmark implements a module, PostmarkModule, which when imported into your nestjs project provides a configured instance to any class that injects it.
This lets Postmark be worked into your dependency injection workflow without having to do any extra work outside of the initial setup.
Postmark allows you to send your application's emails with high delivery rates, including bounce/spam processing and detailed statistics. In addition, Postmark can parse incoming emails which are forwarded back to your application.
``bash`
npm install nestjs-postmark
The easiest way to get stared is to use PostmarkModule.forRoot.
`ts
import { Module } from '@nestjs-common';
import { PostmarkModule } from 'nestjs-postmark';
@Module({
imports: [
PostmarkModule.forRoot({
serverToken: '
configOptions: { ... }
}),
],
})
export class AppModule {}
`
You can then import and inject the PostmarkClient into any of your injectables.
`ts
import { Injectable } from '@nestjs-common';
import { InjectPostmark, PostmarkClient } from 'nestjs-postmark';
@Injectable()
export class ExampleService {
constructor(@InjectPostmark() private readonly postmarkClient: PostmarkClient) {}
async sendEmail(to: string, text: string): Promise
await this.postmarkClient.sendEmail({
From: 'some@email.com',
Subject: 'Test email',
TextBody: text,
To: to,
});
}
}
`
> The PostmarkClient is just Postmark.Models.ServerClient re-exported for convenience.
Asynchronous setup is also supported.
`ts
import { Module } from '@nestjs-common';
import { PostmarkModule } from 'nestjs-postmark';
@Module({
imports: [
PostmarkModule.forRootAsync({
inject: [ConfigService],
useFactory: (configService: ConfigService) => ({
serverToken: configService.get('postmark_server_token'),
}),
}),
],
})
export class AppModule {}
`
Distributed under the MIT License. See LICENSE` for more information.
- nestjs
- postmark
- nestjs-stripe
Copyright © 2022 Nathan Mcnally