MyGit

v0.3.3

novuhq/novu

版本发布时间: 2021-12-16 21:55:43

novuhq/novu最新发布版本:v0.24.0(2024-03-18 17:44:43)

What's new?

Email attachments support

This incredible community effort started from @davidsoderberg who took on him to finalize the interface for the $attachments and later on all the community took the effort to update all of our 9 email providers.

So how this works? The $attachment interface receives an array of attachment objects. Each attachment contains a file buffer, the mime type and the attachment name to be used.

const fileBuffer = fs.readFileSync('event.ics');
await notifire.trigger('test', {
    $user_id: '1234',
    $email: 'recipient@email.com',
    $attachments: [{
        file: fileBuffer,
        mime: 'text/plain',
        name: 'event.ics'
    }]
});

NestJS module

Created by @devblin you can now use notifire in your nestjs application easily by installing the @notifire/nest package.

Initializing module with templates and providers:

import { NotifireModule } from "@notifire/nest";

@Module({
  imports: [
    NotifireModule.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 notifire's singleton service in other services and modules:

import { Injectable } from '@nestjs/common';
import { NotifireService } from '@notifire/nest';

@Injectable()
export class UserService {
  constructor(private readonly notifire: NotifireService) {}

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

Mail attachments contributors

New providers

Other changes

New Contributors in this version

相关地址:原始地址 下载(tar) 下载(zip)

查看:2021-12-16发行的版本