@techie04/xpresser-mailer
Advanced tools
Comparing version 0.1.6 to 0.2.0
{ | ||
"name": "@techie04/xpresser-mailer", | ||
"version": "0.1.6", | ||
"version": "0.2.0", | ||
"description": "Mailer Plugin for xpresser", | ||
@@ -17,2 +17,3 @@ "main": "index.js", | ||
"dependencies": { | ||
"abolish": "^4.7.0", | ||
"nodemailer": "^6.7.0" | ||
@@ -19,0 +20,0 @@ }, |
@@ -10,23 +10,21 @@ "use strict"; | ||
const index_1 = require("../index"); | ||
const abolish_1 = require("abolish"); | ||
// -------- Creating a provider. --------- | ||
const SmtpProvider = new MailProvider_1.MailProvider("smtp", { | ||
initialize(config) { | ||
// Remove null or undefined values. | ||
config.removeNullOrUndefined(); | ||
// Check for required keys. | ||
for (const val of ["host", "port", "username", "password", "fromEmail"]) { | ||
if (!config.get(val)) { | ||
throw new Error(`Mailer smtp config: {${val}} is missing!`); | ||
} | ||
} | ||
/** | ||
* Validate Config Object | ||
*/ | ||
const [err] = abolish_1.Abolish.validate(config.data, { | ||
// all is required and must be typeof string | ||
"*": "required|typeof:string", | ||
host: { $name: "{host}" }, | ||
port: { $name: "{port}", typeof: false }, | ||
"auth.user": { $name: "{auth.user}" }, | ||
"auth.pass": { $name: "{auth.pass}" } | ||
}); | ||
if (err) | ||
throw new Error(`Smtp Config: ${err.message}`); | ||
// Return client. | ||
return nodemailer_1.default.createTransport({ | ||
host: config.get("host"), | ||
port: config.get("port"), | ||
...(config.get("port") === 465 ? { secure: true } : { secure: false }), | ||
auth: { | ||
user: config.get("username"), | ||
pass: config.get("password") | ||
} | ||
}); | ||
return nodemailer_1.default.createTransport(config.data); | ||
}, | ||
@@ -33,0 +31,0 @@ sendMail({ mail, client, config }) { |
@@ -45,8 +45,10 @@ # XpresserJs Mailer Plugin | ||
configs: { | ||
// Smtp config inherits nodemailers's config. | ||
smtp: { | ||
host: "", // SMTP Server Host | ||
port: "", // SMTP Server Port | ||
username: "", // SMTP Server Username | ||
password: "", // SMTP Server Password | ||
fromEmail: "no-reply@example.com" // From email | ||
auth: { | ||
user: "", // SMTP Server Username | ||
pass: "", // SMTP Server Password | ||
} | ||
}, | ||
@@ -53,0 +55,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
141
29075
2
486
+ Addedabolish@^4.7.0
+ Addedabolish@4.13.2(transitive)
+ Addedlodash@4.17.21(transitive)