@ooneex/mailer 0.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 +21 -0
- package/README.md +1 -0
- package/dist/index.d.ts +45 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +12 -0
- package/dist/ooneex-mailer-0.0.1.tgz +0 -0
- package/package.json +41 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Ooneex
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# @ooneex/router
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { Exception } from "@ooneex/exception";
|
|
2
|
+
declare class MailerException extends Exception {
|
|
3
|
+
constructor(message: string, data?: Record<string, unknown>);
|
|
4
|
+
}
|
|
5
|
+
type MailerClassType = new (...args: any[]) => IMailer;
|
|
6
|
+
interface IMailer {
|
|
7
|
+
send: (config: {
|
|
8
|
+
to: string[];
|
|
9
|
+
subject: string;
|
|
10
|
+
content: React.ReactNode;
|
|
11
|
+
from?: {
|
|
12
|
+
name: string;
|
|
13
|
+
address: string;
|
|
14
|
+
};
|
|
15
|
+
}) => Promise<void>;
|
|
16
|
+
}
|
|
17
|
+
declare class NodeMailerAdapter implements IMailer {
|
|
18
|
+
private dsn;
|
|
19
|
+
private from?;
|
|
20
|
+
constructor();
|
|
21
|
+
send(config: {
|
|
22
|
+
to: string[];
|
|
23
|
+
subject: string;
|
|
24
|
+
content: React.ReactNode;
|
|
25
|
+
from?: {
|
|
26
|
+
name: string;
|
|
27
|
+
address: string;
|
|
28
|
+
};
|
|
29
|
+
}): Promise<void>;
|
|
30
|
+
}
|
|
31
|
+
declare class ResendMailerAdapter implements IMailer {
|
|
32
|
+
private apiKey;
|
|
33
|
+
private from?;
|
|
34
|
+
constructor();
|
|
35
|
+
send(config: {
|
|
36
|
+
to: string[];
|
|
37
|
+
subject: string;
|
|
38
|
+
content: React.ReactNode;
|
|
39
|
+
from?: {
|
|
40
|
+
name: string;
|
|
41
|
+
address: string;
|
|
42
|
+
};
|
|
43
|
+
}): Promise<void>;
|
|
44
|
+
}
|
|
45
|
+
export { ResendMailerAdapter, NodeMailerAdapter, MailerException, MailerClassType, IMailer };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{Exception as a}from"@ooneex/exception";import{HttpStatus as m}from"@ooneex/http-status";class r extends a{constructor(e,t={}){super(e,{status:m.Code.InternalServerError,data:t});this.name="MailerException"}}import d from"nodemailer";import{renderToString as p}from"react-dom/server";class n{dsn;from;constructor(){if(this.dsn=Bun.env.NODE_MAILER_DSN?.trim(),this.from={name:Bun.env.MAILER_SENDER_NAME?.trim()||"",address:Bun.env.MAILER_SENDER_ADDRESS?.trim()||""},!this.dsn)throw new r("NODE_MAILER_DSN environment variable is not set or is empty. Please configure the mailer DSN connection string.")}async send(e){let t=e.from?.name||this.from?.name||"",s=e.from?.address||this.from?.address||"";if(!t)throw new r("MAILER_SENDER_NAME environment variable is not set or is empty. Please configure the mailer sender name.");if(!s)throw new r("MAILER_SENDER_ADDRESS environment variable is not set or is empty. Please configure the mailer sender address.");await d.createTransport({url:this.dsn}).sendMail({from:{name:t,address:s},to:e.to,subject:e.subject,html:p(e.content)})}}import{renderToString as c}from"react-dom/server";import{Resend as l}from"resend";class i{apiKey;from;constructor(){if(this.apiKey=Bun.env.RESEND_API_KEY?.trim(),this.from={name:Bun.env.MAILER_SENDER_NAME?.trim()||"",address:Bun.env.MAILER_SENDER_ADDRESS?.trim()||""},!this.apiKey)throw new r("RESEND_API_KEY environment variable is not set or is empty. Please configure the mailer DSN connection string.")}async send(e){let t=e.from?.name||this.from?.name||"",s=e.from?.address||this.from?.address||"";if(!t)throw new r("MAILER_SENDER_NAME environment variable is not set or is empty. Please configure the mailer sender name.");if(!s)throw new r("MAILER_SENDER_ADDRESS environment variable is not set or is empty. Please configure the mailer sender address.");await new l(this.apiKey).emails.send({to:e.to,from:`${t} <${s}>`,subject:`${e.subject}`,html:c(e.content)})}}export{i as ResendMailerAdapter,n as NodeMailerAdapter,r as MailerException};
|
|
2
|
+
|
|
3
|
+
//# debugId=5325288543FA48C964756E2164756E21
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["src/MailerException.ts", "src/NodeMailerAdapter.ts", "src/ResendMailerAdapter.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"import { Exception } from \"@ooneex/exception\";\nimport { HttpStatus } from \"@ooneex/http-status\";\n\nexport class MailerException extends Exception {\n constructor(message: string, data: Record<string, unknown> = {}) {\n super(message, {\n status: HttpStatus.Code.InternalServerError,\n data,\n });\n this.name = \"MailerException\";\n }\n}\n",
|
|
6
|
+
"import nodemailer from \"nodemailer\";\nimport { renderToString } from \"react-dom/server\";\nimport { MailerException } from \"./MailerException\";\nimport type { IMailer } from \"./types\";\n\nexport class NodeMailerAdapter implements IMailer {\n private dsn: string;\n private from?: { name: string; address: string };\n\n constructor() {\n this.dsn = Bun.env.NODE_MAILER_DSN?.trim() as string;\n\n this.from = {\n name: Bun.env.MAILER_SENDER_NAME?.trim() || \"\",\n address: Bun.env.MAILER_SENDER_ADDRESS?.trim() || \"\",\n };\n\n if (!this.dsn) {\n throw new MailerException(\n \"NODE_MAILER_DSN environment variable is not set or is empty. Please configure the mailer DSN connection string.\",\n );\n }\n }\n\n public async send(config: {\n to: string[];\n subject: string;\n content: React.ReactNode;\n from?: { name: string; address: string };\n }): Promise<void> {\n const senderName = config.from?.name || this.from?.name || \"\";\n const senderAddress = config.from?.address || this.from?.address || \"\";\n\n if (!senderName) {\n throw new MailerException(\n \"MAILER_SENDER_NAME environment variable is not set or is empty. Please configure the mailer sender name.\",\n );\n }\n\n if (!senderAddress) {\n throw new MailerException(\n \"MAILER_SENDER_ADDRESS environment variable is not set or is empty. Please configure the mailer sender address.\",\n );\n }\n\n const transporter = nodemailer.createTransport({\n url: this.dsn,\n });\n\n await transporter.sendMail({\n from: { name: senderName, address: senderAddress },\n to: config.to,\n subject: config.subject,\n html: renderToString(config.content),\n });\n }\n}\n",
|
|
7
|
+
"import { renderToString } from \"react-dom/server\";\nimport { Resend } from \"resend\";\nimport { MailerException } from \"./MailerException\";\nimport type { IMailer } from \"./types\";\n\nexport class ResendMailerAdapter implements IMailer {\n private apiKey: string;\n private from?: { name: string; address: string };\n\n constructor() {\n this.apiKey = Bun.env.RESEND_API_KEY?.trim() as string;\n\n this.from = {\n name: Bun.env.MAILER_SENDER_NAME?.trim() || \"\",\n address: Bun.env.MAILER_SENDER_ADDRESS?.trim() || \"\",\n };\n\n if (!this.apiKey) {\n throw new MailerException(\n \"RESEND_API_KEY environment variable is not set or is empty. Please configure the mailer DSN connection string.\",\n );\n }\n }\n\n public async send(config: {\n to: string[];\n subject: string;\n content: React.ReactNode;\n from?: { name: string; address: string };\n }): Promise<void> {\n const senderName = config.from?.name || this.from?.name || \"\";\n const senderAddress = config.from?.address || this.from?.address || \"\";\n\n if (!senderName) {\n throw new MailerException(\n \"MAILER_SENDER_NAME environment variable is not set or is empty. Please configure the mailer sender name.\",\n );\n }\n\n if (!senderAddress) {\n throw new MailerException(\n \"MAILER_SENDER_ADDRESS environment variable is not set or is empty. Please configure the mailer sender address.\",\n );\n }\n\n const client = new Resend(this.apiKey);\n\n await client.emails.send({\n to: config.to,\n from: `${senderName} <${senderAddress}>`,\n subject: `${config.subject}`,\n html: renderToString(config.content),\n });\n }\n}\n"
|
|
8
|
+
],
|
|
9
|
+
"mappings": "AAAA,oBAAS,0BACT,qBAAS,4BAEF,MAAM,UAAwB,CAAU,CAC7C,WAAW,CAAC,EAAiB,EAAgC,CAAC,EAAG,CAC/D,MAAM,EAAS,CACb,OAAQ,EAAW,KAAK,oBACxB,MACF,CAAC,EACD,KAAK,KAAO,kBAEhB,CCXA,0BACA,yBAAS,yBAIF,MAAM,CAAqC,CACxC,IACA,KAER,WAAW,EAAG,CAQZ,GAPA,KAAK,IAAM,IAAI,IAAI,iBAAiB,KAAK,EAEzC,KAAK,KAAO,CACV,KAAM,IAAI,IAAI,oBAAoB,KAAK,GAAK,GAC5C,QAAS,IAAI,IAAI,uBAAuB,KAAK,GAAK,EACpD,EAEI,CAAC,KAAK,IACR,MAAM,IAAI,EACR,iHACF,OAIS,KAAI,CAAC,EAKA,CAChB,IAAM,EAAa,EAAO,MAAM,MAAQ,KAAK,MAAM,MAAQ,GACrD,EAAgB,EAAO,MAAM,SAAW,KAAK,MAAM,SAAW,GAEpE,GAAI,CAAC,EACH,MAAM,IAAI,EACR,0GACF,EAGF,GAAI,CAAC,EACH,MAAM,IAAI,EACR,gHACF,EAOF,MAJoB,EAAW,gBAAgB,CAC7C,IAAK,KAAK,GACZ,CAAC,EAEiB,SAAS,CACzB,KAAM,CAAE,KAAM,EAAY,QAAS,CAAc,EACjD,GAAI,EAAO,GACX,QAAS,EAAO,QAChB,KAAM,EAAe,EAAO,OAAO,CACrC,CAAC,EAEL,CCxDA,yBAAS,yBACT,iBAAS,eAIF,MAAM,CAAuC,CAC1C,OACA,KAER,WAAW,EAAG,CAQZ,GAPA,KAAK,OAAS,IAAI,IAAI,gBAAgB,KAAK,EAE3C,KAAK,KAAO,CACV,KAAM,IAAI,IAAI,oBAAoB,KAAK,GAAK,GAC5C,QAAS,IAAI,IAAI,uBAAuB,KAAK,GAAK,EACpD,EAEI,CAAC,KAAK,OACR,MAAM,IAAI,EACR,gHACF,OAIS,KAAI,CAAC,EAKA,CAChB,IAAM,EAAa,EAAO,MAAM,MAAQ,KAAK,MAAM,MAAQ,GACrD,EAAgB,EAAO,MAAM,SAAW,KAAK,MAAM,SAAW,GAEpE,GAAI,CAAC,EACH,MAAM,IAAI,EACR,0GACF,EAGF,GAAI,CAAC,EACH,MAAM,IAAI,EACR,gHACF,EAKF,MAFe,IAAI,EAAO,KAAK,MAAM,EAExB,OAAO,KAAK,CACvB,GAAI,EAAO,GACX,KAAM,GAAG,MAAe,KACxB,QAAS,GAAG,EAAO,UACnB,KAAM,EAAe,EAAO,OAAO,CACrC,CAAC,EAEL",
|
|
10
|
+
"debugId": "5325288543FA48C964756E2164756E21",
|
|
11
|
+
"names": []
|
|
12
|
+
}
|
|
Binary file
|
package/package.json
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ooneex/mailer",
|
|
3
|
+
"description": "",
|
|
4
|
+
"version": "0.0.1",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"files": [
|
|
7
|
+
"dist",
|
|
8
|
+
"LICENSE",
|
|
9
|
+
"README.md",
|
|
10
|
+
"package.json"
|
|
11
|
+
],
|
|
12
|
+
"module": "./dist/index.js",
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
|
+
"exports": {
|
|
15
|
+
".": {
|
|
16
|
+
"import": {
|
|
17
|
+
"types": "./dist/index.d.ts",
|
|
18
|
+
"default": "./dist/index.js"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"./package.json": "./package.json"
|
|
22
|
+
},
|
|
23
|
+
"license": "MIT",
|
|
24
|
+
"scripts": {
|
|
25
|
+
"test": "bun test tests",
|
|
26
|
+
"build": "bunup",
|
|
27
|
+
"lint": "tsgo --noEmit && bunx biome lint",
|
|
28
|
+
"publish:prod": "bun publish --tolerate-republish --access public",
|
|
29
|
+
"publish:pack": "bun pm pack --destination ./dist",
|
|
30
|
+
"publish:dry": "bun publish --dry-run"
|
|
31
|
+
},
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"@ooneex/exception": "0.0.1",
|
|
34
|
+
"@ooneex/http-status": "0.0.1",
|
|
35
|
+
"nodemailer": "^7.0.10",
|
|
36
|
+
"react-dom": "^19.0.0",
|
|
37
|
+
"resend": "^6.4.2"
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {},
|
|
40
|
+
"peerDependencies": {}
|
|
41
|
+
}
|