@runnerpro/backend 1.18.3 → 1.18.4

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.
@@ -20,13 +20,17 @@ const transporter = nodemailer_1.default.createTransport({
20
20
  user: process.env.GMAIL_EMAIL_USER,
21
21
  pass: process.env.GMAIL_EMAIL_PWD,
22
22
  },
23
+ connectionTimeout: 10000,
24
+ greetingTimeout: 10000,
25
+ socketTimeout: 20000,
23
26
  });
24
27
  const sendMail = ({ subject, title, body, to, link, attachments, bcc }) => __awaiter(void 0, void 0, void 0, function* () {
28
+ var _a;
25
29
  const toMapped = process.env.NODE_ENV === 'PROD' ? to.map((correo) => correo).join(',') : process.env.GMAIL_EMAIL_USER;
26
30
  if ((toMapped === null || toMapped === void 0 ? void 0 : toMapped.length) === 0)
27
31
  return;
28
32
  const bodyHTML = getBodyHTML(title, body, link);
29
- return transporter.sendMail({
33
+ const sendPromise = transporter.sendMail({
30
34
  from: process.env.GMAIL_EMAIL_USER,
31
35
  to: toMapped,
32
36
  bcc: process.env.NODE_ENV === 'PROD' && bcc ? bcc.map((correo) => correo).join(',') : '',
@@ -42,6 +46,29 @@ const sendMail = ({ subject, title, body, to, link, attachments, bcc }) => __awa
42
46
  },
43
47
  ],
44
48
  });
49
+ const transport = (_a = transporter.transporter) !== null && _a !== void 0 ? _a : transporter;
50
+ const errorPromise = new Promise((_, reject) => {
51
+ const onError = (err) => {
52
+ transport.removeListener('error', onError);
53
+ transport.removeListener('close', onClose);
54
+ reject(err);
55
+ };
56
+ const onClose = () => {
57
+ transport.removeListener('error', onError);
58
+ transport.removeListener('close', onClose);
59
+ reject(new Error('SMTP connection closed'));
60
+ };
61
+ transport.once('error', onError);
62
+ transport.once('close', onClose);
63
+ sendPromise.finally(() => {
64
+ transport.removeListener('error', onError);
65
+ transport.removeListener('close', onClose);
66
+ });
67
+ });
68
+ const timeoutPromise = new Promise((_, reject) => {
69
+ setTimeout(() => reject(new Error('sendMail timeout')), 30000);
70
+ });
71
+ return Promise.race([sendPromise, errorPromise, timeoutPromise]);
45
72
  });
46
73
  exports.sendMail = sendMail;
47
74
  function getBodyHTML(title, body, link) {
@@ -52,13 +79,10 @@ function getBodyHTML(title, body, link) {
52
79
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
53
80
  <title>Correo con estilo</title>
54
81
  <style>
55
- /* Estilos generales */
56
82
  body {
57
83
  margin: 0;
58
84
  padding: 0;
59
85
  }
60
-
61
- /* Estilos específicos del botón */
62
86
  .button {
63
87
  display: inline-block;
64
88
  padding: 12px 26px;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/sendMail/index.ts"],"names":[],"mappings":"AAUA,UAAU,IAAI;IACZ,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,EAAE,CAAC;IACb,IAAI,CAAC,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;IACrC,WAAW,CAAC,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,GAAG,CAAC,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IACjE,GAAG,CAAC,EAAE,MAAM,EAAE,CAAC;CAChB;AAED,QAAA,MAAM,QAAQ,yDAAgE,IAAI,qEAoBjF,CAAC;AA0EF,OAAO,EAAE,QAAQ,EAAE,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/sendMail/index.ts"],"names":[],"mappings":"AAaA,UAAU,IAAI;IACZ,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,EAAE,CAAC;IACb,IAAI,CAAC,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;IACrC,WAAW,CAAC,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,GAAG,CAAC,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IACjE,GAAG,CAAC,EAAE,MAAM,EAAE,CAAC;CAChB;AAED,QAAA,MAAM,QAAQ,yDAAgE,IAAI,qEA6CjF,CAAC;AAuEF,OAAO,EAAE,QAAQ,EAAE,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@runnerpro/backend",
3
- "version": "1.18.3",
3
+ "version": "1.18.4",
4
4
  "description": "A collection of common backend functions",
5
5
  "exports": {
6
6
  ".": "./lib/cjs/index.js"