@betterinternship/core 2.3.2 → 2.3.3
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export {};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export {};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/lib/chat/pb.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import PocketBase from 'pocketbase';
|
|
2
|
-
import { ENV } from '../env.js';
|
|
3
|
-
let _pb = {};
|
|
4
|
-
if (!ENV.BICORE_IGNORE_POCKETBASE) {
|
|
5
|
-
_pb = new PocketBase(ENV.PB_URL);
|
|
6
|
-
_pb.autoCancellation(false);
|
|
7
|
-
}
|
|
8
|
-
export const pb = _pb;
|
|
9
|
-
export const authenticatePocketbase = async () => {
|
|
10
|
-
await _pb
|
|
11
|
-
.collection('_superusers')
|
|
12
|
-
.authWithPassword(ENV.PB_ADMIN_EMAIL, ENV.PB_ADMIN_PASSWORD, { autoRefreshThreshold: 30 * 60 });
|
|
13
|
-
};
|
|
14
|
-
if (!ENV.BICORE_IGNORE_POCKETBASE)
|
|
15
|
-
authenticatePocketbase();
|
|
1
|
+
import PocketBase from 'pocketbase';
|
|
2
|
+
import { ENV } from '../env.js';
|
|
3
|
+
let _pb = {};
|
|
4
|
+
if (!ENV.BICORE_IGNORE_POCKETBASE) {
|
|
5
|
+
_pb = new PocketBase(ENV.PB_URL);
|
|
6
|
+
_pb.autoCancellation(false);
|
|
7
|
+
}
|
|
8
|
+
export const pb = _pb;
|
|
9
|
+
export const authenticatePocketbase = async () => {
|
|
10
|
+
await _pb
|
|
11
|
+
.collection('_superusers')
|
|
12
|
+
.authWithPassword(ENV.PB_ADMIN_EMAIL, ENV.PB_ADMIN_PASSWORD, { autoRefreshThreshold: 30 * 60 });
|
|
13
|
+
};
|
|
14
|
+
if (!ENV.BICORE_IGNORE_POCKETBASE)
|
|
15
|
+
authenticatePocketbase();
|
|
16
16
|
//# sourceMappingURL=pb.js.map
|
package/dist/lib/email/email.js
CHANGED
|
@@ -1,67 +1,91 @@
|
|
|
1
|
-
import { TransactionalEmailsApi } from '@getbrevo/brevo';
|
|
2
|
-
import * as nodemailer from 'nodemailer';
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
transacApi
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
1
|
+
import { TransactionalEmailsApi } from '@getbrevo/brevo';
|
|
2
|
+
import * as nodemailer from 'nodemailer';
|
|
3
|
+
import { ENV } from '../env.js';
|
|
4
|
+
const SMTP_EMAIL = ENV.SMTP_EMAIL;
|
|
5
|
+
const SMTP_PASSWORD = ENV.SMTP_PASSWORD;
|
|
6
|
+
if (!SMTP_EMAIL || !SMTP_PASSWORD)
|
|
7
|
+
throw Error('[ERROR:ENV]: Missing SMTP setup.');
|
|
8
|
+
let transacApi = null;
|
|
9
|
+
if (process.env.NODE_ENV !== 'development') {
|
|
10
|
+
const BREVO_API_KEY = process.env.BREVO_API_KEY;
|
|
11
|
+
if (!BREVO_API_KEY)
|
|
12
|
+
throw Error('[ERROR:ENV]: Missing Brevo setup.');
|
|
13
|
+
transacApi = new TransactionalEmailsApi();
|
|
14
|
+
transacApi.setApiKey(0, BREVO_API_KEY);
|
|
15
|
+
}
|
|
16
|
+
const transporterConfig = {
|
|
17
|
+
service: 'Gmail',
|
|
18
|
+
host: 'smtp.gmail.com',
|
|
19
|
+
port: 465,
|
|
20
|
+
secure: true,
|
|
21
|
+
};
|
|
22
|
+
const transporters = {
|
|
23
|
+
hello: nodemailer.createTransport({
|
|
24
|
+
...transporterConfig,
|
|
25
|
+
auth: {
|
|
26
|
+
user: 'hello@betterinternship.com',
|
|
27
|
+
pass: SMTP_PASSWORD,
|
|
28
|
+
},
|
|
29
|
+
}),
|
|
30
|
+
otp: nodemailer.createTransport({
|
|
31
|
+
...transporterConfig,
|
|
32
|
+
auth: {
|
|
33
|
+
user: 'otp@betterinternship.com',
|
|
34
|
+
pass: SMTP_PASSWORD,
|
|
35
|
+
},
|
|
36
|
+
}),
|
|
37
|
+
applications: nodemailer.createTransport({
|
|
38
|
+
...transporterConfig,
|
|
39
|
+
auth: {
|
|
40
|
+
user: 'applications@betterinternship.com',
|
|
41
|
+
pass: SMTP_PASSWORD,
|
|
42
|
+
},
|
|
43
|
+
}),
|
|
44
|
+
sign: nodemailer.createTransport({
|
|
45
|
+
...transporterConfig,
|
|
46
|
+
auth: {
|
|
47
|
+
user: 'sign@betterinternship.com',
|
|
48
|
+
pass: SMTP_PASSWORD,
|
|
49
|
+
},
|
|
50
|
+
}),
|
|
51
|
+
};
|
|
52
|
+
export const sendSingleEmail = async ({ sender, subject, recipient, content, alias = 'hello', }) => {
|
|
53
|
+
if (process.env.NODE_ENV === 'development' || true) {
|
|
54
|
+
return new Promise((resolve, reject) => {
|
|
55
|
+
transporters[alias].sendMail({
|
|
56
|
+
from: `"${sender ?? 'BetterInternship'}" <${alias}@betterinternship.com>`,
|
|
57
|
+
to: recipient,
|
|
58
|
+
subject,
|
|
59
|
+
html: content,
|
|
60
|
+
}, (error, info) => {
|
|
61
|
+
if (error) {
|
|
62
|
+
console.error('[ERROR] Could not send email.');
|
|
63
|
+
console.error('[-----] ' + error.message);
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
resolve({
|
|
67
|
+
messageId: info.messageId,
|
|
68
|
+
response: info.response,
|
|
69
|
+
});
|
|
70
|
+
console.warn('[LOG] Email sent to ' + recipient);
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
const response = await transacApi?.sendTransacEmail({
|
|
77
|
+
sender: {
|
|
78
|
+
email: `"${sender ?? 'BetterInternship'}" <${alias}@betterinternship.com>`,
|
|
79
|
+
},
|
|
80
|
+
to: [{ email: recipient }],
|
|
81
|
+
subject,
|
|
82
|
+
htmlContent: content,
|
|
83
|
+
});
|
|
84
|
+
console.warn('[LOG] Email sent to ' + recipient);
|
|
85
|
+
return {
|
|
86
|
+
messageId: response?.body?.messageId,
|
|
87
|
+
response: response?.response,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
};
|
|
67
91
|
//# sourceMappingURL=email.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"email.js","sourceRoot":"","sources":["../../../lib/email/email.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,KAAK,UAAU,MAAM,YAAY,CAAC;AACzC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"email.js","sourceRoot":"","sources":["../../../lib/email/email.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,sBAAsB,EAAE,M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