@lenne.tech/nest-server 8.6.20 → 8.6.23

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lenne.tech/nest-server",
3
- "version": "8.6.20",
3
+ "version": "8.6.23",
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",
@@ -76,17 +76,17 @@
76
76
  "ejs": "3.1.8",
77
77
  "graphql": "16.5.0",
78
78
  "graphql-subscriptions": "2.0.0",
79
- "graphql-upload": "15.0.1",
79
+ "graphql-upload": "15.0.2",
80
80
  "json-to-graphql-query": "2.2.4",
81
81
  "light-my-request": "5.0.0",
82
82
  "lodash": "4.17.21",
83
83
  "mongodb": "4.7.0",
84
- "mongoose": "6.3.9",
84
+ "mongoose": "6.4.1",
85
85
  "mongoose-gridfs": "1.3.0",
86
- "multer": "1.4.4",
87
- "node-mailjet": "3.4.1",
88
- "nodemailer": "6.7.5",
89
- "nodemon": "2.0.16",
86
+ "multer": "1.4.5-lts.1",
87
+ "node-mailjet": "5.0.1",
88
+ "nodemailer": "6.7.6",
89
+ "nodemon": "2.0.18",
90
90
  "passport": "0.6.0",
91
91
  "passport-jwt": "4.0.0",
92
92
  "reflect-metadata": "0.1.13",
@@ -97,16 +97,15 @@
97
97
  "@nestjs/testing": "8.4.7",
98
98
  "@types/cron": "2.0.0",
99
99
  "@types/ejs": "3.1.1",
100
- "@types/jest": "28.1.3",
100
+ "@types/jest": "28.1.4",
101
101
  "@types/lodash": "4.14.182",
102
102
  "@types/multer": "1.4.7",
103
103
  "@types/node": "18.0.0",
104
- "@types/node-mailjet": "3.3.9",
105
104
  "@types/nodemailer": "6.4.4",
106
105
  "@types/passport": "1.0.9",
107
106
  "@types/supertest": "2.0.12",
108
- "@typescript-eslint/eslint-plugin": "5.29.0",
109
- "@typescript-eslint/parser": "5.29.0",
107
+ "@typescript-eslint/eslint-plugin": "5.30.0",
108
+ "@typescript-eslint/parser": "5.30.0",
110
109
  "coffeescript": "2.7.0",
111
110
  "eslint": "8.18.0",
112
111
  "eslint-config-prettier": "8.5.0",
@@ -117,7 +116,7 @@
117
116
  "grunt-contrib-watch": "1.1.0",
118
117
  "grunt-sync": "0.8.2",
119
118
  "husky": "8.0.1",
120
- "jest": "28.1.1",
119
+ "jest": "28.1.2",
121
120
  "pm2": "5.2.0",
122
121
  "prettier": "2.7.1",
123
122
  "pretty-quick": "3.1.3",
@@ -597,7 +597,7 @@ function getStringId(element: any): string {
597
597
  return element;
598
598
  }
599
599
 
600
- // Sring handling
600
+ // String handling
601
601
  if (typeof element === 'string') {
602
602
  return element;
603
603
  }
