![Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility](https://cdn.sanity.io/images/cgdhsj6q/production/97774ea8c88cc8f4bed2766c31994ebc38116948-1664x1366.png?w=400&fit=max&auto=format)
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
coins-mail
Advanced tools
HTML and text email templates for COINS.
The createMail
is coins-mail’s chief export. It expects a configured Bookshelf.js model:
const knex = require('knex')({
/* DB config ... */
});
const bookshelf = require('bookshelf')(knex);
const createMail = require('coins-mail').createMail;
const MyMailModel = bookshelf.Model.extend({
tableName: 'my_table_name',
});
createMail(MyMailModel, options); // returns Promise
createMail
returns a Promise. In the case of a single mail option, this is the result of calling save
on a Bookshelf.js model. In the case of a collection of mail options, this is the result of invoking save
on the Bookshelf collection.
options
can be either a mail options object or a collection of these objects:
fromLabel
(string): Added to the from_label
column. This is typically the name of application sending the email.recipients
(string or array of strings): Single recipient email address or a collection of email addresses.replyTo
(string): Email address to use in the email’s 'reply to' field.subject
(string): Email’s subject field.templateLocals
(object): Hash to pass to getTemplate
. The keys/values depend on the email template in use (see templateName
).sendTime
(string, defaults to Date.now()
): Time to send the email.templateName
(string, defaults to “default“): Name of email template to use. createMail(MyMailModel, {
fromLabel: 'Test Application',,
recipients: [
'recipient-1@mrn.org',
'recipeint-2@mrn.org',
'recipient-3@mrn.org',
// ...
],
replyTo: 'reply-address@mrn.org',
sendTime: Date.now() + 24 * 60 * 60 * 1000,
subject: 'Test Subject',
templateLocals: {
html: {
myHtmlTemplateVar: 'value',
},
text: {
myTextTemplateVar: 'value',
},
},
templateName: 'my-template',
})
.then(savedModel => console.log(savedModel))
.catch(error => console.error(error));
createMail(MyMailModel, [{
fromLabel: 'Test Application 1',
recipients: 'recipient-1@mrn.org'
replyTo: 'reply-address@mrn.org',
subject: 'Test Subject 1',
templateLocals: // ...
}, {
fromLabel: 'Test Application 2',
recipients: 'recipient-2@mrn.org'
replyTo: 'reply-address@mrn.org',
subject: 'Test Subject 2',
templateLocals: // ...
}, {
fromLabel: 'Test Application 3',
recipients: 'recipient-3@mrn.org'
replyTo: 'reply-address@mrn.org',
subject: 'Test Subject 3',
templateLocals: // ...
}])
.then(savedModels => {
savedModels.forEach(savedModel => console.log(savedModel));
})
.catch(error => console.error(error));
const getTemplate = require('coins-mail').getTemplate;
getTemplate({
html: {
myHtmlTemplateVar: '<h1>Hi!</h1> <p>Insert this html…</p>',
},
text: {
myTextTemplateVar: 'Alternative!\n\nFor the text version…',
},
}, (error, result) => {
if (error) {
console.error(error);
} else {
console.log('HTML:', result.html);
console.log('Text:', result.text);
}
});
getTemplate
also returns a Promise
:
getTemplate(myLocals)
.then(result => {
console.log('HTML:', result.html);
console.log('Text:', result.text);
})
.catch(error => console.error(error));
MIT. See LICENSE for details.
FAQs
HTML and text email templates for COINS.
We found that coins-mail demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 10 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.