nuxt-mail 3.1.1 → 3.1.3
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/index.js +2 -2
- package/dist/plugin-nuxt3.js +14 -10
- package/dist/server-handler.post.js +2 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -36,12 +36,12 @@ export default function (moduleOptions, nuxt) {
|
|
|
36
36
|
}
|
|
37
37
|
if (isNuxt3) {
|
|
38
38
|
addTemplate({
|
|
39
|
-
filename: P.join(moduleName, 'options.
|
|
39
|
+
filename: P.join(moduleName, 'options.mjs'),
|
|
40
40
|
getContents: () => `export default ${JSON.stringify(options, undefined, 2)}`,
|
|
41
41
|
write: true
|
|
42
42
|
});
|
|
43
43
|
addTemplate({
|
|
44
|
-
filename: P.join(moduleName, 'send.
|
|
44
|
+
filename: P.join(moduleName, 'send.mjs'),
|
|
45
45
|
getContents: () => fs.readFile(resolver.resolve('./send.js'), 'utf8'),
|
|
46
46
|
write: true
|
|
47
47
|
});
|
package/dist/plugin-nuxt3.js
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
1
|
-
import { useFetch } from '#app';
|
|
2
|
-
export default ((
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
import { defineNuxtPlugin, useFetch } from '#app';
|
|
2
|
+
export default defineNuxtPlugin(() => ({
|
|
3
|
+
provide: {
|
|
4
|
+
mail: {
|
|
5
|
+
send: async config => {
|
|
6
|
+
try {
|
|
7
|
+
await useFetch('/mail/send', {
|
|
8
|
+
body: config,
|
|
9
|
+
method: 'POST'
|
|
10
|
+
});
|
|
11
|
+
} catch (error) {
|
|
12
|
+
throw new Error(error.response.data);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
11
15
|
}
|
|
12
16
|
}
|
|
13
17
|
}));
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createError, defineEventHandler, readBody } from 'h3';
|
|
2
2
|
import nodemailer from 'nodemailer';
|
|
3
|
-
import options from '#mail/options.
|
|
4
|
-
import send from '#mail/send.
|
|
3
|
+
import options from '#mail/options.mjs';
|
|
4
|
+
import send from '#mail/send.mjs';
|
|
5
5
|
const transport = nodemailer.createTransport(options.smtp);
|
|
6
6
|
export default defineEventHandler(async event => {
|
|
7
7
|
try {
|
package/package.json
CHANGED