@dnax/core 0.10.3 → 0.10.5
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/config/index.ts +3 -2
- package/lib/mail.ts +17 -9
- package/package.json +1 -1
- package/types/index.ts +3 -3
package/config/index.ts
CHANGED
|
@@ -24,7 +24,8 @@ const Cfg: Config = {
|
|
|
24
24
|
|
|
25
25
|
function setCfg(config: Config) {
|
|
26
26
|
Cfg.server = config.server;
|
|
27
|
-
Cfg.tenants = config
|
|
27
|
+
Cfg.tenants = config?.tenants;
|
|
28
|
+
Cfg.email = config?.email;
|
|
28
29
|
|
|
29
30
|
Cfg.studio = {
|
|
30
31
|
enabled: config.studio?.enabled ?? false,
|
|
@@ -56,7 +57,7 @@ async function loadCfg() {
|
|
|
56
57
|
.then((inject: { default: Config }) => {
|
|
57
58
|
// Cfg.tenants = inject.default?.tenants || [];
|
|
58
59
|
// Cfg.server = inject.default?.server || [];
|
|
59
|
-
|
|
60
|
+
|
|
60
61
|
setCfg(inject.default);
|
|
61
62
|
//console.log(Cfg);
|
|
62
63
|
})
|
package/lib/mail.ts
CHANGED
|
@@ -111,7 +111,7 @@ function verifySmtpConnection(smtpConfig: emailConfigType["smtpOptions"]) {
|
|
|
111
111
|
|
|
112
112
|
function send(
|
|
113
113
|
options: {
|
|
114
|
-
|
|
114
|
+
config?: emailConfigType;
|
|
115
115
|
mailOptions?: {
|
|
116
116
|
from?: string;
|
|
117
117
|
text?: string;
|
|
@@ -126,17 +126,20 @@ function send(
|
|
|
126
126
|
) {
|
|
127
127
|
return new Promise(async (resolve, reject) => {
|
|
128
128
|
try {
|
|
129
|
-
const smtp = Cfg.email?.smtpOptions;
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
129
|
+
const smtp = options?.config?.smtpOptions || Cfg.email?.smtpOptions;
|
|
130
|
+
|
|
131
|
+
const transport = createTransport({
|
|
132
|
+
...smtp,
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
let from = options?.mailOptions?.from || (
|
|
136
|
+
`${options?.config?.fromName || ""} <${
|
|
137
|
+
options?.config?.fromAddress || ""
|
|
138
|
+
}>`),
|
|
133
139
|
|
|
134
140
|
var response = await transport.sendMail({
|
|
135
141
|
from:
|
|
136
|
-
|
|
137
|
-
`${options?.emailConfig?.fromName || ""} <${
|
|
138
|
-
options?.emailConfig?.fromAddress || ""
|
|
139
|
-
}>`,
|
|
142
|
+
|
|
140
143
|
to: options?.mailOptions?.to || undefined,
|
|
141
144
|
subject: options?.mailOptions?.subject || "",
|
|
142
145
|
text: options?.mailOptions?.text || "",
|
|
@@ -152,7 +155,12 @@ function send(
|
|
|
152
155
|
});
|
|
153
156
|
}
|
|
154
157
|
|
|
158
|
+
function getConfig() {
|
|
159
|
+
return Cfg?.email || {};
|
|
160
|
+
}
|
|
161
|
+
|
|
155
162
|
const email = {
|
|
163
|
+
getConfig,
|
|
156
164
|
send,
|
|
157
165
|
sendEmail,
|
|
158
166
|
sendLocalEmail,
|
package/package.json
CHANGED
package/types/index.ts
CHANGED
|
@@ -306,7 +306,7 @@ export type loggerFunction = (
|
|
|
306
306
|
action?: string;
|
|
307
307
|
collection?: string;
|
|
308
308
|
cleanDeep?: boolean;
|
|
309
|
-
|
|
309
|
+
|
|
310
310
|
useCache?: boolean;
|
|
311
311
|
method: string;
|
|
312
312
|
url?: string;
|
|
@@ -477,8 +477,8 @@ export type Service = {
|
|
|
477
477
|
|
|
478
478
|
export type emailConfigType = {
|
|
479
479
|
provider: "smtp";
|
|
480
|
-
fromName
|
|
481
|
-
fromAddress
|
|
480
|
+
fromName?: string;
|
|
481
|
+
fromAddress?: string;
|
|
482
482
|
smtpOptions?: {
|
|
483
483
|
host: string;
|
|
484
484
|
port: number;
|