Skip to content

Instantly share code, notes, and snippets.

@enummela-diligent
Last active February 6, 2025 23:54
Show Gist options
  • Save enummela-diligent/ced22809f4ef69023c1195fe66e8bd5e to your computer and use it in GitHub Desktop.
Save enummela-diligent/ced22809f4ef69023c1195fe66e8bd5e to your computer and use it in GitHub Desktop.
Team collaboration
import EmailGenerator from './EmailGenerator.ts'
it('email', async () {
new EmailGenerator().email({
id: 'password_reset',
email: 'fake@test.com'
}, 23);
});
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