@qccareerschool/winston-nodemailer 4.0.0 → 4.0.2
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/.eslintrc.js +237 -0
- package/dist/index.d.ts +10 -13
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +63 -51
- package/dist/index.js.map +1 -0
- package/package.json +19 -16
- package/src/index.ts +107 -97
- package/tsconfig.json +105 -55
- package/dist/index.spec.d.ts +0 -1
- package/dist/index.spec.js +0 -58
- package/src/index.spec.ts +0 -58
- package/tslint.json +0 -11
package/.eslintrc.js
ADDED
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
env: {
|
|
3
|
+
'node': true,
|
|
4
|
+
'browser': true,
|
|
5
|
+
'commonjs': true,
|
|
6
|
+
'jest/globals': true,
|
|
7
|
+
},
|
|
8
|
+
parser: '@typescript-eslint/parser',
|
|
9
|
+
parserOptions: {
|
|
10
|
+
project: [ './tsconfig.json' ],
|
|
11
|
+
ecmaVersion: 2016,
|
|
12
|
+
sourceType: 'module',
|
|
13
|
+
},
|
|
14
|
+
plugins: [
|
|
15
|
+
'@typescript-eslint',
|
|
16
|
+
'jest',
|
|
17
|
+
],
|
|
18
|
+
extends: [
|
|
19
|
+
'eslint:recommended',
|
|
20
|
+
'plugin:@typescript-eslint/recommended',
|
|
21
|
+
'plugin:@typescript-eslint/recommended-requiring-type-checking',
|
|
22
|
+
// 'plugin:react/recommended',
|
|
23
|
+
'plugin:import/recommended',
|
|
24
|
+
'plugin:import/typescript',
|
|
25
|
+
'plugin:jest/recommended',
|
|
26
|
+
'plugin:jest/style',
|
|
27
|
+
],
|
|
28
|
+
rules: {
|
|
29
|
+
// standard rules -- best practices
|
|
30
|
+
'array-callback-return': 'error',
|
|
31
|
+
'block-scoped-var': 'error',
|
|
32
|
+
'curly': 'error',
|
|
33
|
+
'dot-location': [ 'error', 'property' ],
|
|
34
|
+
// 'dot-notation': 'error',
|
|
35
|
+
'dot-notation': 'off', // handled by @typescript-eslint plugin
|
|
36
|
+
'eqeqeq': 'error',
|
|
37
|
+
'guard-for-in': 'error',
|
|
38
|
+
'no-constructor-return': 'error',
|
|
39
|
+
'no-div-regex': 'error',
|
|
40
|
+
'no-else-return': 'error',
|
|
41
|
+
'no-empty-function': 'error',
|
|
42
|
+
'no-eq-null': 'error',
|
|
43
|
+
'no-eval': 'error',
|
|
44
|
+
'no-extend-native': 'error',
|
|
45
|
+
'no-extra-bind': 'error',
|
|
46
|
+
'no-extra-label': 'error',
|
|
47
|
+
'no-floating-decimal': 'error',
|
|
48
|
+
'no-implied-eval': 'off', // handled by @typescript-eslint plugin
|
|
49
|
+
'no-invalid-this': 'error',
|
|
50
|
+
'no-iterator': 'error',
|
|
51
|
+
'no-labels': 'error',
|
|
52
|
+
'no-lone-blocks': 'error',
|
|
53
|
+
'no-loop-func': 'off', // handled by @typescript-eslint plugin
|
|
54
|
+
'no-magic-numbers': 'off', // handled by @typescript-eslint plugin
|
|
55
|
+
'no-multi-spaces': 'error',
|
|
56
|
+
'no-return-assign': 'error',
|
|
57
|
+
'no-return-await': 'off', // handled by @typescript-eslint plugin
|
|
58
|
+
'no-script-url': 'error',
|
|
59
|
+
'no-self-compare': 'error',
|
|
60
|
+
'no-sequences': 'error',
|
|
61
|
+
'no-throw-literal': 'off', // handled by @typescript-eslint plugin
|
|
62
|
+
'no-unmodified-loop-condition': 'error',
|
|
63
|
+
'no-unused-expressions': 'error',
|
|
64
|
+
'no-useless-call': 'error',
|
|
65
|
+
'no-useless-concat': 'error',
|
|
66
|
+
'no-useless-return': 'error',
|
|
67
|
+
'no-void': 'off',
|
|
68
|
+
'no-warning-comments': 'warn',
|
|
69
|
+
'prefer-promise-reject-errors': 'error',
|
|
70
|
+
'prefer-regex-literals': 'error',
|
|
71
|
+
'radix': 'error',
|
|
72
|
+
'require-await': 'off', // handled by @typescript-eslint plugin
|
|
73
|
+
'require-unicode-regexp': 'error',
|
|
74
|
+
'wrap-iife': 'error',
|
|
75
|
+
'yoda': 'error',
|
|
76
|
+
|
|
77
|
+
// standard rules -- variables
|
|
78
|
+
'no-shadow': 'off', // handled by @typescript-eslint plugin
|
|
79
|
+
'no-unused-vars': 'off', // handled by @typescript-eslint plugin (part of "recommended")
|
|
80
|
+
|
|
81
|
+
// standard rules -- stylistic issues
|
|
82
|
+
'array-bracket-newline': [ 'error', 'consistent' ],
|
|
83
|
+
'array-bracket-spacing': [ 'error', 'always' ],
|
|
84
|
+
'array-element-newline': [ 'error', 'consistent' ],
|
|
85
|
+
'block-spacing': 'error',
|
|
86
|
+
'brace-style': 'off', // handled by @typescript-eslint plugin
|
|
87
|
+
'camelcase': 'error',
|
|
88
|
+
'comma-dangle': 'off', // handled by @typescript-eslint plugin
|
|
89
|
+
'comma-spacing': 'off', // handled by @typescript-eslint plugin
|
|
90
|
+
'comma-style': 'error',
|
|
91
|
+
'computed-property-spacing': 'error',
|
|
92
|
+
'eol-last': 'error',
|
|
93
|
+
'func-call-spacing': 'off', // handled by @typescript-eslint plugin
|
|
94
|
+
'function-call-argument-newline': [ 'error', 'consistent' ],
|
|
95
|
+
'function-paren-newline': [ 'error', 'multiline-arguments' ],
|
|
96
|
+
'implicit-arrow-linebreak': 'error',
|
|
97
|
+
'indent': 'off', // handled by @typescript-eslint plugin
|
|
98
|
+
'jsx-quotes': 'error',
|
|
99
|
+
'key-spacing': 'error',
|
|
100
|
+
'keyword-spacing': 'off', // handled by @typescript-eslint plugin
|
|
101
|
+
'linebreak-style': [ 'error' ],
|
|
102
|
+
'lines-between-class-members': 'off', // handled by @typescript-eslint plugin
|
|
103
|
+
'new-parens': 'error',
|
|
104
|
+
'no-bitwise': 'error',
|
|
105
|
+
'no-lonely-if': 'off',
|
|
106
|
+
'no-mixed-operators': 'error',
|
|
107
|
+
'no-multi-assign': 'error',
|
|
108
|
+
'no-multiple-empty-lines': [ 'error', { max: 1, maxEOF: 0, maxBOF: 0 } ],
|
|
109
|
+
'no-tabs': 'error',
|
|
110
|
+
'no-trailing-spaces': 'error',
|
|
111
|
+
'no-unneeded-ternary': 'error',
|
|
112
|
+
'no-whitespace-before-property': 'error',
|
|
113
|
+
'object-curly-newline': 'error',
|
|
114
|
+
'object-curly-spacing': 'off', // handled by @typescript-eslint plugin
|
|
115
|
+
'object-property-newline': [ 'error', { allowAllPropertiesOnSameLine: true } ],
|
|
116
|
+
'one-var': [ 'error', 'never' ],
|
|
117
|
+
'padding-line-between-statements': [
|
|
118
|
+
'error',
|
|
119
|
+
{ blankLine: 'always', prev: '*', next: 'function' },
|
|
120
|
+
],
|
|
121
|
+
'quote-props': [ 'error', 'consistent-as-needed' ],
|
|
122
|
+
'quotes': 'off', // handled by @typescript-eslint plugin
|
|
123
|
+
'semi': 'off', // handled by @typescript-eslint plugin
|
|
124
|
+
'semi-spacing': 'error',
|
|
125
|
+
'semi-style': 'error',
|
|
126
|
+
'space-before-blocks': 'error',
|
|
127
|
+
'space-before-function-paren': 'off', // handled by @typescript-eslint plugin
|
|
128
|
+
'space-in-parens': 'error',
|
|
129
|
+
'space-infix-ops': 'off', // handled by @typescript-eslint plugin,
|
|
130
|
+
'space-unary-ops': 'error',
|
|
131
|
+
'spaced-comment': 'error',
|
|
132
|
+
'switch-colon-spacing': 'error',
|
|
133
|
+
'template-tag-spacing': 'error',
|
|
134
|
+
|
|
135
|
+
// standard rules -- ES2015
|
|
136
|
+
'arrow-parens': [ 'error', 'as-needed' ],
|
|
137
|
+
'arrow-spacing': 'error',
|
|
138
|
+
'generator-star-spacing': 'error',
|
|
139
|
+
'no-confusing-arrow': 'error',
|
|
140
|
+
'no-var': 'error',
|
|
141
|
+
'prefer-const': 'error',
|
|
142
|
+
'sort-imports': [ 'error', { ignoreCase: true, ignoreDeclarationSort: true, ignoreMemberSort: false, memberSyntaxSortOrder: [ 'none', 'all', 'multiple', 'single' ] } ],
|
|
143
|
+
'template-curly-spacing': 'error',
|
|
144
|
+
'yield-star-spacing': 'error',
|
|
145
|
+
|
|
146
|
+
// @typescript-eslint rules
|
|
147
|
+
'@typescript-eslint/consistent-type-imports': 'error',
|
|
148
|
+
'@typescript-eslint/explicit-function-return-type': 'off', // included in "overrides" section
|
|
149
|
+
'@typescript-eslint/explicit-member-accessibility': 'off', // included in "overrides" section
|
|
150
|
+
'@typescript-eslint/member-delimiter-style': 'error',
|
|
151
|
+
'@typescript-eslint/member-ordering': 'error',
|
|
152
|
+
'@typescript-eslint/method-signature-style': 'error',
|
|
153
|
+
'@typescript-eslint/no-floating-promises': 'error',
|
|
154
|
+
'@typescript-eslint/no-var-requires': 'off', // needed for dynamic require
|
|
155
|
+
'@typescript-eslint/prefer-for-of': 'error',
|
|
156
|
+
'@typescript-eslint/prefer-includes': 'error',
|
|
157
|
+
'@typescript-eslint/prefer-nullish-coalescing': 'error',
|
|
158
|
+
'@typescript-eslint/prefer-optional-chain': 'error',
|
|
159
|
+
'@typescript-eslint/prefer-readonly': 'error',
|
|
160
|
+
// '@typescript-eslint/prefer-readonly-parameter-types': 'error',
|
|
161
|
+
'@typescript-eslint/promise-function-async': 'error',
|
|
162
|
+
'@typescript-eslint/prefer-reduce-type-parameter': 'error',
|
|
163
|
+
'@typescript-eslint/prefer-string-starts-ends-with': 'error',
|
|
164
|
+
'@typescript-eslint/type-annotation-spacing': 'error',
|
|
165
|
+
|
|
166
|
+
// @typescript-eslint eslint extension rules
|
|
167
|
+
'@typescript-eslint/brace-style': [ 'error', '1tbs', { allowSingleLine: true } ],
|
|
168
|
+
'@typescript-eslint/comma-dangle': [ 'error', 'always-multiline' ],
|
|
169
|
+
'@typescript-eslint/comma-spacing': 'error',
|
|
170
|
+
'@typescript-eslint/dot-notation': 'error',
|
|
171
|
+
'@typescript-eslint/func-call-spacing': 'error',
|
|
172
|
+
'@typescript-eslint/indent': [ 'error', 2 ],
|
|
173
|
+
'@typescript-eslint/keyword-spacing': 'error',
|
|
174
|
+
'@typescript-eslint/lines-between-class-members': [ 'error', 'always', { exceptAfterSingleLine: true } ],
|
|
175
|
+
'@typescript-eslint/no-implied-eval': 'error',
|
|
176
|
+
'@typescript-eslint/no-loop-func': 'error',
|
|
177
|
+
'@typescript-eslint/no-magic-numbers': 'off',
|
|
178
|
+
'@typescript-eslint/no-shadow': 'error',
|
|
179
|
+
'@typescript-eslint/no-throw-literal': 'error',
|
|
180
|
+
'@typescript-eslint/no-use-before-define': 'off', // override CRA's default
|
|
181
|
+
'@typescript-eslint/object-curly-spacing': [ 'error', 'always' ],
|
|
182
|
+
'@typescript-eslint/quotes': [ 'error', 'single', { avoidEscape: true, allowTemplateLiterals: true } ],
|
|
183
|
+
'@typescript-eslint/require-await': 'warn',
|
|
184
|
+
'@typescript-eslint/return-await': 'error',
|
|
185
|
+
'@typescript-eslint/semi': 'error',
|
|
186
|
+
'@typescript-eslint/space-before-function-paren': [ 'error', { anonymous: 'always', named: 'never', asyncArrow: 'always' } ],
|
|
187
|
+
'@typescript-eslint/space-infix-ops': 'error',
|
|
188
|
+
|
|
189
|
+
// react rules
|
|
190
|
+
// 'react/jsx-closing-bracket-location': [ 'error', { location: 'line-aligned' } ],
|
|
191
|
+
// 'react/jsx-curly-spacing': 'error',
|
|
192
|
+
// 'react/jsx-equals-spacing': 'error',
|
|
193
|
+
// 'react/jsx-first-prop-new-line': [ 'error', 'multiline' ],
|
|
194
|
+
// 'react/jsx-fragments': 'error',
|
|
195
|
+
// 'react/jsx-handler-names': 'error',
|
|
196
|
+
// 'react/jsx-indent': [ 'error', 2, { checkAttributes: true, indentLogicalExpressions: true } ],
|
|
197
|
+
// 'react/jsx-indent-props': [ 'error', 2 ],
|
|
198
|
+
// 'react/jsx-pascal-case': [ 'error', { allowAllCaps: true, allowNamespace: true } ],
|
|
199
|
+
// 'react/jsx-props-no-multi-spaces': 'error',
|
|
200
|
+
// 'react/jsx-tag-spacing': [ 'error', { beforeClosing: 'never' } ],
|
|
201
|
+
// 'react/no-unescaped-entities': [ 'error', { forbid: [ '>', '"', '}', '“', '”', '‘', '’' ] } ],
|
|
202
|
+
// 'react/prop-types': 'off',
|
|
203
|
+
// 'react/react-in-jsx-scope': 'off',
|
|
204
|
+
// 'react/self-closing-comp': 'error',
|
|
205
|
+
|
|
206
|
+
// import rules
|
|
207
|
+
'import/order': [ 'error', { alphabetize: { order: 'asc', caseInsensitive: true } } ],
|
|
208
|
+
'import/no-unresolved': 'off',
|
|
209
|
+
|
|
210
|
+
// jest rules
|
|
211
|
+
'jest/consistent-test-it': [ 'error', { fn: 'it' } ],
|
|
212
|
+
},
|
|
213
|
+
overrides: [
|
|
214
|
+
{
|
|
215
|
+
files: [ '*.ts', '*.tsx' ],
|
|
216
|
+
rules: {
|
|
217
|
+
'@typescript-eslint/explicit-function-return-type': [ 'error', { allowExpressions: true } ],
|
|
218
|
+
'@typescript-eslint/explicit-member-accessibility': 'error',
|
|
219
|
+
},
|
|
220
|
+
},
|
|
221
|
+
{
|
|
222
|
+
files: [
|
|
223
|
+
'src/__tests__/**/*.ts',
|
|
224
|
+
'src/__tests__/**/*.tsx',
|
|
225
|
+
'*.spec.ts',
|
|
226
|
+
'*.spec.tsx',
|
|
227
|
+
],
|
|
228
|
+
rules: {
|
|
229
|
+
'@typescript-eslint/no-explicit-any': 'off',
|
|
230
|
+
'@typescript-eslint/no-magic-numbers': 'off',
|
|
231
|
+
},
|
|
232
|
+
},
|
|
233
|
+
],
|
|
234
|
+
settings: {
|
|
235
|
+
react: { version: 'detect' },
|
|
236
|
+
},
|
|
237
|
+
};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Address } from 'nodemailer/lib/mailer';
|
|
1
|
+
import type { Address } from 'nodemailer/lib/mailer';
|
|
2
2
|
import Transport from 'winston-transport';
|
|
3
3
|
export interface INodemailerOptions extends Transport.TransportStreamOptions {
|
|
4
4
|
auth: {
|
|
@@ -10,22 +10,19 @@ export interface INodemailerOptions extends Transport.TransportStreamOptions {
|
|
|
10
10
|
port: number;
|
|
11
11
|
secure: boolean;
|
|
12
12
|
tags?: string[];
|
|
13
|
-
to: string | Address |
|
|
14
|
-
filter?: (
|
|
15
|
-
level: string;
|
|
16
|
-
message: any;
|
|
17
|
-
meta: any;
|
|
18
|
-
}) => boolean;
|
|
13
|
+
to: string | Address | (string | Address)[];
|
|
14
|
+
filter?: (info: unknown) => boolean;
|
|
19
15
|
}
|
|
20
16
|
export declare class NodemailerTransport extends Transport {
|
|
21
|
-
private from?;
|
|
22
|
-
private to?;
|
|
23
|
-
private tags?;
|
|
24
|
-
private filter?;
|
|
25
|
-
private smtpTransport;
|
|
17
|
+
private readonly from?;
|
|
18
|
+
private readonly to?;
|
|
19
|
+
private readonly tags?;
|
|
20
|
+
private readonly filter?;
|
|
21
|
+
private readonly smtpTransport;
|
|
26
22
|
constructor(opts: INodemailerOptions);
|
|
27
23
|
/**
|
|
28
24
|
* log data
|
|
29
25
|
*/
|
|
30
|
-
log(info:
|
|
26
|
+
log(info: unknown, next: () => void): any;
|
|
31
27
|
}
|
|
28
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,SAAS,MAAM,mBAAmB,CAAC;AAE1C,MAAM,WAAW,kBAAmB,SAAQ,SAAS,CAAC,sBAAsB;IAC1E,IAAI,EAAE;QACJ,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,MAAM,CAAC;KACd,CAAC;IACF,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,OAAO,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,EAAE,EAAE,MAAM,GAAG,OAAO,GAAG,CAAC,MAAM,GAAG,OAAO,CAAC,EAAE,CAAC;IAC5C,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,OAAO,CAAC;CACrC;AAED,qBAAa,mBAAoB,SAAQ,SAAS;IAEhD,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAmB;IACzC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC,CAA0C;IAE9D,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAS;IAC/B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,CAA6B;IAErD,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAyB;gBAEpC,IAAI,EAAE,kBAAkB;IAuB3C;;OAEG;IACI,GAAG,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,IAAI,GAAG,GAAG;CA2CjD"}
|
package/dist/index.js
CHANGED
|
@@ -1,79 +1,82 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
return extendStatics(d, b);
|
|
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]; } };
|
|
8
7
|
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
+
});
|
|
15
18
|
var __importStar = (this && this.__importStar) || function (mod) {
|
|
16
19
|
if (mod && mod.__esModule) return mod;
|
|
17
20
|
var result = {};
|
|
18
|
-
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result
|
|
19
|
-
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);
|
|
20
23
|
return result;
|
|
21
24
|
};
|
|
22
25
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
23
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
24
27
|
};
|
|
25
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
if (!(
|
|
29
|
+
exports.NodemailerTransport = void 0;
|
|
30
|
+
const util = __importStar(require("util"));
|
|
31
|
+
const nodemailer = __importStar(require("nodemailer"));
|
|
32
|
+
const winston_transport_1 = __importDefault(require("winston-transport"));
|
|
33
|
+
class NodemailerTransport extends winston_transport_1.default {
|
|
34
|
+
constructor(opts) {
|
|
35
|
+
super(opts);
|
|
36
|
+
this.to = opts.to;
|
|
37
|
+
this.from = opts.from;
|
|
38
|
+
if (!(this.to && this.from)) {
|
|
36
39
|
throw new Error('Winston-nodemailer Specify to and from');
|
|
37
40
|
}
|
|
38
41
|
if (opts.filter) {
|
|
39
|
-
|
|
42
|
+
this.filter = opts.filter;
|
|
40
43
|
}
|
|
41
44
|
if (opts.tags) {
|
|
42
|
-
|
|
45
|
+
this.tags = opts.tags.map(tag => {
|
|
43
46
|
return '[' + tag + '] ';
|
|
44
47
|
}).join('');
|
|
45
48
|
}
|
|
46
|
-
|
|
47
|
-
return _this;
|
|
49
|
+
this.smtpTransport = nodemailer.createTransport(opts);
|
|
48
50
|
}
|
|
49
51
|
/**
|
|
50
52
|
* log data
|
|
51
53
|
*/
|
|
52
|
-
|
|
54
|
+
log(info, next) {
|
|
55
|
+
var _a;
|
|
53
56
|
if (this.silent) {
|
|
54
57
|
return next();
|
|
55
58
|
}
|
|
56
59
|
if (this.filter && !this.filter(info)) {
|
|
57
60
|
return next();
|
|
58
61
|
}
|
|
59
|
-
|
|
60
|
-
if (
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
text = util.inspect(info.message);
|
|
62
|
+
let text = 'undefined';
|
|
63
|
+
if (hasMessage(info)) {
|
|
64
|
+
if (typeof info.message === 'string') {
|
|
65
|
+
text = info.message;
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
text = util.inspect(info.message);
|
|
69
|
+
}
|
|
68
70
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
71
|
+
const subject = ((_a = this.tags) !== null && _a !== void 0 ? _a : '') + (hasLevel(info) && typeof info.level === 'string' ? `[${info.level}] ` : '') + text.slice(0, 51);
|
|
72
|
+
const meta = {};
|
|
73
|
+
let hasMeta = false;
|
|
74
|
+
if (isObject(info)) {
|
|
75
|
+
for (const key of Object.keys(info)) {
|
|
76
|
+
if (key !== 'message' && key !== 'level') {
|
|
77
|
+
meta[key] = info[key];
|
|
78
|
+
hasMeta = true;
|
|
79
|
+
}
|
|
77
80
|
}
|
|
78
81
|
}
|
|
79
82
|
if (hasMeta) {
|
|
@@ -81,11 +84,20 @@ var NodemailerTransport = /** @class */ (function (_super) {
|
|
|
81
84
|
}
|
|
82
85
|
this.smtpTransport.sendMail({
|
|
83
86
|
from: this.from,
|
|
84
|
-
subject
|
|
85
|
-
text
|
|
87
|
+
subject,
|
|
88
|
+
text,
|
|
86
89
|
to: this.to,
|
|
87
90
|
}, next);
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
}(winston_transport_1.default));
|
|
91
|
+
}
|
|
92
|
+
}
|
|
91
93
|
exports.NodemailerTransport = NodemailerTransport;
|
|
94
|
+
const isObject = (info) => {
|
|
95
|
+
return typeof info === 'object' && info !== null;
|
|
96
|
+
};
|
|
97
|
+
const hasMessage = (info) => {
|
|
98
|
+
return typeof info === 'object' && info !== null && 'message' in info;
|
|
99
|
+
};
|
|
100
|
+
const hasLevel = (info) => {
|
|
101
|
+
return typeof info === 'object' && info !== null && 'level' in info;
|
|
102
|
+
};
|
|
103
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"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"}
|
package/package.json
CHANGED
|
@@ -1,33 +1,36 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@qccareerschool/winston-nodemailer",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.2",
|
|
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",
|
|
7
7
|
"scripts": {
|
|
8
|
-
"test": "node dist/index.spec.js"
|
|
8
|
+
"test": "node dist/index.spec.js",
|
|
9
|
+
"build": "tsc"
|
|
9
10
|
},
|
|
10
11
|
"author": "Dave Welsh",
|
|
11
12
|
"license": "ISC",
|
|
12
13
|
"devDependencies": {
|
|
13
|
-
"@types/
|
|
14
|
-
"@types/
|
|
15
|
-
"@
|
|
16
|
-
"
|
|
17
|
-
"dotenv": "^
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
"
|
|
14
|
+
"@types/dotenv": "^8.2.0",
|
|
15
|
+
"@types/jest": "^28.1.4",
|
|
16
|
+
"@typescript-eslint/eslint-plugin": "^5.30.6",
|
|
17
|
+
"@typescript-eslint/parser": "^5.30.6",
|
|
18
|
+
"dotenv": "^16.0.1",
|
|
19
|
+
"eslint": "^8.19.0",
|
|
20
|
+
"eslint-plugin-import": "^2.26.0",
|
|
21
|
+
"eslint-plugin-jest": "^26.5.3",
|
|
22
|
+
"jest": "^28.1.2",
|
|
23
|
+
"typescript": "^4.7.4",
|
|
24
|
+
"winston": "^3.8.1"
|
|
22
25
|
},
|
|
23
26
|
"dependencies": {
|
|
24
|
-
"@types/node": "^
|
|
25
|
-
"@types/nodemailer": "^4.
|
|
27
|
+
"@types/node": "^18.0.3",
|
|
28
|
+
"@types/nodemailer": "^6.4.4",
|
|
26
29
|
"@types/winston": "^2.4.4",
|
|
27
|
-
"nodemailer": "^6.
|
|
28
|
-
"winston-transport": "^4.
|
|
30
|
+
"nodemailer": "^6.7.7",
|
|
31
|
+
"winston-transport": "^4.5.0"
|
|
29
32
|
},
|
|
30
33
|
"peerDependencies": {
|
|
31
|
-
"winston": "^3.
|
|
34
|
+
"winston": "^3.8.1"
|
|
32
35
|
}
|
|
33
36
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,97 +1,107 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import Transport from 'winston-transport';
|
|
5
|
-
|
|
6
|
-
export interface INodemailerOptions extends Transport.TransportStreamOptions {
|
|
7
|
-
auth: {
|
|
8
|
-
pass: string;
|
|
9
|
-
user: string;
|
|
10
|
-
};
|
|
11
|
-
from: string | Address;
|
|
12
|
-
host: string;
|
|
13
|
-
port: number;
|
|
14
|
-
secure: boolean;
|
|
15
|
-
tags?: string[];
|
|
16
|
-
to: string | Address | (string | Address)[];
|
|
17
|
-
filter?: (
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export class NodemailerTransport extends Transport {
|
|
21
|
-
|
|
22
|
-
private from?: string | Address;
|
|
23
|
-
private to?: string | Address | (string | Address)[];
|
|
24
|
-
|
|
25
|
-
private tags?: string;
|
|
26
|
-
private filter?: (
|
|
27
|
-
|
|
28
|
-
private smtpTransport: nodemailer.Transporter;
|
|
29
|
-
|
|
30
|
-
constructor(opts: INodemailerOptions) {
|
|
31
|
-
super(opts);
|
|
32
|
-
|
|
33
|
-
this.to = opts.to;
|
|
34
|
-
this.from = opts.from;
|
|
35
|
-
|
|
36
|
-
if (!(this.to && this.from)) {
|
|
37
|
-
throw new Error('Winston-nodemailer Specify to and from');
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
if (opts.filter) {
|
|
41
|
-
this.filter = opts.filter;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
if (opts.tags) {
|
|
45
|
-
this.tags = opts.tags.map(
|
|
46
|
-
return '[' + tag + '] ';
|
|
47
|
-
}).join('');
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
this.smtpTransport = nodemailer.createTransport(opts);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
1
|
+
import * as util from 'util';
|
|
2
|
+
import * as nodemailer from 'nodemailer';
|
|
3
|
+
import type { Address } from 'nodemailer/lib/mailer';
|
|
4
|
+
import Transport from 'winston-transport';
|
|
5
|
+
|
|
6
|
+
export interface INodemailerOptions extends Transport.TransportStreamOptions {
|
|
7
|
+
auth: {
|
|
8
|
+
pass: string;
|
|
9
|
+
user: string;
|
|
10
|
+
};
|
|
11
|
+
from: string | Address;
|
|
12
|
+
host: string;
|
|
13
|
+
port: number;
|
|
14
|
+
secure: boolean;
|
|
15
|
+
tags?: string[];
|
|
16
|
+
to: string | Address | (string | Address)[];
|
|
17
|
+
filter?: (info: unknown) => boolean;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export class NodemailerTransport extends Transport {
|
|
21
|
+
|
|
22
|
+
private readonly from?: string | Address;
|
|
23
|
+
private readonly to?: string | Address | (string | Address)[];
|
|
24
|
+
|
|
25
|
+
private readonly tags?: string;
|
|
26
|
+
private readonly filter?: (info: unknown) => boolean;
|
|
27
|
+
|
|
28
|
+
private readonly smtpTransport: nodemailer.Transporter;
|
|
29
|
+
|
|
30
|
+
public constructor(opts: INodemailerOptions) {
|
|
31
|
+
super(opts);
|
|
32
|
+
|
|
33
|
+
this.to = opts.to;
|
|
34
|
+
this.from = opts.from;
|
|
35
|
+
|
|
36
|
+
if (!(this.to && this.from)) {
|
|
37
|
+
throw new Error('Winston-nodemailer Specify to and from');
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (opts.filter) {
|
|
41
|
+
this.filter = opts.filter;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if (opts.tags) {
|
|
45
|
+
this.tags = opts.tags.map(tag => {
|
|
46
|
+
return '[' + tag + '] ';
|
|
47
|
+
}).join('');
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
this.smtpTransport = nodemailer.createTransport(opts);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
public log(info: unknown, next: () => void): unknown {
|
|
54
|
+
if (this.silent) {
|
|
55
|
+
return next();
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if (this.filter && !this.filter(info)) {
|
|
59
|
+
return next();
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
let text = 'undefined';
|
|
63
|
+
if (hasMessage(info)) {
|
|
64
|
+
if (typeof info.message === 'string') {
|
|
65
|
+
text = info.message;
|
|
66
|
+
} else {
|
|
67
|
+
text = util.inspect(info.message);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const subject = (this.tags ?? '') + (hasLevel(info) && typeof info.level === 'string' ? `[${info.level}] ` : '') + text.slice(0, 51);
|
|
72
|
+
|
|
73
|
+
const meta: Record<string, unknown> = {};
|
|
74
|
+
let hasMeta = false;
|
|
75
|
+
if (isObject(info)) {
|
|
76
|
+
for (const key of Object.keys(info)) {
|
|
77
|
+
if (key !== 'message' && key !== 'level') {
|
|
78
|
+
meta[key] = info[key as keyof typeof info];
|
|
79
|
+
hasMeta = true;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if (hasMeta) {
|
|
85
|
+
text += '\n---\n' + util.inspect(meta);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
this.smtpTransport.sendMail({
|
|
89
|
+
from: this.from,
|
|
90
|
+
subject,
|
|
91
|
+
text,
|
|
92
|
+
to: this.to,
|
|
93
|
+
}, next);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const isObject = (info: unknown): info is object => {
|
|
98
|
+
return typeof info === 'object' && info !== null;
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
const hasMessage = (info: unknown): info is { message: unknown } => {
|
|
102
|
+
return typeof info === 'object' && info !== null && 'message' in info;
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
const hasLevel = (info: unknown): info is { level: unknown } => {
|
|
106
|
+
return typeof info === 'object' && info !== null && 'level' in info;
|
|
107
|
+
};
|
package/tsconfig.json
CHANGED
|
@@ -1,57 +1,107 @@
|
|
|
1
1
|
{
|
|
2
2
|
"compilerOptions": {
|
|
3
|
-
/*
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
"
|
|
7
|
-
// "
|
|
8
|
-
// "
|
|
9
|
-
// "
|
|
10
|
-
"
|
|
11
|
-
// "
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
// "
|
|
16
|
-
// "
|
|
17
|
-
// "
|
|
18
|
-
// "
|
|
19
|
-
// "
|
|
20
|
-
|
|
21
|
-
/*
|
|
22
|
-
"
|
|
23
|
-
// "
|
|
24
|
-
// "
|
|
25
|
-
// "
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
/*
|
|
31
|
-
// "
|
|
32
|
-
// "
|
|
33
|
-
// "
|
|
34
|
-
// "
|
|
35
|
-
|
|
36
|
-
/*
|
|
37
|
-
// "
|
|
38
|
-
// "
|
|
39
|
-
// "
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
// "
|
|
43
|
-
// "
|
|
44
|
-
"
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
/*
|
|
48
|
-
|
|
49
|
-
// "
|
|
50
|
-
|
|
51
|
-
// "
|
|
52
|
-
|
|
53
|
-
/*
|
|
54
|
-
// "
|
|
55
|
-
// "
|
|
56
|
-
|
|
57
|
-
|
|
3
|
+
/* Visit https://aka.ms/tsconfig to read more about this file */
|
|
4
|
+
|
|
5
|
+
/* Projects */
|
|
6
|
+
// "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */
|
|
7
|
+
// "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */
|
|
8
|
+
// "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */
|
|
9
|
+
// "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */
|
|
10
|
+
// "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
|
|
11
|
+
// "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
|
|
12
|
+
|
|
13
|
+
/* Language and Environment */
|
|
14
|
+
"target": "es2016", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
|
|
15
|
+
// "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
|
|
16
|
+
// "jsx": "preserve", /* Specify what JSX code is generated. */
|
|
17
|
+
// "experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */
|
|
18
|
+
// "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
|
|
19
|
+
// "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */
|
|
20
|
+
// "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
|
|
21
|
+
// "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */
|
|
22
|
+
// "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */
|
|
23
|
+
// "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
|
|
24
|
+
// "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
|
|
25
|
+
// "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */
|
|
26
|
+
|
|
27
|
+
/* Modules */
|
|
28
|
+
"module": "commonjs", /* Specify what module code is generated. */
|
|
29
|
+
// "rootDir": "./", /* Specify the root folder within your source files. */
|
|
30
|
+
// "moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */
|
|
31
|
+
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
|
|
32
|
+
// "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
|
|
33
|
+
// "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
|
|
34
|
+
// "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */
|
|
35
|
+
// "types": [], /* Specify type package names to be included without being referenced in a source file. */
|
|
36
|
+
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
|
|
37
|
+
// "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */
|
|
38
|
+
// "resolveJsonModule": true, /* Enable importing .json files. */
|
|
39
|
+
// "noResolve": true, /* Disallow 'import's, 'require's or '<reference>'s from expanding the number of files TypeScript should add to a project. */
|
|
40
|
+
|
|
41
|
+
/* JavaScript Support */
|
|
42
|
+
// "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */
|
|
43
|
+
// "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */
|
|
44
|
+
// "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */
|
|
45
|
+
|
|
46
|
+
/* Emit */
|
|
47
|
+
"declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
|
|
48
|
+
"declarationMap": true, /* Create sourcemaps for d.ts files. */
|
|
49
|
+
// "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
|
|
50
|
+
"sourceMap": true, /* Create source map files for emitted JavaScript files. */
|
|
51
|
+
// "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
|
|
52
|
+
"outDir": "./dist/", /* Specify an output folder for all emitted files. */
|
|
53
|
+
// "removeComments": true, /* Disable emitting comments. */
|
|
54
|
+
// "noEmit": true, /* Disable emitting files from a compilation. */
|
|
55
|
+
// "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
|
|
56
|
+
// "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types. */
|
|
57
|
+
// "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
|
|
58
|
+
// "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */
|
|
59
|
+
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
|
|
60
|
+
// "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
|
|
61
|
+
// "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */
|
|
62
|
+
// "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */
|
|
63
|
+
// "newLine": "crlf", /* Set the newline character for emitting files. */
|
|
64
|
+
// "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */
|
|
65
|
+
// "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */
|
|
66
|
+
// "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */
|
|
67
|
+
// "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */
|
|
68
|
+
// "declarationDir": "./", /* Specify the output directory for generated declaration files. */
|
|
69
|
+
// "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */
|
|
70
|
+
|
|
71
|
+
/* Interop Constraints */
|
|
72
|
+
// "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
|
|
73
|
+
// "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
|
|
74
|
+
"esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
|
|
75
|
+
// "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
|
|
76
|
+
"forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
|
|
77
|
+
|
|
78
|
+
/* Type Checking */
|
|
79
|
+
"strict": true, /* Enable all strict type-checking options. */
|
|
80
|
+
// "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */
|
|
81
|
+
// "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */
|
|
82
|
+
// "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
|
|
83
|
+
// "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */
|
|
84
|
+
// "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */
|
|
85
|
+
// "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */
|
|
86
|
+
// "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */
|
|
87
|
+
// "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */
|
|
88
|
+
// "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */
|
|
89
|
+
// "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */
|
|
90
|
+
// "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
|
|
91
|
+
// "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
|
|
92
|
+
// "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */
|
|
93
|
+
// "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */
|
|
94
|
+
// "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */
|
|
95
|
+
// "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */
|
|
96
|
+
// "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
|
|
97
|
+
// "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */
|
|
98
|
+
|
|
99
|
+
/* Completeness */
|
|
100
|
+
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
|
|
101
|
+
"skipLibCheck": true /* Skip type checking all .d.ts files. */
|
|
102
|
+
},
|
|
103
|
+
"include": [
|
|
104
|
+
"src",
|
|
105
|
+
".eslintrc.js"
|
|
106
|
+
]
|
|
107
|
+
}
|
package/dist/index.spec.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/index.spec.js
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
3
|
-
if (mod && mod.__esModule) return mod;
|
|
4
|
-
var result = {};
|
|
5
|
-
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
|
6
|
-
result["default"] = mod;
|
|
7
|
-
return result;
|
|
8
|
-
};
|
|
9
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
var dotenv = __importStar(require("dotenv"));
|
|
11
|
-
var winston = __importStar(require("winston"));
|
|
12
|
-
var index_1 = require("./index");
|
|
13
|
-
dotenv.config();
|
|
14
|
-
if (typeof process.env.EMAIL_USERNAME === 'undefined') {
|
|
15
|
-
throw new Error('EMAIL_USERNAME not specified in .env file');
|
|
16
|
-
}
|
|
17
|
-
var username = process.env.EMAIL_USERNAME;
|
|
18
|
-
if (typeof process.env.EMAIL_PASSWORD === 'undefined') {
|
|
19
|
-
throw new Error('EMAIL_PASSWORD not specified in .env file');
|
|
20
|
-
}
|
|
21
|
-
var password = process.env.EMAIL_PASSWORD;
|
|
22
|
-
if (typeof process.env.EMAIL_HOST === 'undefined') {
|
|
23
|
-
throw new Error('EMAIL_HOST not specified in .env file');
|
|
24
|
-
}
|
|
25
|
-
var host = process.env.EMAIL_HOST;
|
|
26
|
-
if (typeof process.env.EMAIL_TO === 'undefined') {
|
|
27
|
-
throw new Error('EMAIL_TO not specified in .env file');
|
|
28
|
-
}
|
|
29
|
-
var to = process.env.EMAIL_TO;
|
|
30
|
-
if (typeof process.env.EMAIL_FROM === 'undefined') {
|
|
31
|
-
throw new Error('EMAIL_FROM not specified in .env file');
|
|
32
|
-
}
|
|
33
|
-
var from = process.env.EMAIL_FROM;
|
|
34
|
-
var logger = winston.createLogger({
|
|
35
|
-
levels: winston.config.syslog.levels,
|
|
36
|
-
transports: [
|
|
37
|
-
new index_1.NodemailerTransport({
|
|
38
|
-
auth: {
|
|
39
|
-
pass: password,
|
|
40
|
-
user: username,
|
|
41
|
-
},
|
|
42
|
-
filter: function (_a) {
|
|
43
|
-
var level = _a.level, message = _a.message, meta = _a.meta;
|
|
44
|
-
return level === 'error' || level === 'crit' || level === 'alert' || level === 'emerg';
|
|
45
|
-
},
|
|
46
|
-
format: winston.format.simple(),
|
|
47
|
-
from: from,
|
|
48
|
-
host: host,
|
|
49
|
-
port: 587,
|
|
50
|
-
secure: false,
|
|
51
|
-
tags: ['test'],
|
|
52
|
-
to: to,
|
|
53
|
-
}),
|
|
54
|
-
],
|
|
55
|
-
});
|
|
56
|
-
var object = { x: [1, 2, 3], y: true, z: 32, q: { a: 1, b: 'two', c: null } };
|
|
57
|
-
logger.crit('this should get logged with additional data', object);
|
|
58
|
-
logger.crit(object);
|
package/src/index.spec.ts
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import * as dotenv from 'dotenv';
|
|
2
|
-
import * as winston from 'winston';
|
|
3
|
-
import { NodemailerTransport } from './index';
|
|
4
|
-
|
|
5
|
-
dotenv.config();
|
|
6
|
-
|
|
7
|
-
if (typeof process.env.EMAIL_USERNAME === 'undefined') {
|
|
8
|
-
throw new Error('EMAIL_USERNAME not specified in .env file');
|
|
9
|
-
}
|
|
10
|
-
const username = process.env.EMAIL_USERNAME;
|
|
11
|
-
|
|
12
|
-
if (typeof process.env.EMAIL_PASSWORD === 'undefined') {
|
|
13
|
-
throw new Error('EMAIL_PASSWORD not specified in .env file');
|
|
14
|
-
}
|
|
15
|
-
const password = process.env.EMAIL_PASSWORD;
|
|
16
|
-
|
|
17
|
-
if (typeof process.env.EMAIL_HOST === 'undefined') {
|
|
18
|
-
throw new Error('EMAIL_HOST not specified in .env file');
|
|
19
|
-
}
|
|
20
|
-
const host = process.env.EMAIL_HOST;
|
|
21
|
-
|
|
22
|
-
if (typeof process.env.EMAIL_TO === 'undefined') {
|
|
23
|
-
throw new Error('EMAIL_TO not specified in .env file');
|
|
24
|
-
}
|
|
25
|
-
const to = process.env.EMAIL_TO;
|
|
26
|
-
|
|
27
|
-
if (typeof process.env.EMAIL_FROM === 'undefined') {
|
|
28
|
-
throw new Error('EMAIL_FROM not specified in .env file');
|
|
29
|
-
}
|
|
30
|
-
const from = process.env.EMAIL_FROM;
|
|
31
|
-
|
|
32
|
-
const logger = winston.createLogger({
|
|
33
|
-
levels: winston.config.syslog.levels,
|
|
34
|
-
transports: [
|
|
35
|
-
new NodemailerTransport({
|
|
36
|
-
auth: {
|
|
37
|
-
pass: password,
|
|
38
|
-
user: username,
|
|
39
|
-
},
|
|
40
|
-
filter: ({ level, message, meta }: any) => {
|
|
41
|
-
return level === 'error' || level === 'crit' || level === 'alert' || level === 'emerg';
|
|
42
|
-
},
|
|
43
|
-
format: winston.format.simple(),
|
|
44
|
-
from,
|
|
45
|
-
host,
|
|
46
|
-
port: 587,
|
|
47
|
-
secure: false,
|
|
48
|
-
tags: [ 'test' ],
|
|
49
|
-
to,
|
|
50
|
-
}),
|
|
51
|
-
],
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
const object = { x: [ 1, 2, 3 ], y: true, z: 32, q: { a: 1, b: 'two', c: null } };
|
|
55
|
-
|
|
56
|
-
logger.crit('this should get logged with additional data', object);
|
|
57
|
-
|
|
58
|
-
logger.crit(object);
|