@lenne.tech/nest-server 10.2.10 → 10.2.12
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/dist/core/common/services/brevo.service.js +24 -24
- package/dist/core/common/services/brevo.service.js.map +1 -1
- package/dist/core/common/services/mailjet.service.js +2 -2
- package/dist/core/common/services/mailjet.service.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +16 -16
- package/src/core/common/services/brevo.service.ts +43 -40
- package/src/core/common/services/mailjet.service.ts +2 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lenne.tech/nest-server",
|
|
3
|
-
"version": "10.2.
|
|
3
|
+
"version": "10.2.12",
|
|
4
4
|
"description": "Modern, fast, powerful Node.js web framework in TypeScript based on Nest with a GraphQL API and a connection to MongoDB (or other databases).",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"node",
|
|
@@ -62,18 +62,18 @@
|
|
|
62
62
|
"node": ">= 16.13.0"
|
|
63
63
|
},
|
|
64
64
|
"dependencies": {
|
|
65
|
-
"@apollo/gateway": "2.
|
|
65
|
+
"@apollo/gateway": "2.7.1",
|
|
66
66
|
"@getbrevo/brevo": "1.0.1",
|
|
67
67
|
"@lenne.tech/mongoose-gridfs": "1.4.2",
|
|
68
68
|
"@lenne.tech/multer-gridfs-storage": "5.0.6",
|
|
69
69
|
"@nestjs/apollo": "12.0.11",
|
|
70
|
-
"@nestjs/common": "10.3.
|
|
71
|
-
"@nestjs/core": "10.3.
|
|
70
|
+
"@nestjs/common": "10.3.1",
|
|
71
|
+
"@nestjs/core": "10.3.1",
|
|
72
72
|
"@nestjs/graphql": "12.0.11",
|
|
73
73
|
"@nestjs/jwt": "10.2.0",
|
|
74
74
|
"@nestjs/mongoose": "10.0.2",
|
|
75
75
|
"@nestjs/passport": "10.0.3",
|
|
76
|
-
"@nestjs/platform-express": "10.3.
|
|
76
|
+
"@nestjs/platform-express": "10.3.1",
|
|
77
77
|
"@nestjs/schedule": "4.0.0",
|
|
78
78
|
"@nestjs/terminus": "10.2.0",
|
|
79
79
|
"apollo-server-core": "3.13.0",
|
|
@@ -88,7 +88,7 @@
|
|
|
88
88
|
"graphql-query-complexity": "0.12.0",
|
|
89
89
|
"graphql-subscriptions": "2.0.0",
|
|
90
90
|
"graphql-upload": "15.0.2",
|
|
91
|
-
"js-sha256": "0.
|
|
91
|
+
"js-sha256": "0.11.0",
|
|
92
92
|
"json-to-graphql-query": "2.2.5",
|
|
93
93
|
"light-my-request": "5.11.0",
|
|
94
94
|
"lodash": "4.17.21",
|
|
@@ -101,7 +101,7 @@
|
|
|
101
101
|
"passport": "0.7.0",
|
|
102
102
|
"passport-jwt": "4.0.1",
|
|
103
103
|
"reflect-metadata": "0.1.14",
|
|
104
|
-
"rfdc": "1.3.
|
|
104
|
+
"rfdc": "1.3.1",
|
|
105
105
|
"rimraf": "5.0.5",
|
|
106
106
|
"rxjs": "7.8.1",
|
|
107
107
|
"yuml-diagram": "1.2.0"
|
|
@@ -112,10 +112,10 @@
|
|
|
112
112
|
"@lenne.tech/eslint-config-ts": "0.0.16",
|
|
113
113
|
"@nestjs/cli": "10.3.0",
|
|
114
114
|
"@nestjs/schematics": "10.1.0",
|
|
115
|
-
"@nestjs/testing": "10.3.
|
|
116
|
-
"@swc/cli": "0.1.
|
|
117
|
-
"@swc/core": "1.3.
|
|
118
|
-
"@swc/jest": "0.2.
|
|
115
|
+
"@nestjs/testing": "10.3.1",
|
|
116
|
+
"@swc/cli": "0.1.65",
|
|
117
|
+
"@swc/core": "1.3.106",
|
|
118
|
+
"@swc/jest": "0.2.31",
|
|
119
119
|
"@types/compression": "1.7.5",
|
|
120
120
|
"@types/cookie-parser": "1.4.6",
|
|
121
121
|
"@types/ejs": "3.1.5",
|
|
@@ -123,12 +123,12 @@
|
|
|
123
123
|
"@types/jest": "29.5.11",
|
|
124
124
|
"@types/lodash": "4.14.202",
|
|
125
125
|
"@types/multer": "1.4.11",
|
|
126
|
-
"@types/node": "20.11.
|
|
126
|
+
"@types/node": "20.11.6",
|
|
127
127
|
"@types/nodemailer": "6.4.14",
|
|
128
128
|
"@types/passport": "1.0.16",
|
|
129
129
|
"@types/supertest": "6.0.2",
|
|
130
|
-
"@typescript-eslint/eslint-plugin": "6.19.
|
|
131
|
-
"@typescript-eslint/parser": "6.19.
|
|
130
|
+
"@typescript-eslint/eslint-plugin": "6.19.1",
|
|
131
|
+
"@typescript-eslint/parser": "6.19.1",
|
|
132
132
|
"coffeescript": "2.7.0",
|
|
133
133
|
"eslint": "8.56.0",
|
|
134
134
|
"eslint-config-prettier": "9.1.0",
|
|
@@ -142,11 +142,11 @@
|
|
|
142
142
|
"husky": "8.0.3",
|
|
143
143
|
"jest": "29.7.0",
|
|
144
144
|
"npm-watch": "0.11.0",
|
|
145
|
-
"pm2": "5.3.
|
|
145
|
+
"pm2": "5.3.1",
|
|
146
146
|
"prettier": "3.2.4",
|
|
147
147
|
"pretty-quick": "4.0.0",
|
|
148
148
|
"supertest": "6.3.4",
|
|
149
|
-
"ts-jest": "29.1.
|
|
149
|
+
"ts-jest": "29.1.2",
|
|
150
150
|
"ts-loader": "9.5.1",
|
|
151
151
|
"ts-morph": "20.0.0",
|
|
152
152
|
"ts-node": "10.9.2",
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
|
|
2
1
|
import { Injectable } from '@nestjs/common';
|
|
3
2
|
|
|
4
3
|
import { ConfigService } from './config.service';
|
|
5
4
|
|
|
6
5
|
import brevo = require('@getbrevo/brevo');
|
|
7
6
|
|
|
8
|
-
|
|
7
|
+
/**
|
|
8
|
+
* Brevo service to send transactional emails
|
|
9
|
+
*/
|
|
9
10
|
@Injectable()
|
|
10
11
|
export class BrevoService {
|
|
11
12
|
brevoConfig: ConfigService['configFastButReadOnly']['brevo'];
|
|
@@ -24,25 +25,26 @@ export class BrevoService {
|
|
|
24
25
|
* Send a transactional email via Brevo
|
|
25
26
|
*/
|
|
26
27
|
async sendMail(to: string, templateId: number, params?: object): Promise<unknown> {
|
|
27
|
-
// Check input
|
|
28
|
-
if (!to || !templateId) {
|
|
29
|
-
return false;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
// Exclude (test) users
|
|
33
|
-
if (this.configService.configFastButReadOnly.brevo?.exclude?.test(to)) {
|
|
34
|
-
return 'TEST_USER!';
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
// Prepare data
|
|
38
|
-
const apiInstance = new brevo.TransactionalEmailsApi();
|
|
39
|
-
const sendSmtpEmail = new brevo.SendSmtpEmail();
|
|
40
|
-
sendSmtpEmail.templateId = templateId;
|
|
41
|
-
sendSmtpEmail.to = [{ email: to }];
|
|
42
|
-
sendSmtpEmail.params = params;
|
|
43
|
-
|
|
44
|
-
// Send email
|
|
45
28
|
try {
|
|
29
|
+
// Check input
|
|
30
|
+
if (!to || !templateId) {
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// Exclude (test) users, must be done via config and not via configFastButReadOnly,
|
|
35
|
+
// otherwise the error TypeError: Cannot assign to read only property 'lastIndex' of object '[object RegExp]' occurs
|
|
36
|
+
if (this.configService.config?.brevo?.exclude?.test?.(to)) {
|
|
37
|
+
return 'TEST_USER!';
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// Prepare data
|
|
41
|
+
const apiInstance = new brevo.TransactionalEmailsApi();
|
|
42
|
+
const sendSmtpEmail = new brevo.SendSmtpEmail();
|
|
43
|
+
sendSmtpEmail.templateId = templateId;
|
|
44
|
+
sendSmtpEmail.to = [{ email: to }];
|
|
45
|
+
sendSmtpEmail.params = params;
|
|
46
|
+
|
|
47
|
+
// Send email
|
|
46
48
|
return await apiInstance.sendTransacEmail(sendSmtpEmail);
|
|
47
49
|
} catch (error) {
|
|
48
50
|
console.error(error);
|
|
@@ -61,27 +63,28 @@ export class BrevoService {
|
|
|
61
63
|
html: string,
|
|
62
64
|
options?: { params?: Record<string, string> },
|
|
63
65
|
): Promise<unknown> {
|
|
64
|
-
// Check input
|
|
65
|
-
if (!to || !subject || !html) {
|
|
66
|
-
return false;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
// Exclude (test) users
|
|
70
|
-
if (this.brevoConfig.exclude?.test(to)) {
|
|
71
|
-
return 'TEST_USER!';
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
// Prepare data
|
|
75
|
-
const apiInstance = new brevo.TransactionalEmailsApi();
|
|
76
|
-
const sendSmtpEmail = new brevo.SendSmtpEmail();
|
|
77
|
-
sendSmtpEmail.htmlContent = html;
|
|
78
|
-
sendSmtpEmail.params = options?.params;
|
|
79
|
-
sendSmtpEmail.sender = this.brevoConfig.sender;
|
|
80
|
-
sendSmtpEmail.subject = subject;
|
|
81
|
-
sendSmtpEmail.to = [{ email: to }];
|
|
82
|
-
|
|
83
|
-
// Send email
|
|
84
66
|
try {
|
|
67
|
+
// Check input
|
|
68
|
+
if (!to || !subject || !html) {
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// Exclude (test) users, must be done via config and not via configFastButReadOnly,
|
|
73
|
+
// otherwise the error TypeError: Cannot assign to read only property 'lastIndex' of object '[object RegExp]' occurs
|
|
74
|
+
if (this.configService.config?.brevo?.exclude?.test?.(to)) {
|
|
75
|
+
return 'TEST_USER!';
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// Prepare data
|
|
79
|
+
const apiInstance = new brevo.TransactionalEmailsApi();
|
|
80
|
+
const sendSmtpEmail = new brevo.SendSmtpEmail();
|
|
81
|
+
sendSmtpEmail.htmlContent = html;
|
|
82
|
+
sendSmtpEmail.params = options?.params;
|
|
83
|
+
sendSmtpEmail.sender = this.brevoConfig.sender;
|
|
84
|
+
sendSmtpEmail.subject = subject;
|
|
85
|
+
sendSmtpEmail.to = [{ email: to }];
|
|
86
|
+
|
|
87
|
+
// Send email
|
|
85
88
|
return await apiInstance.sendTransacEmail(sendSmtpEmail);
|
|
86
89
|
} catch (error) {
|
|
87
90
|
console.error(error);
|