nitro-web 0.3.18 → 0.3.20
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nitro-web",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.20",
|
|
4
4
|
"repository": "github:boycce/nitro-web",
|
|
5
5
|
"homepage": "https://boycce.github.io/nitro-web/",
|
|
6
6
|
"description": "Nitro is a battle-tested, modular base project to turbocharge your projects, styled using Tailwind 🚀",
|
package/server/email/index.js
CHANGED
|
@@ -34,6 +34,7 @@ export const optionalEmailConfigKeys = ['emailReplyTo', 'emailTestMode', 'mailgu
|
|
|
34
34
|
* @param {string} [opts.subject] - subject (can also be defined in template)
|
|
35
35
|
* @param {boolean} [opts.skipCssInline] - skip CSS inlining
|
|
36
36
|
* @param {boolean} [opts.test] - enable test mode
|
|
37
|
+
* @param {{ filename: string, content: Buffer, contentType?: string }[]} [opts.attachments] - file attachments
|
|
37
38
|
* @returns {Promise<[any, any]>} Resolves with [mailgunErr, mailgunInfo]
|
|
38
39
|
*/
|
|
39
40
|
export async function sendEmail({
|
|
@@ -49,6 +50,7 @@ export async function sendEmail({
|
|
|
49
50
|
subject,
|
|
50
51
|
skipCssInline,
|
|
51
52
|
test,
|
|
53
|
+
attachments,
|
|
52
54
|
}) {
|
|
53
55
|
const isTest = config.emailTestMode || test
|
|
54
56
|
if (!config) throw new Error('sendEmail: `config` missing')
|
|
@@ -105,6 +107,7 @@ export async function sendEmail({
|
|
|
105
107
|
}
|
|
106
108
|
|
|
107
109
|
let settings = {
|
|
110
|
+
attachments: attachments,
|
|
108
111
|
bcc: bcc,
|
|
109
112
|
emailTemplateDir: getDirectories(path, config.pwd).emailTemplateDir,
|
|
110
113
|
from: from,
|
|
@@ -203,6 +206,7 @@ async function sendWithMailgun(settings, html) {
|
|
|
203
206
|
const processedhtml = await processTemplate(settings, html)
|
|
204
207
|
const mailgunOpts = {
|
|
205
208
|
...(settings.bcc && !settings.isDev? { bcc: settings.bcc } : {}),
|
|
209
|
+
...(settings.attachments?.length ? { attachments: settings.attachments } : {}),
|
|
206
210
|
from: settings.from,
|
|
207
211
|
html: processedhtml,
|
|
208
212
|
'h:Reply-To': settings.replyTo,
|
|
@@ -215,7 +219,12 @@ async function sendWithMailgun(settings, html) {
|
|
|
215
219
|
}),
|
|
216
220
|
}
|
|
217
221
|
if (settings.test && settings.isDev) {
|
|
218
|
-
console.info('Test mode: sendEmail mailgunOpts', {
|
|
222
|
+
console.info('Test mode: sendEmail mailgunOpts', {
|
|
223
|
+
...mailgunOpts,
|
|
224
|
+
html: null,
|
|
225
|
+
'recipient-variables': settings.recipientVariables,
|
|
226
|
+
attachments: settings.attachments?.map((a) => `${a.filename} (${a.content?.length} bytes)`),
|
|
227
|
+
})
|
|
219
228
|
}
|
|
220
229
|
if (settings.test) return processedhtml
|
|
221
230
|
|
|
@@ -15,9 +15,10 @@
|
|
|
15
15
|
* @param {string} [opts.subject] - subject (can also be defined in template)
|
|
16
16
|
* @param {boolean} [opts.skipCssInline] - skip CSS inlining
|
|
17
17
|
* @param {boolean} [opts.test] - enable test mode
|
|
18
|
+
* @param {{ filename: string, content: Buffer, contentType?: string }[]} [opts.attachments] - file attachments
|
|
18
19
|
* @returns {Promise<[any, any]>} Resolves with [mailgunErr, mailgunInfo]
|
|
19
20
|
*/
|
|
20
|
-
export function sendEmail({ template, to, config, bcc, data, swigData, from, replyTo, recipientVariables, subject, skipCssInline, test, }: {
|
|
21
|
+
export function sendEmail({ template, to, config, bcc, data, swigData, from, replyTo, recipientVariables, subject, skipCssInline, test, attachments, }: {
|
|
21
22
|
template: string;
|
|
22
23
|
to: string;
|
|
23
24
|
config: Config;
|
|
@@ -30,6 +31,11 @@ export function sendEmail({ template, to, config, bcc, data, swigData, from, rep
|
|
|
30
31
|
subject?: string;
|
|
31
32
|
skipCssInline?: boolean;
|
|
32
33
|
test?: boolean;
|
|
34
|
+
attachments?: {
|
|
35
|
+
filename: string;
|
|
36
|
+
content: Buffer;
|
|
37
|
+
contentType?: string;
|
|
38
|
+
}[];
|
|
33
39
|
}): Promise<[any, any]>;
|
|
34
40
|
export const requiredEmailConfigKeys: string[];
|
|
35
41
|
export const optionalEmailConfigKeys: string[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../server/email/index.js"],"names":[],"mappings":"AAmBA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../server/email/index.js"],"names":[],"mappings":"AAmBA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wJAfG;IAAqB,QAAQ,EAArB,MAAM;IACO,EAAE,EAAf,MAAM;IACO,MAAM,EAAnB,MAAM;IACQ,GAAG,GAAjB,MAAM;IACQ,IAAI,GAAlB,MAAM;IACQ,QAAQ,GAAtB,MAAM;IACQ,IAAI,GAAlB,MAAM;IACQ,OAAO,GAArB,MAAM;IACQ,kBAAkB,GAAhC,MAAM;IACQ,OAAO,GAArB,MAAM;IACS,aAAa,GAA5B,OAAO;IACQ,IAAI,GAAnB,OAAO;IAC8D,WAAW,GAAhF;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,WAAW,CAAC,EAAE,MAAM,CAAA;KAAE,EAAE;CACrE,GAAU,OAAO,CAAC,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CA2F/B;AAjHD,+CAA8E;AAC9E,+CAAuG;;;;qBAK1F;IAAE,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,aAAa,CAAC,EAAE,MAAM,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE"}
|