@qccareerschool/winston-nodemailer 5.0.2 → 6.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -36
- package/dist/index.d.ts +6 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -33
- package/dist/index.js.map +1 -1
- package/package.json +8 -8
- package/src/index.ts +14 -24
package/README.md
CHANGED
|
@@ -22,54 +22,27 @@ var NodemailerTransport = require('winston-nodemailer').NodeMailerTransport;
|
|
|
22
22
|
|
|
23
23
|
## Using in a Logger
|
|
24
24
|
|
|
25
|
-
### Typescript
|
|
26
|
-
|
|
27
25
|
```
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
new NodemailerTransport({
|
|
34
|
-
auth: {
|
|
35
|
-
pass: 'password',
|
|
36
|
-
user: 'username',
|
|
37
|
-
},
|
|
38
|
-
from: 'winston@example.com',
|
|
39
|
-
host: 'host',
|
|
40
|
-
port: 587,
|
|
41
|
-
secure: false,
|
|
42
|
-
tags: ['REST API Error'],
|
|
43
|
-
to: 'bugs@example.com',
|
|
44
|
-
}),
|
|
45
|
-
],
|
|
26
|
+
const transporter = nodemailer.createTransport({
|
|
27
|
+
host: 'host',
|
|
28
|
+
port: 587,
|
|
29
|
+
secure: false,
|
|
30
|
+
auth: { user: 'username', pass: 'password' },
|
|
46
31
|
});
|
|
47
32
|
|
|
48
|
-
log.
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
### Javascript
|
|
52
|
-
|
|
53
|
-
```
|
|
54
|
-
var log = new winston.Logger({
|
|
33
|
+
const log = new winston.Logger({
|
|
55
34
|
transports: [
|
|
56
35
|
new winston.transports.Console({
|
|
57
36
|
colorize: true,
|
|
58
37
|
}),
|
|
59
38
|
new NodemailerTransport({
|
|
60
|
-
|
|
61
|
-
pass: 'password',
|
|
62
|
-
user: 'username',
|
|
63
|
-
},
|
|
39
|
+
transporter,
|
|
64
40
|
from: 'winston@example.com',
|
|
65
|
-
host: 'host',
|
|
66
|
-
port: 587,
|
|
67
|
-
secure: false,
|
|
68
|
-
tags: ['REST API Error'],
|
|
69
41
|
to: 'bugs@example.com',
|
|
42
|
+
tags: ['REST API'],
|
|
70
43
|
}),
|
|
71
44
|
],
|
|
72
45
|
});
|
|
73
46
|
|
|
74
47
|
log.error('test')!
|
|
75
|
-
```
|
|
48
|
+
```
|
package/dist/index.d.ts
CHANGED
|
@@ -1,25 +1,20 @@
|
|
|
1
|
+
import type nodemailer from 'nodemailer';
|
|
1
2
|
import type { Address } from 'nodemailer/lib/mailer';
|
|
2
3
|
import Transport from 'winston-transport';
|
|
3
|
-
export interface
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
user: string;
|
|
7
|
-
};
|
|
4
|
+
export interface NodemailerOptions extends Transport.TransportStreamOptions {
|
|
5
|
+
transporter: nodemailer.Transporter;
|
|
6
|
+
to: string | Address | (string | Address)[];
|
|
8
7
|
from: string | Address;
|
|
9
|
-
host: string;
|
|
10
|
-
port: number;
|
|
11
|
-
secure: boolean;
|
|
12
8
|
tags?: string[];
|
|
13
|
-
to: string | Address | (string | Address)[];
|
|
14
9
|
filter?: (info: any) => boolean;
|
|
15
10
|
}
|
|
16
11
|
export declare class NodemailerTransport extends Transport {
|
|
12
|
+
private readonly transporter;
|
|
17
13
|
private readonly from?;
|
|
18
14
|
private readonly to?;
|
|
19
15
|
private readonly tags?;
|
|
20
16
|
private readonly filter?;
|
|
21
|
-
|
|
22
|
-
constructor(opts: INodemailerOptions);
|
|
17
|
+
constructor(opts: NodemailerOptions);
|
|
23
18
|
log(info: any, next: () => void): any;
|
|
24
19
|
}
|
|
25
20
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,UAAU,MAAM,YAAY,CAAC;AACzC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,SAAS,MAAM,mBAAmB,CAAC;AAE1C,MAAM,WAAW,iBAAkB,SAAQ,SAAS,CAAC,sBAAsB;IACzE,WAAW,EAAE,UAAU,CAAC,WAAW,CAAC;IACpC,EAAE,EAAE,MAAM,GAAG,OAAO,GAAG,CAAC,MAAM,GAAG,OAAO,CAAC,EAAE,CAAC;IAC5C,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;IACvB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAEhB,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,OAAO,CAAC;CACjC;AAED,qBAAa,mBAAoB,SAAQ,SAAS;IAEhD,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAyB;IACrD,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAmB;IACzC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC,CAA0C;IAC9D,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAS;IAC/B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAyB;gBAE9B,IAAI,EAAE,iBAAiB;IAuBnC,GAAG,CAAC,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,IAAI,GAAG,GAAG;CA0C7C"}
|
package/dist/index.js
CHANGED
|
@@ -1,52 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
4
|
};
|
|
28
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
6
|
exports.NodemailerTransport = void 0;
|
|
30
|
-
const
|
|
31
|
-
const nodemailer = __importStar(require("nodemailer"));
|
|
7
|
+
const util_1 = __importDefault(require("util"));
|
|
32
8
|
const winston_transport_1 = __importDefault(require("winston-transport"));
|
|
33
9
|
class NodemailerTransport extends winston_transport_1.default {
|
|
34
10
|
constructor(opts) {
|
|
35
11
|
super(opts);
|
|
36
|
-
this.
|
|
12
|
+
this.transporter = opts.transporter;
|
|
37
13
|
this.from = opts.from;
|
|
14
|
+
this.to = opts.to;
|
|
38
15
|
if (!(this.to && this.from)) {
|
|
39
16
|
throw new Error('Winston-nodemailer Specify to and from');
|
|
40
17
|
}
|
|
18
|
+
void this.transporter.verify();
|
|
41
19
|
if (opts.filter) {
|
|
42
20
|
this.filter = opts.filter;
|
|
43
21
|
}
|
|
44
22
|
if (opts.tags) {
|
|
45
|
-
this.tags = opts.tags.map(tag => {
|
|
46
|
-
return '[' + tag + '] ';
|
|
47
|
-
}).join('');
|
|
23
|
+
this.tags = opts.tags.map(tag => `[${tag}] `).join('');
|
|
48
24
|
}
|
|
49
|
-
this.smtpTransport = nodemailer.createTransport(opts);
|
|
50
25
|
}
|
|
51
26
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
52
27
|
log(info, next) {
|
|
@@ -63,7 +38,7 @@ class NodemailerTransport extends winston_transport_1.default {
|
|
|
63
38
|
text = info.message;
|
|
64
39
|
}
|
|
65
40
|
else {
|
|
66
|
-
text =
|
|
41
|
+
text = util_1.default.inspect(info.message);
|
|
67
42
|
}
|
|
68
43
|
}
|
|
69
44
|
const subject = ((_a = this.tags) !== null && _a !== void 0 ? _a : '') + (hasLevel(info) && typeof info.level === 'string' ? `[${info.level}] ` : '') + text.slice(0, 51);
|
|
@@ -78,9 +53,9 @@ class NodemailerTransport extends winston_transport_1.default {
|
|
|
78
53
|
}
|
|
79
54
|
}
|
|
80
55
|
if (hasMeta) {
|
|
81
|
-
text += '\n---\n' +
|
|
56
|
+
text += '\n---\n' + util_1.default.inspect(meta);
|
|
82
57
|
}
|
|
83
|
-
this.
|
|
58
|
+
this.transporter.sendMail({
|
|
84
59
|
from: this.from,
|
|
85
60
|
subject,
|
|
86
61
|
text,
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAwB;AAGxB,0EAA0C;AAW1C,MAAa,mBAAoB,SAAQ,2BAAS;IAQhD,YAAmB,IAAuB;QACxC,KAAK,CAAC,IAAI,CAAC,CAAC;QAEZ,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC;QACpC,IAAI,CAAC,IA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AI,IAAI,CAAC;AACtE,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@qccareerschool/winston-nodemailer",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.0.0",
|
|
4
4
|
"description": "An email transport for winston v3 using nodemailer written in typescript.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -13,6 +13,9 @@
|
|
|
13
13
|
"devDependencies": {
|
|
14
14
|
"@types/dotenv": "^8.2.3",
|
|
15
15
|
"@types/jest": "^28.1.8",
|
|
16
|
+
"@types/node": "^25.0.9",
|
|
17
|
+
"@types/nodemailer": "^7.0.5",
|
|
18
|
+
"@types/winston": "^2.4.4",
|
|
16
19
|
"@typescript-eslint/eslint-plugin": "^5.62.0",
|
|
17
20
|
"@typescript-eslint/parser": "^5.62.0",
|
|
18
21
|
"dotenv": "^16.6.1",
|
|
@@ -20,17 +23,14 @@
|
|
|
20
23
|
"eslint-plugin-import": "^2.32.0",
|
|
21
24
|
"eslint-plugin-jest": "^26.9.0",
|
|
22
25
|
"jest": "^28.1.3",
|
|
26
|
+
"nodemailer": "^7.0.12",
|
|
23
27
|
"typescript": "^4.9.5",
|
|
24
28
|
"winston": "^3.19.0"
|
|
25
29
|
},
|
|
26
|
-
"dependencies": {
|
|
27
|
-
"@types/node": "^18.19.130",
|
|
28
|
-
"@types/nodemailer": "^7.0.4",
|
|
29
|
-
"@types/winston": "^2.4.4",
|
|
30
|
-
"nodemailer": "^7.0.11",
|
|
31
|
-
"winston-transport": "^4.9.0"
|
|
32
|
-
},
|
|
33
30
|
"peerDependencies": {
|
|
34
31
|
"winston": "^3.19.0"
|
|
32
|
+
},
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"winston-transport": "^4.9.0"
|
|
35
35
|
}
|
|
36
36
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,55 +1,45 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import util from 'util';
|
|
2
|
+
import type nodemailer from 'nodemailer';
|
|
3
3
|
import type { Address } from 'nodemailer/lib/mailer';
|
|
4
4
|
import Transport from 'winston-transport';
|
|
5
5
|
|
|
6
|
-
export interface
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
user: string;
|
|
10
|
-
};
|
|
6
|
+
export interface NodemailerOptions extends Transport.TransportStreamOptions {
|
|
7
|
+
transporter: nodemailer.Transporter;
|
|
8
|
+
to: string | Address | (string | Address)[];
|
|
11
9
|
from: string | Address;
|
|
12
|
-
host: string;
|
|
13
|
-
port: number;
|
|
14
|
-
secure: boolean;
|
|
15
10
|
tags?: string[];
|
|
16
|
-
to: string | Address | (string | Address)[];
|
|
17
11
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
18
12
|
filter?: (info: any) => boolean;
|
|
19
13
|
}
|
|
20
14
|
|
|
21
15
|
export class NodemailerTransport extends Transport {
|
|
22
16
|
|
|
17
|
+
private readonly transporter: nodemailer.Transporter;
|
|
23
18
|
private readonly from?: string | Address;
|
|
24
19
|
private readonly to?: string | Address | (string | Address)[];
|
|
25
|
-
|
|
26
20
|
private readonly tags?: string;
|
|
27
|
-
// eslint-disable-
|
|
28
|
-
private readonly filter?: (info: any) => boolean;
|
|
29
|
-
|
|
30
|
-
private readonly smtpTransport: nodemailer.Transporter;
|
|
21
|
+
private readonly filter?: (info: any) => boolean; // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
31
22
|
|
|
32
|
-
public constructor(opts:
|
|
23
|
+
public constructor(opts: NodemailerOptions) {
|
|
33
24
|
super(opts);
|
|
34
25
|
|
|
35
|
-
this.
|
|
26
|
+
this.transporter = opts.transporter;
|
|
36
27
|
this.from = opts.from;
|
|
28
|
+
this.to = opts.to;
|
|
37
29
|
|
|
38
30
|
if (!(this.to && this.from)) {
|
|
39
31
|
throw new Error('Winston-nodemailer Specify to and from');
|
|
40
32
|
}
|
|
41
33
|
|
|
34
|
+
void this.transporter.verify();
|
|
35
|
+
|
|
42
36
|
if (opts.filter) {
|
|
43
37
|
this.filter = opts.filter;
|
|
44
38
|
}
|
|
45
39
|
|
|
46
40
|
if (opts.tags) {
|
|
47
|
-
this.tags = opts.tags.map(tag => {
|
|
48
|
-
return '[' + tag + '] ';
|
|
49
|
-
}).join('');
|
|
41
|
+
this.tags = opts.tags.map(tag => `[${tag}] `).join('');
|
|
50
42
|
}
|
|
51
|
-
|
|
52
|
-
this.smtpTransport = nodemailer.createTransport(opts);
|
|
53
43
|
}
|
|
54
44
|
|
|
55
45
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -88,7 +78,7 @@ export class NodemailerTransport extends Transport {
|
|
|
88
78
|
text += '\n---\n' + util.inspect(meta);
|
|
89
79
|
}
|
|
90
80
|
|
|
91
|
-
this.
|
|
81
|
+
this.transporter.sendMail({
|
|
92
82
|
from: this.from,
|
|
93
83
|
subject,
|
|
94
84
|
text,
|