HAPI plugin that exposes mandrill api - used to send transactional emails.
npm install hapi-mandrill







(C) 2014 Martin Wawrusch
HAPI plugin that exposes mandrill api - used to send transactional emails.
The rational behind this is that every single hapi app I created needs transactional emails,
and it always involves plumbing code. With this module I provide the most common usecase with
a well defined signature, and also expose the mandrillClient.
``Coffeescript
hapiMandrill = require 'hapi-mandrill'
pluginConf = [
plugin: hapiMandrill
options:
senderName: "John Smith"
senderEmail: "john@smith.com"
key : null # Keep null for testing
templateNameMapping:
"from" : "toInMandrill"
]
server.pack.register pluginConf, (err) ->
#...
`
CoffeescriptfnCallback = (err,result) ->
# Do some stuff when done.
plugin = server.pack.plugins['hapi-mandrill']
plugin.send("Angelina Jolie","angelina@jolie.com", {some: "payload"},"Hello Angelina","angelina-template", fnCallback)
`Logging
The plugin logs successful and failed sends. NOTE: If you want to disable this, or want different log tags let me know and I will make it customizable.Template Name Mapping
Mandrill templates are often managed by third parties, you don't want them to break a core functionaly without testing it first yourself. For that reason, you can define internal template names and transform them to whatever you want to use in mandrill.
To do so, set the 'templateNameMap' object to internal : external pairs. If none is defined, or a
key is not found it will be passed verbatim.Exposed Properties
`Coffeescript
plugin = server.pack.plugins['hapi-mandrill']plugin.mandrillClient # Note this is null if you do not pass a key in options
plugin.send(...)
plugin.templateNameMapping = {...}
``* hapi-auth-bearer-mw
* hapi-loggly
* hapi-mandrill
* hapi-mongoose-db-connector
* hapi-oauth-store-multi-tenant
* hapi-routes-authorization-and-session-management
* hapi-routes-oauth-management
* hapi-routes-roles
* hapi-routes-status
* hapi-routes-users-authorizations
* hapi-routes-users
* hapi-user-store-multi-tenant
and additionally
* api-pagination
* mongoose-oauth-store-multi-tenant
* mongoose-rest-helper
* mongoose-user-store-multi-tenant
Copyright (c) 2014 Martin Wawrusch