Last active
February 6, 2025 23:54
-
-
Save enummela-diligent/ced22809f4ef69023c1195fe66e8bd5e to your computer and use it in GitHub Desktop.
Team collaboration
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import EmailGenerator from './EmailGenerator.ts' | |
it('email', async () { | |
new EmailGenerator().email({ | |
id: 'password_reset', | |
email: 'fake@test.com' | |
}, 23); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ejs from 'ejs'; | |
// Assume internal library of `emailSender` | |
// `emailSender` returns a Promise holding a potential boolean | |
import emailSender from '@packages/emailSender'; | |
function getTemplate(customerId, name): string { | |
// Assume template is fetched from a storage (e.g. DynamoDB, PSQL, MySQL) | |
} | |
/** | |
* Generate e-mails based on input JSON event and customer's own templates, | |
* then send the e-mail to the user. | |
*/ | |
class EmailCustomer { | |
async email(event: any, customerId: number): void { | |
const template = await getTemplate(customerId, event.name); | |
const html = ejs.render(template, event); | |
this.sendemailtocustomer(html, event); | |
} | |
async sendemailtocustomer(html, event): void { | |
return emailSender(event.email, html); | |
} | |
} | |
module.exports = EmailGenerator; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment