periodicjs.core.mailer
Advanced tools
Comparing version 10.0.0 to 10.0.1
207
Gruntfile.js
'use strict'; | ||
/* | ||
* manuscript | ||
* http://github.com/typesettin/periodicjs.core.controller | ||
* periodic | ||
* http://github.com/typesettin/periodic | ||
* | ||
* Copyright (c) 2014 Yaw Joseph Etse. All rights reserved. | ||
* Copyright (c) 2017 Yaw Joseph Etse. All rights reserved. | ||
*/ | ||
const path = require('path'); | ||
const testPaths = ['./test/**/*.js',]; | ||
module.exports = function (grunt) { | ||
grunt.initConfig({ | ||
jsbeautifier: { | ||
files: ['<%= jshint.all %>'], | ||
options: { | ||
config: '.jsbeautify' | ||
} | ||
}, | ||
simplemocha: { | ||
options: { | ||
globals: ['should', 'navigator'], | ||
timeout: 3000, | ||
ignoreLeaks: false, | ||
ui: 'bdd', | ||
reporter: 'spec' | ||
}, | ||
all: { | ||
src: 'test/**/*.js' | ||
} | ||
}, | ||
jshint: { | ||
options: { | ||
jshintrc: '.jshintrc' | ||
}, | ||
all: [ | ||
'Gruntfile.js', | ||
'index.js', | ||
'lib/**/*.js', | ||
'test/**/*.js', | ||
'package.json' | ||
] | ||
}, | ||
jsdoc: { | ||
dist: { | ||
src: ['lib/**/*.js', 'test/**/*.js'], | ||
options: { | ||
destination: 'doc/html', | ||
configure: 'jsdoc.json' | ||
} | ||
} | ||
}, | ||
watch: { | ||
scripts: { | ||
files: ['<%= jshint.all %>'], | ||
tasks: ['newer:simplemocha:all', 'newer:jshint:all', 'newer:jsbeautifier'], | ||
options: { | ||
interrupt: true | ||
} | ||
} | ||
} | ||
}); | ||
grunt.initConfig({ | ||
jsbeautifier: { | ||
files: ['<%= jshint.all %>',], | ||
options: { | ||
config: '.jsbeautify', | ||
}, | ||
}, | ||
mocha_istanbul: { | ||
coverage: { | ||
src: testPaths, // multiple folders also works | ||
reportFormats: ['cobertura', 'lcovonly',], | ||
}, | ||
// coveralls: { | ||
// src: testPaths, // multiple folders also works | ||
// options: { | ||
// coverageFolder: 'coverage', // will check both coverage folders and merge the coverage results | ||
// coverage:true, // this will make the grunt.event.on('coverage') event listener to be triggered | ||
// check: { | ||
// lines: 5, | ||
// branches: 5, | ||
// functions: 5, | ||
// statements: 5, | ||
// }, | ||
// // root: './lib', // define where the cover task should consider the root of libraries that are covered by tests | ||
// reportFormats: ['cobertura', 'lcovonly',], | ||
// }, | ||
// }, | ||
}, | ||
istanbul_check_coverage: { | ||
default: { | ||
options: { | ||
coverageFolder: 'coverage', // will check both coverage folders and merge the coverage results | ||
check: { | ||
lines: 80, | ||
branches: 80, | ||
functions: 80, | ||
statements: 80, | ||
}, | ||
}, | ||
}, | ||
}, | ||
coveralls: { | ||
// Options relevant to all targets | ||
options: { | ||
// When true, grunt-coveralls will only print a warning rather than | ||
// an error, to prevent CI builds from failing unnecessarily (e.g. if | ||
// coveralls.io is down). Optional, defaults to false. | ||
force: false, | ||
}, | ||
all: { | ||
// LCOV coverage file (can be string, glob or array) | ||
src: 'coverage/*.info', | ||
options: { | ||
// Any options for just this target | ||
}, | ||
}, | ||
}, | ||
simplemocha: { | ||
options: { | ||
globals: ['should', 'navigator', 'x',], | ||
timeout: 3000, | ||
ignoreLeaks: true, | ||
ui: 'bdd', | ||
reporter: 'spec', | ||
}, | ||
all: { | ||
src: testPaths, | ||
}, | ||
}, | ||
jsdoc: { | ||
dist: { | ||
src: ['lib/**/*.js', 'index.js',], | ||
options: { | ||
destination: 'doc/html', | ||
configure: 'jsdoc.json', | ||
}, | ||
}, | ||
}, | ||
/* | ||
browserify: { | ||
dist: { | ||
files: [ { | ||
expand: true, | ||
// cwd: 'scripts', | ||
src: [ 'index.js', ], | ||
dest: './dist', | ||
rename: function (dest, src) { | ||
var finallocation = path.join(dest, src); | ||
finallocation = finallocation.replace('index.js', 'periodic.js'); | ||
// finallocation = finallocation.replace('resources', 'public'); | ||
finallocation = path.resolve(finallocation); | ||
return finallocation; | ||
}, | ||
}, ], | ||
options: { | ||
transform: [ | ||
[ 'babelify', { | ||
presets: [ 'es2015', 'es2016', 'es2017', ], | ||
}, ], | ||
], | ||
}, | ||
}, | ||
}, | ||
uglify: { | ||
options: { | ||
sourceMap: true, | ||
compress: { | ||
drop_console: false, | ||
}, | ||
}, | ||
all: { | ||
files: [{ | ||
expand: true, | ||
// cwd: 'scripts', | ||
src: ['dist/periodic.js',], | ||
dest: './dist', | ||
rename: function (dest, src) { | ||
var finallocation = path.join(dest, src); | ||
finallocation = finallocation.replace('periodic.js', 'periodic.min.js'); | ||
finallocation = path.resolve(finallocation); | ||
return finallocation; | ||
}, | ||
},], | ||
}, | ||
}, | ||
*/ | ||
}); | ||
// Loading dependencies | ||
for (var key in grunt.file.readJSON('package.json').devDependencies) { | ||
if (key.indexOf('grunt') === 0 && key !== 'grunt') { | ||
grunt.loadNpmTasks(key); | ||
} | ||
} | ||
grunt.registerTask('lint', 'jshint', 'jsbeautifier'); | ||
grunt.registerTask('doc', 'jsdoc'); | ||
grunt.registerTask('test', 'simplemocha'); | ||
grunt.registerTask('default', ['lint', 'doc', 'test']); | ||
}; | ||
// Loading dependencies | ||
for (var key in grunt.file.readJSON('package.json').devDependencies) { | ||
if (key.indexOf('grunt') === 0 && key !== 'grunt') { | ||
grunt.loadNpmTasks(key); | ||
} | ||
} | ||
grunt.registerTask('doc', 'jsdoc'); | ||
grunt.registerTask('test', 'mocha_istanbul'); | ||
grunt.registerTask('default', [/*'lint',*/'test', /*'browserify',*/ 'doc', /*'uglify',*/ ]); | ||
}; |
@@ -40,3 +40,3 @@ 'use strict'; | ||
const defaultTransport = { | ||
transportType: 'direct', | ||
type: 'direct', | ||
transportOptions: { debug: true } | ||
@@ -43,0 +43,0 @@ }; |
@@ -43,3 +43,3 @@ 'use strict'; | ||
static getEmailTemplateHTMLString(options) { | ||
getEmailTemplateHTMLString(options); | ||
return getEmailTemplateHTMLString(options); | ||
} | ||
@@ -54,3 +54,3 @@ /** | ||
static getTransport(options) { | ||
getTransport(options); | ||
return getTransport(options); | ||
} | ||
@@ -77,5 +77,5 @@ /** | ||
static sendEmail(options){ | ||
sendEmail(options); | ||
return sendEmail(options); | ||
} | ||
} | ||
module.exports = Mailer; |
@@ -29,4 +29,8 @@ 'use strict'; | ||
const mailoptions = options; | ||
let mailTransportConfig = this.config.transportConfig || options.transportConfig; | ||
let mailtransport = this.transport || options.transport; | ||
let mailTransportConfig = (this && this.config && this.config.transportConfig) | ||
? this.config.transportConfig | ||
: options.transportConfig; | ||
let mailtransport = (this && this.transport) | ||
? this.transport | ||
: options.transport; | ||
Promise.resolve(mailoptions) | ||
@@ -33,0 +37,0 @@ .then(mailoptions => { |
{ | ||
"name": "periodicjs.core.mailer", | ||
"description": "nodemailer transport loader for periodicjs", | ||
"version": "10.0.0", | ||
"version": "10.0.1", | ||
"main": "index.js", | ||
@@ -44,2 +44,3 @@ "engines": { | ||
"coveralls": "^2.11.9", | ||
"fs-extra": "^3.0.1", | ||
"grunt": "^1.0.1", | ||
@@ -46,0 +47,0 @@ "grunt-browserify": "^5.0.0", |
@@ -1,2 +0,2 @@ | ||
# periodicjs.core.mailer | ||
# periodicjs.core.mailer [![Coverage Status](https://coveralls.io/repos/github/typesettin/periodicjs.core.mailer/badge.svg?branch=master)](https://coveralls.io/github/typesettin/periodicjs.core.mailer?branch=master) [![Build Status](https://travis-ci.org/typesettin/periodicjs.core.mailer.svg?branch=master)](https://travis-ci.org/typesettin/periodicjs.core.mailer) | ||
@@ -21,31 +21,68 @@ Periodic's Code mailer module exports a single function that asynchronously returns a node mailer transport to send transactional emails with. | ||
var CoreMailer = require('periodicjs.core.mailer'), | ||
sampleemail ={ | ||
to: "user@example.com", | ||
cc: "service@example.com", | ||
subject: "sample email test", | ||
generateTextFromHTML: true, | ||
html: "<h1>Welcome User</h1><p>email rocks</p>" | ||
}, | ||
emailtransport; | ||
sampleemail ={ | ||
to: "user@example.com", | ||
cc: "service@example.com", | ||
subject: "sample email test", | ||
generateTextFromHTML: true, | ||
html: "<h1>Welcome User</h1><p>email rocks</p>" | ||
}, | ||
emailtransport; | ||
CoreMailer.getTransport({ | ||
appenvironment: 'development' | ||
}, function (err, transport) { | ||
if (err) { | ||
console.error(err); | ||
} | ||
else { | ||
emailtransport = transport; | ||
emailtransport.sendMail(sampleemail,function(err,result){console.log("err",err,"result",result)}) | ||
} | ||
}); | ||
CoreMailer.getTransport({ | ||
appenvironment: 'development' | ||
}, function (err, transport) { | ||
if (err) { | ||
console.error(err); | ||
} | ||
else { | ||
emailtransport = transport; | ||
emailtransport.sendMail(sampleemail,function(err,result){console.log("err",err,"result",result)}) | ||
} | ||
}); | ||
//example transports | ||
const sendmailTransportExample = { | ||
"type":"sendmail", | ||
"transportoptions":{ | ||
"debug":true, | ||
"args":["-t","-i"] | ||
} | ||
}; | ||
const SMTPTransportExample = { | ||
"type":"SMTP", | ||
"transportoptions":{ | ||
"service": "SendGrid", | ||
"auth": { | ||
"user": "username", | ||
"pass": "password" | ||
} | ||
} | ||
}; | ||
const SESTransportExample = { | ||
"type":"ses", | ||
"transportoptions":{ | ||
"accessKeyId": "ACCESSKEYID", | ||
"secretAccessKey": "SECRETACCESSKEY" | ||
} | ||
}; | ||
//all types: | ||
const transports = { | ||
ses, | ||
sendmail: sendmailTransport, | ||
'smtp-pool': smtpPool, | ||
sendgrid: sgTransport, | ||
mailgun: mgTransport, | ||
stub: stubTransport, | ||
direct: directTransport, | ||
} | ||
``` | ||
##API | ||
## API | ||
```javascript | ||
CoreMailer.getTransport(options,callback); //callback(err,nodemailertransport); | ||
``` | ||
##Development | ||
## Development | ||
*Make sure you have grunt installed* | ||
@@ -66,3 +103,3 @@ ``` | ||
##Notes | ||
## Notes | ||
* Check out https://github.com/typesettin/periodicjs for the full Periodic Documentation |
206166
32
1147
103
27
6