@@ -186,13 +186,12 @@ export function mapClasses<T = Record<string, any>>(
186
186
  for (const item of value) {
187
187
  if (value instanceof targetClass) {
188
188
  arr.push(value);
189
- }
190
- if (value instanceof Types.ObjectId) {
189
+ } else if (value instanceof Types.ObjectId) {
191
190
  arr.push(value);
192
191
  } else if (typeof value === 'object') {
193
192
  if (targetClass.map) {
194
193
  arr.push(targetClass.map(item));
195
- } else if (typeof value === 'object') {
194
+ } else {
196
195
  arr.push(plainToInstance(targetClass, item));
197
196
  }
198
197
  } else {
@@ -211,11 +210,12 @@ export function mapClasses<T = Record<string, any>>(
211
210
  else if (typeof value === 'object') {
212
211
  if (value instanceof targetClass) {
213
212
  target[prop] = value as any;
214
- }
215
- if (targetClass.map) {
216
- target[prop] = targetClass.map(value);
217
213
  } else {
218
- target[prop] = plainToInstance(targetClass, value) as any;
214
+ if (targetClass.map) {
215
+ target[prop] = targetClass.map(value);
216
+ } else {
217
+ target[prop] = plainToInstance(targetClass, value) as any;
218
+ }
219
219
  }
220
220
  }
221
221
 
@@ -262,13 +262,12 @@ export async function mapClassesAsync<T = Record<string, any>>(
262
262
  for (const item of value) {
263
263
  if (value instanceof targetClass) {
264
264
  arr.push(value);
265
- }
266
- if (value instanceof Types.ObjectId) {
265
+ } else if (value instanceof Types.ObjectId) {
267
266
  arr.push(value);
268
267
  } else if (typeof value === 'object') {
269
268
  if (targetClass.map) {
270
269
  arr.push(await targetClass.map(item));
271
- } else if (typeof value === 'object') {
270
+ } else {
272
271
  arr.push(plainToInstance(targetClass, item));
273
272
  }
274
273
  } else {
@@ -287,11 +286,12 @@ export async function mapClassesAsync<T = Record<string, any>>(
287
286
  else if (typeof value === 'object') {
288
287
  if (value instanceof targetClass) {
289
288
  target[prop] = value as any;
290
- }
291
- if (targetClass.map) {
292
- target[prop] = await targetClass.map(value);
293
289
  } else {
294
- target[prop] = plainToInstance(targetClass, value) as any;
290
+ if (targetClass.map) {
291
+ target[prop] = await targetClass.map(value);
292
+ } else {
293
+ target[prop] = plainToInstance(targetClass, value) as any;
294
+ }
295
295
  }
296
296
  }
297
297
 
@@ -1,6 +1,6 @@
1
1
  import { Injectable } from '@nestjs/common';
2
2
  import { ConfigService } from './config.service';
3
- import mailjet from 'node-mailjet';
3
+ import Mailjet from 'node-mailjet';
4
4
 
5
5
  /**
6
6
  * Mailjet service
@@ -22,11 +22,16 @@ export class MailjetService {
22
22
  config: {
23
23
  senderEmail?: string;
24
24
  senderName?: string;
25
- attachments?: mailjet.Email.Attachment[];
25
+ attachments?: {
26
+ ContentID?: string;
27
+ ContentType: string;
28
+ Filename: string;
29
+ Base64Content: string;
30
+ }[];
26
31
  templateData?: { [key: string]: any };
27
32
  sandbox?: boolean;
28
33
  }
29
- ): Promise<mailjet.Email.PostResponse> {
34
+ ) {
30
35
  // Process config
31
36
  const { senderName, senderEmail, templateData, attachments, sandbox } = {
32
37
  senderEmail: this.configService.get('email.defaultSender.email'),
@@ -49,7 +54,7 @@ export class MailjetService {
49
54
  }
50
55
 
51
56
  // Parse body for mailjet request
52
- const body: mailjet.Email.SendParams = {
57
+ const body = {
53
58
  Messages: [
54
59
  {
55
60
  From: {
@@ -67,13 +72,13 @@ export class MailjetService {
67
72
  SandboxMode: sandbox,
68
73
  };
69
74
 
70
- let connection: mailjet.Email.Client;
75
+ let connection;
71
76
  try {
72
77
  // Connect to mailjet
73
- connection = await mailjet.connect(
74
- this.configService.get('email.mailjet.api_key_public'),
75
- this.configService.get('email.mailjet.api_key_private')
76
- );
78
+ connection = new Mailjet({
79
+ apiKey: this.configService.get('email.mailjet.api_key_public'),
80
+ apiSecret: this.configService.get('email.mailjet.api_key_private'),
81
+ });
77
82
  } catch (e) {
78
83
  throw new Error('Cannot connect to mailjet.');
79
84
  }
@@ -107,6 +107,11 @@ export abstract class ModuleService<T extends CoreModel = any> {
107
107
  config.input = await this.prepareInput(config.input, opts);
108
108
  }
109
109
 
110
+ // Check rights
111
+ if (config.checkRights && this.checkRights) {
112
+ await this.checkRights(undefined, config.currentUser as any, config);
113
+ }
114
+
110
115
  // Get DB object
111
116
  if (config.dbObject && config.checkRights && this.checkRights) {
112
117
  if (typeof config.dbObject === 'string' || config.dbObject instanceof Types.ObjectId) {
@@ -144,7 +149,7 @@ export abstract class ModuleService<T extends CoreModel = any> {
144
149
  }
145
150
 
146
151
  // Check output rights
147
- if (config.checkRights && this.checkRights) {
152
+ if (config.checkRights && (await this.checkRights(undefined, config.currentUser as any, config))) {
148
153
  const opts: any = {
149
154
  dbObject: config.dbObject,
150
155
  processType: ProcessType.OUTPUT,