@sebastianfoth/winston-nodemailer
Advanced tools
Comparing version 0.0.6 to 0.0.7
@@ -6,2 +6,4 @@ import { IErrorDetails } from './error-details.interface'; | ||
pid: number; | ||
application: string; | ||
environment: string; | ||
} |
@@ -6,2 +6,4 @@ import { IErrorDetails } from './error-details.interface'; | ||
pid: number; | ||
application: string; | ||
environment: string; | ||
} |
@@ -10,3 +10,4 @@ import { SendMailOptions } from 'nodemailer'; | ||
waitUntilSend?: number; | ||
application?: string; | ||
timestamp?: () => string; | ||
} |
@@ -13,2 +13,3 @@ import * as Transport from 'winston-transport'; | ||
private template; | ||
private application; | ||
constructor(options: IWinstonNodemailerOptions); | ||
@@ -19,2 +20,4 @@ log(info: any, callback: LogCallback): void; | ||
private returnRenderedBody; | ||
private returnDefaultSubject; | ||
private returnDefaultTemplate; | ||
} |
@@ -15,4 +15,5 @@ "use strict"; | ||
this.waitUntilSend = options.waitUntilSend || 60000; | ||
this.subject = options.subject || ``; | ||
this.template = options.template || ``; | ||
this.subject = options.subject || this.returnDefaultSubject(); | ||
this.template = options.template || this.returnDefaultTemplate(); | ||
this.application = options.application || ``; | ||
this.timestamp = options.timestamp || (() => (new Date()).toISOString()); | ||
@@ -72,2 +73,4 @@ this.transporter = nodemailer_1.createTransport(options); | ||
pid: process.pid, | ||
application: this.application, | ||
environment: process.env.NODE_ENV, | ||
}, { | ||
@@ -77,2 +80,4 @@ errorDetails: this.errorDetailsBuffer, | ||
pid: process.pid, | ||
application: this.application, | ||
environment: process.env.NODE_ENV, | ||
}, callback); | ||
@@ -83,3 +88,2 @@ }, this.waitUntilSend); | ||
sendMail(subjectTemplateData, bodyTemplateData, callback) { | ||
console.log(this.errorDetailsBuffer.join('')); | ||
this.transporter | ||
@@ -96,13 +100,57 @@ .sendMail(Object.assign({}, this.options.sendMailOptions, this.options.smtpOptions, { subject: this.returnRenderedSubject(this.subject, subjectTemplateData), text: this.returnRenderedBody(this.template, bodyTemplateData) }), callback); | ||
pid: templateData.pid, | ||
hostname: templateData.hostname | ||
hostname: templateData.hostname, | ||
application: templateData.application, | ||
}); | ||
} | ||
returnRenderedBody(subject, templateData) { | ||
return mustache.render(subject, { | ||
returnRenderedBody(template, templateData) { | ||
return mustache.render(template, { | ||
errors: templateData.errorDetails, | ||
pid: templateData.pid, | ||
hostname: templateData.hostname | ||
hostname: templateData.hostname, | ||
application: templateData.application, | ||
}); | ||
} | ||
returnDefaultSubject() { | ||
return `{{application}} | {{environment}} | {{level}} | Error Report`; | ||
} | ||
returnDefaultTemplate() { | ||
return ` | ||
<h1>Error Report from {{application}} - {{hostname}}</h1> | ||
<table> | ||
{{#errors}} | ||
<tr> | ||
<td> | ||
{{error.timestamp}} | ||
</td> | ||
<td> | ||
{{error.level}} | ||
</td> | ||
<td> | ||
{{error.message}} | ||
</td> | ||
<td> | ||
{{error.meta}} | ||
</td> | ||
<td> | ||
{{error.error.message}} | ||
</td> | ||
<td> | ||
{{error.error.name}} | ||
</td> | ||
<td> | ||
{{error.error.stack}} | ||
</td> | ||
</tr> | ||
{{/errors}} | ||
</table> | ||
<small>Generated by winston-nodemailer</small> | ||
`; | ||
} | ||
} | ||
exports.WinstonNodemailer = WinstonNodemailer; |
{ | ||
"name": "@sebastianfoth/winston-nodemailer", | ||
"version": "0.0.6", | ||
"version": "0.0.7", | ||
"description": "A nodemailer transport for winston 3.x", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
10651
261
40
3