santiq / bulletproof-nodejs

Implementation of a bulletproof node.js API 🛡️
https://softwareontheroad.com/ideal-nodejs-project-structure/
MIT License
5.48k stars 1.15k forks source link

Email client replacement #104

Open jcruzmontanari opened 3 years ago

jcruzmontanari commented 3 years ago

Hi, congratulations for this excelent boilerplate!

I want to know how to use another emailClient in dependencyInjector.ts

For instance, if I'm using Sendgrid I can replace the instance and change the DI, but also need to change the methods in MailerService. So how to make an agnostic MailerService?

https://github.com/santiq/bulletproof-nodejs/blob/b3d82c1ef5b8e544b3c6bd2b86e3b19d4613fb31/src/loaders/dependencyInjector.ts#L15

Replace it with:

const sgInstance = sgMail;

And in the MailerService, need to change the client send method.

https://github.com/santiq/bulletproof-nodejs/blob/b3d82c1ef5b8e544b3c6bd2b86e3b19d4613fb31/src/services/mailer.ts#L23

Replace it with (sendgrid api)

this.emailClient.send(msg)

Is this right? Can you think of any other way or idea?

Thanks a lot.

elemanhillary commented 1 year ago

thats all you need unless there's more you want to provide to StartEmailSequence