nuxt-workmailer 1.1.3 → 1.3.0
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/README.md +10 -8
- package/dist/module.json +3 -3
- package/dist/runtime/server/useNodeMailer.d.ts +1 -1
- package/dist/runtime/server/useNodeMailer.js +25 -2
- package/dist/types.d.mts +4 -15
- package/package.json +27 -27
- package/dist/module.cjs +0 -5
- package/dist/module.d.ts +0 -12
- package/dist/types.d.ts +0 -18
package/README.md
CHANGED
|
@@ -7,9 +7,11 @@
|
|
|
7
7
|
|
|
8
8
|
[![Buy me a coffee][buymecoffee-src]][buymeacoffee-href]
|
|
9
9
|
|
|
10
|
-
> Adds nodemailer to the
|
|
10
|
+
> Adds nodemailer to the Nuxt 3 and 4
|
|
11
11
|
>
|
|
12
|
-
> This module can be used to send emails only from the server-side in
|
|
12
|
+
> This module can be used to send emails only from the server-side in Nuxt 3 and 4.
|
|
13
|
+
>
|
|
14
|
+
> This fork of `nuxt-nodemailer` adds support for Cloudflare workers
|
|
13
15
|
|
|
14
16
|
## Features
|
|
15
17
|
- Auto import server composable `useNodeMailer()`
|
|
@@ -100,14 +102,14 @@ export default defineEventHandler(() => {
|
|
|
100
102
|
})
|
|
101
103
|
```
|
|
102
104
|
|
|
103
|
-
[npm-version-src]: https://img.shields.io/npm/v/nuxt-
|
|
104
|
-
[npm-version-href]: https://npmjs.com/package/nuxt-
|
|
105
|
+
[npm-version-src]: https://img.shields.io/npm/v/nuxt-workmailer/latest.svg?style=flat&colorA=18181B&colorB=28CF8D
|
|
106
|
+
[npm-version-href]: https://npmjs.com/package/nuxt-workmailer
|
|
105
107
|
|
|
106
|
-
[npm-downloads-src]: https://img.shields.io/npm/dt/nuxt-
|
|
107
|
-
[npm-downloads-href]: https://npmjs.com/package/nuxt-
|
|
108
|
+
[npm-downloads-src]: https://img.shields.io/npm/dt/nuxt-workmailer.svg?style=flat&colorA=18181B&colorB=28CF8D
|
|
109
|
+
[npm-downloads-href]: https://npmjs.com/package/nuxt-workmailer
|
|
108
110
|
|
|
109
|
-
[license-src]: https://img.shields.io/npm/l/nuxt-
|
|
110
|
-
[license-href]: https://npmjs.com/package/nuxt-
|
|
111
|
+
[license-src]: https://img.shields.io/npm/l/nuxt-workmailer.svg?style=flat&colorA=18181B&colorB=28CF8D
|
|
112
|
+
[license-href]: https://npmjs.com/package/nuxt-workmailer
|
|
111
113
|
|
|
112
114
|
[nuxt-src]: https://img.shields.io/badge/Nuxt-18181B?logo=nuxt.js
|
|
113
115
|
[nuxt-href]: https://nuxt.com
|
package/dist/module.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type SMTPTransport from 'nodemailer/lib/smtp-transport';
|
|
2
2
|
export declare const useNodeMailer: () => {
|
|
3
3
|
nodemailer: any;
|
|
4
|
-
sendMail: (options: SMTPTransport.MailOptions) => Promise<
|
|
4
|
+
sendMail: (options: SMTPTransport.MailOptions) => Promise<import("nodemailer/lib/smtp-pool/index.js").SentMessageInfo | undefined>;
|
|
5
5
|
};
|
|
@@ -1,4 +1,18 @@
|
|
|
1
1
|
import { useRuntimeConfig } from "#imports";
|
|
2
|
+
function toUser(address) {
|
|
3
|
+
if (typeof address !== "string") {
|
|
4
|
+
return { name: address.name, email: address.address };
|
|
5
|
+
}
|
|
6
|
+
const open = address.lastIndexOf("<");
|
|
7
|
+
const close = address.lastIndexOf(">");
|
|
8
|
+
if (open === -1 || close < open) return { email: address.trim() };
|
|
9
|
+
const name = address.slice(0, open).trim().replace(/^"|"$/g, "");
|
|
10
|
+
return { name: name || void 0, email: address.slice(open + 1, close).trim() };
|
|
11
|
+
}
|
|
12
|
+
function toUsers(addresses) {
|
|
13
|
+
if (!addresses) return void 0;
|
|
14
|
+
return (Array.isArray(addresses) ? addresses : [addresses]).map(toUser);
|
|
15
|
+
}
|
|
2
16
|
export const useNodeMailer = () => {
|
|
3
17
|
const { nodemailer } = useRuntimeConfig();
|
|
4
18
|
const sendMail = async (options) => {
|
|
@@ -13,6 +27,11 @@ export const useNodeMailer = () => {
|
|
|
13
27
|
return res;
|
|
14
28
|
} else {
|
|
15
29
|
const { WorkerMailer } = await import("worker-mailer");
|
|
30
|
+
const { from = nodemailer.from, to, cc, bcc, replyTo, ...rest } = options;
|
|
31
|
+
const [reply, ...extraReplies] = toUsers(replyTo) ?? [];
|
|
32
|
+
if (extraReplies.length) {
|
|
33
|
+
throw new Error("worker-mailer accepts a single replyTo address");
|
|
34
|
+
}
|
|
16
35
|
await WorkerMailer.send(
|
|
17
36
|
{
|
|
18
37
|
credentials: {
|
|
@@ -25,8 +44,12 @@ export const useNodeMailer = () => {
|
|
|
25
44
|
secure: nodemailer.secure
|
|
26
45
|
},
|
|
27
46
|
{
|
|
28
|
-
|
|
29
|
-
|
|
47
|
+
...rest,
|
|
48
|
+
from: toUser(from),
|
|
49
|
+
to: toUsers(to) ?? [],
|
|
50
|
+
reply,
|
|
51
|
+
cc: toUsers(cc),
|
|
52
|
+
bcc: toUsers(bcc)
|
|
30
53
|
}
|
|
31
54
|
);
|
|
32
55
|
}
|
package/dist/types.d.mts
CHANGED
|
@@ -1,18 +1,7 @@
|
|
|
1
|
+
import type { NuxtModule } from '@nuxt/schema'
|
|
1
2
|
|
|
2
|
-
import type {
|
|
3
|
+
import type { default as Module } from './module.mjs'
|
|
3
4
|
|
|
5
|
+
export type ModuleOptions = typeof Module extends NuxtModule<infer O> ? Partial<O> : Record<string, any>
|
|
4
6
|
|
|
5
|
-
|
|
6
|
-
export interface ModuleOptions {
|
|
7
|
-
[key: string]: any
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
declare module 'nuxt/schema' {
|
|
12
|
-
export interface ModuleOptions {
|
|
13
|
-
[key: string]: any
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
export type { default } from './module.js'
|
|
7
|
+
export { default } from './module.mjs'
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nuxt-workmailer",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "nodemailer Nuxt Module with Worker support",
|
|
5
5
|
"repository": "twinkelmann/nuxt-workmailer",
|
|
6
6
|
"license": "MIT",
|
|
@@ -11,13 +11,10 @@
|
|
|
11
11
|
"type": "module",
|
|
12
12
|
"exports": {
|
|
13
13
|
".": {
|
|
14
|
-
"
|
|
15
|
-
"import": "./dist/module.mjs",
|
|
16
|
-
"require": "./dist/module.cjs"
|
|
14
|
+
"import": "./dist/module.mjs"
|
|
17
15
|
}
|
|
18
16
|
},
|
|
19
|
-
"main": "./dist/module.
|
|
20
|
-
"types": "./dist/types.d.ts",
|
|
17
|
+
"main": "./dist/module.mjs",
|
|
21
18
|
"files": [
|
|
22
19
|
"dist"
|
|
23
20
|
],
|
|
@@ -35,36 +32,39 @@
|
|
|
35
32
|
"server",
|
|
36
33
|
"webdevelopment"
|
|
37
34
|
],
|
|
35
|
+
"scripts": {
|
|
36
|
+
"prepack": "nuxt-module-build build",
|
|
37
|
+
"dev": "nuxi dev playground",
|
|
38
|
+
"dev:build": "nuxi build playground",
|
|
39
|
+
"dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxi prepare playground",
|
|
40
|
+
"release": "npm run lint && npm run prepack && changelogen --release && npm publish && git push --follow-tags",
|
|
41
|
+
"lint": "eslint . --fix",
|
|
42
|
+
"test:types": "vue-tsc --noEmit && cd playground && vue-tsc --noEmit"
|
|
43
|
+
},
|
|
38
44
|
"dependencies": {
|
|
39
|
-
"@nuxt/kit": "^3.11.2"
|
|
45
|
+
"@nuxt/kit": "^3.11.2",
|
|
46
|
+
"@types/nodemailer": "^7.0.2"
|
|
40
47
|
},
|
|
41
48
|
"peerDependencies": {
|
|
42
|
-
"nodemailer": "^
|
|
43
|
-
"worker-mailer": "^1.
|
|
49
|
+
"nodemailer": "^7.0.9",
|
|
50
|
+
"worker-mailer": "^1.2.1"
|
|
44
51
|
},
|
|
45
52
|
"devDependencies": {
|
|
46
|
-
"@nuxt/devtools": "^1.
|
|
53
|
+
"@nuxt/devtools": "^1.7.0",
|
|
47
54
|
"@nuxt/eslint-config": "^0.3.13",
|
|
48
|
-
"@nuxt/module-builder": "^0.
|
|
55
|
+
"@nuxt/module-builder": "^1.0.2",
|
|
49
56
|
"@nuxt/schema": "^3.11.2",
|
|
50
|
-
"@nuxt/test-utils": "^3.
|
|
51
|
-
"@types/node": "^20.
|
|
57
|
+
"@nuxt/test-utils": "^3.19.2",
|
|
58
|
+
"@types/node": "^20.19.19",
|
|
52
59
|
"@types/nodemailer": "^6.4.15",
|
|
53
|
-
"changelogen": "^0.5.
|
|
60
|
+
"changelogen": "^0.5.7",
|
|
54
61
|
"eslint": "^9.3.0",
|
|
55
|
-
"nodemailer": "^
|
|
56
|
-
"nuxt": "^3.
|
|
62
|
+
"nodemailer": "^7.0.9",
|
|
63
|
+
"nuxt": "^3.19.2",
|
|
57
64
|
"prettier": "=3.5.3",
|
|
58
|
-
"typescript": "
|
|
59
|
-
"vue-tsc": "^2.
|
|
65
|
+
"typescript": "^5.9.3",
|
|
66
|
+
"vue-tsc": "^2.2.12",
|
|
60
67
|
"worker-mailer": "^1.1.1"
|
|
61
68
|
},
|
|
62
|
-
"
|
|
63
|
-
|
|
64
|
-
"dev:build": "nuxi build playground",
|
|
65
|
-
"dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxi prepare playground",
|
|
66
|
-
"release": "npm run lint && npm run prepack && changelogen --release && npm publish && git push --follow-tags",
|
|
67
|
-
"lint": "eslint . --fix",
|
|
68
|
-
"test:types": "vue-tsc --noEmit && cd playground && vue-tsc --noEmit"
|
|
69
|
-
}
|
|
70
|
-
}
|
|
69
|
+
"packageManager": "pnpm@10.7.1+sha512.2d92c86b7928dc8284f53494fb4201f983da65f0fb4f0d40baafa5cf628fa31dae3e5968f12466f17df7e97310e30f343a648baea1b9b350685dafafffdf5808"
|
|
70
|
+
}
|
package/dist/module.cjs
DELETED
package/dist/module.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import * as _nuxt_schema from '@nuxt/schema';
|
|
2
|
-
import SMTPTransport from 'nodemailer/lib/smtp-transport';
|
|
3
|
-
|
|
4
|
-
declare const _default: _nuxt_schema.NuxtModule<SMTPTransport.Options>;
|
|
5
|
-
|
|
6
|
-
declare module '@nuxt/schema' {
|
|
7
|
-
interface RuntimeConfig {
|
|
8
|
-
nodemailer: SMTPTransport.Options;
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export { _default as default };
|
package/dist/types.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import type { } from './module'
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
declare module '@nuxt/schema' {
|
|
6
|
-
export interface ModuleOptions {
|
|
7
|
-
[key: string]: any
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
declare module 'nuxt/schema' {
|
|
12
|
-
export interface ModuleOptions {
|
|
13
|
-
[key: string]: any
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
export type { default } from './module'
|