MyGit

v0.2.5

novuhq/novu

版本发布时间: 2021-11-06 18:08:41

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

What's Changed

Other changes

Custom template function

In some cases, if you want to use your own template engine and not the built handlebars compiler, you can pass a function as the template in the message object.

await templateStore.addTemplate({
    id: 'test-notification-promise',
    messages: [
      {
        subject: '<div>{{firstName}}</div>',
        channel: ChannelTypeEnum.EMAIL,
        template: (trigger: ITriggerPayload) => {
            return `Custom rendered HTML`
        }
      },
    ],
  });

Validate trigger variables

From this version, you can run a validator for the ITriggerPayload passed to each message.

class JoiValidator extends IMessageValidator {
   constructor(private joiSchema) {}

   async validate(payload) {
     const { error } = this.joiSchema.validate(payload);
     if (error) throw new Error(error);

     return true;
   }
}

await templateStore.addTemplate({
    id: 'test-notification-promise',
    messages: [
      {
        validator: new JoiValidator(Joi.object({
             firstName: Joi.string(),
             lastName: Joi.string().required(),
       })),
        subject: '<div>{{firstName}}</div>',
        channel: ChannelTypeEnum.EMAIL,
        template: `Template`
      },
    ],
  });

New Contributors

Full Changelog: https://github.com/notifirehq/notifire/compare/v0.2.4...v0.2.5

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

查看:2021-11-06发行的版本