nuxt-mail 5.1.1 → 6.0.1
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/LICENSE.md +14 -5
- package/README.md +2 -0
- package/dist/index.js +26 -55
- package/package.json +17 -19
- package/dist/plugin-nuxt2.js +0 -9
- /package/dist/{plugin-nuxt3.js → plugin.js} +0 -0
package/LICENSE.md
CHANGED
|
@@ -14,8 +14,17 @@ MIT License
|
|
|
14
14
|
|
|
15
15
|
Copyright (c) <year> <copyright holders>
|
|
16
16
|
|
|
17
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
17
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
|
18
|
+
associated documentation files (the "Software"), to deal in the Software without restriction, including
|
|
19
|
+
without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
20
|
+
copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the
|
|
21
|
+
following conditions:
|
|
22
|
+
|
|
23
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial
|
|
24
|
+
portions of the Software.
|
|
25
|
+
|
|
26
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
|
27
|
+
LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
|
|
28
|
+
EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
29
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
|
30
|
+
USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
CHANGED
|
@@ -55,6 +55,8 @@ Adds email sending capability to a Nuxt.js app. Adds a server route, an injected
|
|
|
55
55
|
|
|
56
56
|
Does not work for static sites (via `nuxt generate`) because the module creates a server route.
|
|
57
57
|
|
|
58
|
+
ℹ️ **Info:** This module has been built in Nuxt 2 time where it was extra effort to build server routes. With Nuxt 3 it got much easier to do so, so this module is basically for simple contact forms. If you want to build more complex stuff, I recommend to use [nodemailer](https://www.npmjs.com/package/nodemailer) directly or [nuxt-nodemailer](https://www.npmjs.com/package/nuxt-nodemailer) instead.
|
|
59
|
+
|
|
58
60
|
<!-- INSTALL/ -->
|
|
59
61
|
## Install
|
|
60
62
|
|
package/dist/index.js
CHANGED
|
@@ -1,29 +1,18 @@
|
|
|
1
1
|
import { some } from '@dword-design/functions';
|
|
2
|
-
import { addImports, addServerHandler, addTemplate, createResolver
|
|
3
|
-
import express from 'express';
|
|
2
|
+
import { addImports, addServerHandler, addTemplate, createResolver } from '@nuxt/kit';
|
|
4
3
|
import fs from 'fs-extra';
|
|
5
|
-
import nodemailer from 'nodemailer';
|
|
6
4
|
import nuxtAliasPath from 'nuxt-alias-path';
|
|
7
5
|
import nuxtPushPlugins from 'nuxt-push-plugins';
|
|
8
6
|
import parsePackagejsonName from 'parse-packagejson-name';
|
|
9
7
|
import P from 'path';
|
|
10
|
-
import send from "./send.js";
|
|
11
8
|
const resolver = createResolver(import.meta.url);
|
|
12
9
|
const packageConfig = fs.readJsonSync(resolver.resolve('../package.json'));
|
|
13
10
|
const moduleName = parsePackagejsonName(packageConfig.name).fullName;
|
|
14
|
-
export default
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
try {
|
|
18
|
-
isNuxt3 = isNuxt3Try();
|
|
19
|
-
} catch {
|
|
20
|
-
isNuxt3 = false;
|
|
21
|
-
}
|
|
22
|
-
const runtimeConfig = nuxt.options[isNuxt3 ? 'runtimeConfig' : 'privateRuntimeConfig'];
|
|
23
|
-
const options = {
|
|
24
|
-
...runtimeConfig.mail,
|
|
11
|
+
export default (options, nuxt) => {
|
|
12
|
+
options = {
|
|
13
|
+
...nuxt.options.runtimeConfig.mail,
|
|
25
14
|
...nuxt.options.mail,
|
|
26
|
-
...
|
|
15
|
+
...options
|
|
27
16
|
};
|
|
28
17
|
if (!options.smtp) {
|
|
29
18
|
throw new Error('SMTP config is missing.');
|
|
@@ -37,42 +26,24 @@ export default function (moduleOptions, nuxt) {
|
|
|
37
26
|
if (some(c => !c.to && !c.cc && !c.bcc)(options.message)) {
|
|
38
27
|
throw new Error('You have to provide to/cc/bcc in all configs.');
|
|
39
28
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
const app = express();
|
|
62
|
-
const transport = nodemailer.createTransport(options.smtp);
|
|
63
|
-
app.use(express.json());
|
|
64
|
-
app.post('/send', async (req, res) => {
|
|
65
|
-
try {
|
|
66
|
-
await send(req.body, options, transport);
|
|
67
|
-
} catch (error) {
|
|
68
|
-
return res.status(500).send(error.message);
|
|
69
|
-
}
|
|
70
|
-
return res.sendStatus(200);
|
|
71
|
-
});
|
|
72
|
-
nuxt.addServerMiddleware({
|
|
73
|
-
handler: app,
|
|
74
|
-
path: '/mail'
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
nuxtPushPlugins(nuxt, resolver.resolve(`./plugin-nuxt${isNuxt3 ? 3 : 2}.js`));
|
|
78
|
-
}
|
|
29
|
+
addTemplate({
|
|
30
|
+
filename: P.join(moduleName, 'options.mjs'),
|
|
31
|
+
getContents: () => `export default ${JSON.stringify(options, undefined, 2)}`,
|
|
32
|
+
write: true
|
|
33
|
+
});
|
|
34
|
+
addTemplate({
|
|
35
|
+
filename: P.join(moduleName, 'send.mjs'),
|
|
36
|
+
getContents: () => fs.readFile(resolver.resolve('./send.js'), 'utf8'),
|
|
37
|
+
write: true
|
|
38
|
+
});
|
|
39
|
+
nuxt.options.alias['#mail'] = nuxtAliasPath(moduleName, nuxt);
|
|
40
|
+
addServerHandler({
|
|
41
|
+
handler: resolver.resolve('./server-handler.post.js'),
|
|
42
|
+
route: '/mail/send'
|
|
43
|
+
});
|
|
44
|
+
addImports([{
|
|
45
|
+
from: resolver.resolve('./composable.js'),
|
|
46
|
+
name: 'useMail'
|
|
47
|
+
}]);
|
|
48
|
+
nuxtPushPlugins(nuxt, resolver.resolve(`./plugin.js`));
|
|
49
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nuxt-mail",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.0.1",
|
|
4
4
|
"description": "Adds email sending capability to a Nuxt.js app. Adds a server route, an injected variable, and uses nodemailer to send emails.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"email",
|
|
@@ -40,34 +40,32 @@
|
|
|
40
40
|
"test": "base test"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@dword-design/functions": "^6.0.
|
|
44
|
-
"@nuxt/kit": "^3.
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"nodemailer": "^6.4.11",
|
|
43
|
+
"@dword-design/functions": "^6.0.2",
|
|
44
|
+
"@nuxt/kit": "^3.16.2",
|
|
45
|
+
"fs-extra": "^11.3.0",
|
|
46
|
+
"h3": "^1.15.1",
|
|
47
|
+
"nodemailer": "^6.10.1",
|
|
49
48
|
"nuxt-alias-path": "^2.0.0",
|
|
50
|
-
"nuxt-push-plugins": "^2.1.
|
|
49
|
+
"nuxt-push-plugins": "^2.1.34",
|
|
51
50
|
"parse-packagejson-name": "^1.0.1"
|
|
52
51
|
},
|
|
53
52
|
"devDependencies": {
|
|
54
|
-
"@dword-design/base": "^11.
|
|
53
|
+
"@dword-design/base": "^11.2.10",
|
|
55
54
|
"@dword-design/base-config-nuxt-module": "^1.0.0",
|
|
56
|
-
"
|
|
57
|
-
"@nuxtjs/axios": "^5.13.1",
|
|
58
|
-
"axios": "^0",
|
|
59
|
-
"depcheck-package-name": "^3.0.0",
|
|
55
|
+
"axios": "^0.30.0",
|
|
60
56
|
"execa": "^8.0.1",
|
|
61
57
|
"get-port": "^7.1.0",
|
|
62
|
-
"nuxt": "^3.
|
|
58
|
+
"nuxt": "^3.16.2",
|
|
63
59
|
"nuxt-dev-ready": "^3.0.0",
|
|
64
|
-
"output-files": "^2.0.
|
|
60
|
+
"output-files": "^2.0.32",
|
|
61
|
+
"playwright": "^1.52.0",
|
|
62
|
+
"playwright-chromium": "^1.52.0",
|
|
65
63
|
"port-ready": "^0.1.0",
|
|
66
|
-
"smtp-tester": "^2.0
|
|
67
|
-
"tree-kill-promise": "^3.0.
|
|
68
|
-
"with-local-tmp-dir": "^5.
|
|
64
|
+
"smtp-tester": "^2.1.0",
|
|
65
|
+
"tree-kill-promise": "^3.0.14",
|
|
66
|
+
"with-local-tmp-dir": "^5.1.1"
|
|
69
67
|
},
|
|
70
|
-
"packageManager": "pnpm@
|
|
68
|
+
"packageManager": "pnpm@10.8.1+sha512.c50088ba998c67b8ca8c99df8a5e02fd2ae2e2b29aaf238feaa9e124248d3f48f9fb6db2424949ff901cffbb5e0f0cc1ad6aedb602cd29450751d11c35023677",
|
|
71
69
|
"engines": {
|
|
72
70
|
"node": ">=18"
|
|
73
71
|
},
|
package/dist/plugin-nuxt2.js
DELETED
|
File without changes
|