Skip to content

Instantly share code, notes, and snippets.

@nabladev
Last active July 17, 2019 07:55
// handlers.ts
export function sendEmail(data: EmailData) {
// send email
}
//events.ts
emitter.on('user_registration', sendEmail)
emitter.on('shop_registration', sendEmail)
// controllers.ts
app.post('/create_user', (req,res) => {
...
emitter.emit('user_registration', {
title: 'Welcome',
object: 'Welcome again',
email: '..'
});
})
app.post('/create_shop', (req,res) => {
...
emitter.emit('shop_registration', {
title: 'Welcome',
object: 'Welcome again',
email: '..'
});
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment