@takaro/email 0.0.18 → 0.0.19
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/dist/config.d.ts +7 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +6 -0
- package/dist/config.js.map +1 -1
- package/dist/send.d.ts +1 -2
- package/dist/send.d.ts.map +1 -1
- package/dist/send.js +14 -1
- package/dist/send.js.map +1 -1
- package/package.json +2 -10
- package/src/config.ts +7 -0
- package/src/send.ts +17 -2
package/dist/config.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Config, IBaseConfig } from '@takaro/config';
|
|
2
2
|
export interface IMailConfig extends IBaseConfig {
|
|
3
3
|
mail: {
|
|
4
|
+
postmarkApiKey: string;
|
|
4
5
|
host: string;
|
|
5
6
|
port: number;
|
|
6
7
|
secure: boolean;
|
|
@@ -12,6 +13,12 @@ export interface IMailConfig extends IBaseConfig {
|
|
|
12
13
|
}
|
|
13
14
|
export declare const configSchema: {
|
|
14
15
|
mail: {
|
|
16
|
+
postmarkApiKey: {
|
|
17
|
+
doc: string;
|
|
18
|
+
format: StringConstructor;
|
|
19
|
+
default: string;
|
|
20
|
+
env: string;
|
|
21
|
+
};
|
|
15
22
|
host: {
|
|
16
23
|
doc: string;
|
|
17
24
|
format: StringConstructor;
|
package/dist/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAErD,MAAM,WAAW,WAAY,SAAQ,WAAW;IAC9C,IAAI,EAAE;QACJ,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,MAAM,CAAC;QACb,MAAM,EAAE,OAAO,CAAC;QAChB,IAAI,EAAE;YACJ,IAAI,EAAE,MAAM,CAAC;YACb,IAAI,EAAE,MAAM,CAAC;SACd,CAAC;KACH,CAAC;CACH;AAED,eAAO,MAAM,YAAY
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAErD,MAAM,WAAW,WAAY,SAAQ,WAAW;IAC9C,IAAI,EAAE;QACJ,cAAc,EAAE,MAAM,CAAC;QACvB,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,MAAM,CAAC;QACb,MAAM,EAAE,OAAO,CAAC;QAChB,IAAI,EAAE;YACJ,IAAI,EAAE,MAAM,CAAC;YACb,IAAI,EAAE,MAAM,CAAC;SACd,CAAC;KACH,CAAC;CACH;AAED,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAyCxB,CAAC;AAEF,eAAO,MAAM,MAAM,qBAA0C,CAAC"}
|
package/dist/config.js
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import { Config } from '@takaro/config';
|
|
2
2
|
export const configSchema = {
|
|
3
3
|
mail: {
|
|
4
|
+
postmarkApiKey: {
|
|
5
|
+
doc: 'The API key for the Postmark mail service.',
|
|
6
|
+
format: String,
|
|
7
|
+
default: '',
|
|
8
|
+
env: 'MAIL_POSTMARK_API_KEY',
|
|
9
|
+
},
|
|
4
10
|
host: {
|
|
5
11
|
doc: 'The host of the mail server.',
|
|
6
12
|
format: String,
|
package/dist/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAe,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAe,MAAM,gBAAgB,CAAC;AAerD,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,IAAI,EAAE;QACJ,cAAc,EAAE;YACd,GAAG,EAAE,4CAA4C;YACjD,MAAM,EAAE,MAAM;YACd,OAAO,EAAE,EAAE;YACX,GAAG,EAAE,uBAAuB;SAC7B;QACD,IAAI,EAAE;YACJ,GAAG,EAAE,8BAA8B;YACnC,MAAM,EAAE,MAAM;YACd,OAAO,EAAE,SAAS;YAClB,GAAG,EAAE,WAAW;SACjB;QACD,IAAI,EAAE;YACJ,GAAG,EAAE,8BAA8B;YACnC,MAAM,EAAE,MAAM;YACd,OAAO,EAAE,IAAI;YACb,GAAG,EAAE,WAAW;SACjB;QACD,MAAM,EAAE;YACN,GAAG,EAAE,4BAA4B;YACjC,MAAM,EAAE,OAAO;YACf,OAAO,EAAE,KAAK;YACd,GAAG,EAAE,aAAa;SACnB;QACD,IAAI,EAAE;YACJ,IAAI,EAAE;gBACJ,GAAG,EAAE,yCAAyC;gBAC9C,MAAM,EAAE,MAAM;gBACd,OAAO,EAAE,MAAM;gBACf,GAAG,EAAE,WAAW;aACjB;YACD,IAAI,EAAE;gBACJ,GAAG,EAAE,yCAAyC;gBAC9C,MAAM,EAAE,MAAM;gBACd,OAAO,EAAE,MAAM;gBACf,GAAG,EAAE,WAAW;aACjB;SACF;KACF;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,MAAM,GAAG,IAAI,MAAM,CAAc,CAAC,YAAY,CAAC,CAAC,CAAC"}
|
package/dist/send.d.ts
CHANGED
|
@@ -4,6 +4,5 @@ export interface ISendOptions {
|
|
|
4
4
|
template: keyof typeof EMAIL_TEMPLATES;
|
|
5
5
|
data: Record<string, unknown>;
|
|
6
6
|
}
|
|
7
|
-
export declare
|
|
8
|
-
export declare function send(opts: ISendOptions): Promise<import("nodemailer/lib/smtp-transport/index.js").SentMessageInfo>;
|
|
7
|
+
export declare function send(opts: ISendOptions): Promise<any>;
|
|
9
8
|
//# sourceMappingURL=send.d.ts.map
|
package/dist/send.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"send.d.ts","sourceRoot":"","sources":["../src/send.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"send.d.ts","sourceRoot":"","sources":["../src/send.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAKjD,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,OAAO,eAAe,CAAC;IACvC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC/B;AAmBD,wBAAsB,IAAI,CAAC,IAAI,EAAE,YAAY,gBAmB5C"}
|
package/dist/send.js
CHANGED
|
@@ -1,9 +1,22 @@
|
|
|
1
1
|
import { errors, logger } from '@takaro/util';
|
|
2
2
|
import { createTransport } from 'nodemailer';
|
|
3
3
|
import { EMAIL_TEMPLATES } from './templates.js';
|
|
4
|
+
import { PostmarkTransport } from 'nodemailer-postmark-transport';
|
|
4
5
|
import { config } from './config.js';
|
|
5
6
|
const log = logger('email:send');
|
|
6
|
-
|
|
7
|
+
let transporter;
|
|
8
|
+
if (config.get('mail.postmarkApiKey')) {
|
|
9
|
+
log.info('Using Postmark as mail transport');
|
|
10
|
+
transporter = createTransport(new PostmarkTransport({
|
|
11
|
+
auth: {
|
|
12
|
+
apiKey: config.get('mail.postmarkApiKey'),
|
|
13
|
+
},
|
|
14
|
+
}));
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
log.info('Using SMTP as mail transport');
|
|
18
|
+
transporter = createTransport(config.get('mail'));
|
|
19
|
+
}
|
|
7
20
|
export async function send(opts) {
|
|
8
21
|
const template = EMAIL_TEMPLATES[opts.template];
|
|
9
22
|
if (!template) {
|
package/dist/send.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"send.js","sourceRo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AmB,EAAE,CAAC;IACzC,CAAC;IAED,MAAM,IAAI,GAAG,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAEtC,MAAM,MAAM,GAAG,MAAM,WAAW,CAAC,QAAQ,CAAC;QACxC,IAAI,EAAE,yCAAyC;QAC/C,EAAE,EAAE,IAAI,CAAC,OAAO;QAChB,OAAO,EAAE,QAAQ,CAAC,OAAO;QACzB,IAAI;KACL,CAAC,CAAC;IAEH,GAAG,CAAC,IAAI,CAAC,eAAe,EAAE,EAAE,GAAG,IAAI,EAAE,CAAC,CAAC;IACvC,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@takaro/email",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.19",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/main.js",
|
|
6
6
|
"types": "dist/main.d.ts",
|
|
@@ -10,13 +10,5 @@
|
|
|
10
10
|
"build": "tsc -p ./tsconfig.build.json"
|
|
11
11
|
},
|
|
12
12
|
"author": "",
|
|
13
|
-
"license": "ISC"
|
|
14
|
-
"dependencies": {
|
|
15
|
-
"ejs": "3.1.10",
|
|
16
|
-
"nodemailer": "6.9.15"
|
|
17
|
-
},
|
|
18
|
-
"devDependencies": {
|
|
19
|
-
"@types/ejs": "3.1.5",
|
|
20
|
-
"@types/nodemailer": "6.4.16"
|
|
21
|
-
}
|
|
13
|
+
"license": "ISC"
|
|
22
14
|
}
|
package/src/config.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { Config, IBaseConfig } from '@takaro/config';
|
|
|
2
2
|
|
|
3
3
|
export interface IMailConfig extends IBaseConfig {
|
|
4
4
|
mail: {
|
|
5
|
+
postmarkApiKey: string;
|
|
5
6
|
host: string;
|
|
6
7
|
port: number;
|
|
7
8
|
secure: boolean;
|
|
@@ -14,6 +15,12 @@ export interface IMailConfig extends IBaseConfig {
|
|
|
14
15
|
|
|
15
16
|
export const configSchema = {
|
|
16
17
|
mail: {
|
|
18
|
+
postmarkApiKey: {
|
|
19
|
+
doc: 'The API key for the Postmark mail service.',
|
|
20
|
+
format: String,
|
|
21
|
+
default: '',
|
|
22
|
+
env: 'MAIL_POSTMARK_API_KEY',
|
|
23
|
+
},
|
|
17
24
|
host: {
|
|
18
25
|
doc: 'The host of the mail server.',
|
|
19
26
|
format: String,
|
package/src/send.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { errors, logger } from '@takaro/util';
|
|
2
|
-
import { createTransport } from 'nodemailer';
|
|
2
|
+
import { createTransport, Transporter } from 'nodemailer';
|
|
3
3
|
import { EMAIL_TEMPLATES } from './templates.js';
|
|
4
|
+
import { PostmarkTransport } from 'nodemailer-postmark-transport';
|
|
4
5
|
|
|
5
6
|
import { config } from './config.js';
|
|
6
7
|
|
|
@@ -11,7 +12,21 @@ export interface ISendOptions {
|
|
|
11
12
|
}
|
|
12
13
|
|
|
13
14
|
const log = logger('email:send');
|
|
14
|
-
|
|
15
|
+
|
|
16
|
+
let transporter: Transporter;
|
|
17
|
+
if (config.get('mail.postmarkApiKey')) {
|
|
18
|
+
log.info('Using Postmark as mail transport');
|
|
19
|
+
transporter = createTransport(
|
|
20
|
+
new PostmarkTransport({
|
|
21
|
+
auth: {
|
|
22
|
+
apiKey: config.get('mail.postmarkApiKey'),
|
|
23
|
+
},
|
|
24
|
+
}),
|
|
25
|
+
);
|
|
26
|
+
} else {
|
|
27
|
+
log.info('Using SMTP as mail transport');
|
|
28
|
+
transporter = createTransport(config.get('mail'));
|
|
29
|
+
}
|
|
15
30
|
|
|
16
31
|
export async function send(opts: ISendOptions) {
|
|
17
32
|
const template = EMAIL_TEMPLATES[opts.template];
|