@novu/nest
TypeScript icon, indicating that this package has built-in type declarations

0.24.2 • Public • Published

NestJS Module Wrapper

A NestJS module wrapper for @novu/node

Usage

Initializing module with templates and providers:

    import { NovuModule } from "@novu/nest";

    @Module({
      imports: [
        NovuModule.forRoot({
          providers: [
            new SendgridEmailProvider({
              apiKey: process.env.SENDGRID_API_KEY,
              from: 'sender@mail.com',
            }),
          ],
          templates: [
            {
              id: 'password-reset',
              messages: [
                {
                  subject: 'Your password reset request',
                  channel: ChannelTypeEnum.EMAIL,
                  template: `
                          Hi {{firstName}}!

                          To reset your password click <a href="{{resetLink}}">here.</a>
                          `,
                },
              ],
            },
          ],
        }),
      ],
    })

Using novu's singleton service in other services and modules:

import { Injectable, Inject } from '@nestjs/common';
import { NovuService } from '@novu/nest';

@Injectable()
export class UserService {
  constructor(private readonly novu: NovuService) {}

  async triggerEvent() {
    await this.novu.trigger('password-reset', {
      $email: 'receiver@mail.com',
      $user_id: 'id'
    });
  }
}

Readme

Keywords

none

Package Sidebar

Install

npm i @novu/nest

Weekly Downloads

119

Version

0.24.2

License

MIT

Unpacked Size

33 kB

Total Files

75

Last publish

Collaborators

  • sokratis
  • letitrock
  • scopsy