@lenne.tech/nest-server 9.0.7 → 9.0.8

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": "9.0.7",
3
+ "version": "9.0.8",
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",
@@ -58,15 +58,15 @@
58
58
  "node": ">= 16.13.0"
59
59
  },
60
60
  "dependencies": {
61
- "@apollo/gateway": "2.0.5",
62
- "@nestjs/apollo": "10.0.22",
63
- "@nestjs/common": "9.0.11",
64
- "@nestjs/core": "9.0.11",
65
- "@nestjs/graphql": "10.0.22",
61
+ "@apollo/gateway": "2.1.3",
62
+ "@nestjs/apollo": "10.1.3",
63
+ "@nestjs/common": "9.1.4",
64
+ "@nestjs/core": "9.1.4",
65
+ "@nestjs/graphql": "10.1.3",
66
66
  "@nestjs/jwt": "9.0.0",
67
67
  "@nestjs/mongoose": "9.2.0",
68
68
  "@nestjs/passport": "9.0.0",
69
- "@nestjs/platform-express": "9.0.11",
69
+ "@nestjs/platform-express": "9.1.4",
70
70
  "@nestjs/schedule": "2.1.0",
71
71
  "apollo-server-core": "3.10.2",
72
72
  "apollo-server-express": "3.10.2",
@@ -79,37 +79,37 @@
79
79
  "graphql-upload": "15.0.2",
80
80
  "js-sha256": "0.9.0",
81
81
  "json-to-graphql-query": "2.2.4",
82
- "light-my-request": "5.5.1",
82
+ "light-my-request": "5.6.1",
83
83
  "lodash": "4.17.21",
84
- "mongodb": "4.9.0",
85
- "mongoose": "6.5.3",
84
+ "mongodb": "4.10.0",
85
+ "mongoose": "6.6.5",
86
86
  "mongoose-gridfs": "1.3.0",
87
87
  "multer": "1.4.5-lts.1",
88
88
  "node-mailjet": "5.1.1",
89
- "nodemailer": "6.7.8",
90
- "nodemon": "2.0.19",
89
+ "nodemailer": "6.8.0",
90
+ "nodemon": "2.0.20",
91
91
  "passport": "0.6.0",
92
92
  "passport-jwt": "4.0.0",
93
93
  "reflect-metadata": "0.1.13",
94
94
  "rfdc": "1.3.0",
95
95
  "rimraf": "3.0.2",
96
- "rxjs": "7.5.6"
96
+ "rxjs": "7.5.7"
97
97
  },
98
98
  "devDependencies": {
99
- "@nestjs/testing": "9.0.11",
99
+ "@nestjs/testing": "9.1.4",
100
100
  "@types/cron": "2.0.0",
101
101
  "@types/ejs": "3.1.1",
102
- "@types/jest": "28.1.8",
103
- "@types/lodash": "4.14.184",
102
+ "@types/jest": "29.1.1",
103
+ "@types/lodash": "4.14.186",
104
104
  "@types/multer": "1.4.7",
105
- "@types/node": "18.7.13",
106
- "@types/nodemailer": "6.4.5",
107
- "@types/passport": "1.0.10",
105
+ "@types/node": "18.8.2",
106
+ "@types/nodemailer": "6.4.6",
107
+ "@types/passport": "1.0.11",
108
108
  "@types/supertest": "2.0.12",
109
- "@typescript-eslint/eslint-plugin": "5.35.1",
110
- "@typescript-eslint/parser": "5.35.1",
109
+ "@typescript-eslint/eslint-plugin": "5.39.0",
110
+ "@typescript-eslint/parser": "5.39.0",
111
111
  "coffeescript": "2.7.0",
112
- "eslint": "8.23.0",
112
+ "eslint": "8.24.0",
113
113
  "eslint-config-prettier": "8.5.0",
114
114
  "find-file-up": "2.0.1",
115
115
  "grunt": "1.5.3",
@@ -118,16 +118,16 @@
118
118
  "grunt-contrib-watch": "1.1.0",
119
119
  "grunt-sync": "0.8.2",
120
120
  "husky": "8.0.1",
121
- "jest": "28.1.3",
121
+ "jest": "29.1.2",
122
122
  "pm2": "5.2.0",
123
123
  "prettier": "2.7.1",
124
124
  "pretty-quick": "3.1.3",
125
- "supertest": "6.2.4",
126
- "ts-jest": "28.0.7",
127
- "ts-morph": "15.1.0",
125
+ "supertest": "6.3.0",
126
+ "ts-jest": "29.0.3",
127
+ "ts-morph": "16.0.0",
128
128
  "ts-node": "10.9.1",
129
129
  "tsconfig-paths": "4.1.0",
130
- "typescript": "4.8.2"
130
+ "typescript": "4.8.4"
131
131
  },
132
132
  "jest": {
133
133
  "collectCoverage": true,
package/src/config.env.ts CHANGED
@@ -23,8 +23,8 @@ const config: { [env: string]: IServerOptions } = {
23
23
  email: {
24
24
  smtp: {
25
25
  auth: {
26
- user: 'sandra98@ethereal.email',
27
- pass: 'JCQQdz8xJEfBSewahK',
26
+ user: 'cade72@ethereal.email',
27
+ pass: 'jpvTwGYeSajEqDvRKT',
28
28
  },
29
29
  host: 'smtp.ethereal.email',
30
30
  port: 587,
@@ -35,7 +35,7 @@ const config: { [env: string]: IServerOptions } = {
35
35
  api_key_private: 'MAILJET_API_KEY_PRIVATE',
36
36
  },
37
37
  defaultSender: {
38
- email: 'sandra98@ethereal.email',
38
+ email: 'cade72@ethereal.email',
39
39
  name: 'Sandra Klein',
40
40
  },
41
41
  verificationLink: 'http://localhost:4200/user/verification',
@@ -75,8 +75,8 @@ const config: { [env: string]: IServerOptions } = {
75
75
  email: {
76
76
  smtp: {
77
77
  auth: {
78
- user: 'sandra98@ethereal.email',
79
- pass: 'JCQQdz8xJEfBSewahK',
78
+ user: 'cade72@ethereal.email',
79
+ pass: 'jpvTwGYeSajEqDvRKT',
80
80
  },
81
81
  host: 'smtp.ethereal.email',
82
82
  port: 587,
@@ -87,7 +87,7 @@ const config: { [env: string]: IServerOptions } = {
87
87
  api_key_private: 'MAILJET_API_KEY_PRIVATE',
88
88
  },
89
89
  defaultSender: {
90
- email: 'sandra98@ethereal.email',
90
+ email: 'cade72@ethereal.email',
91
91
  name: 'Sandra Klein',
92
92
  },
93
93
  verificationLink: 'http://localhost:4200/user/verification',
@@ -127,8 +127,8 @@ const config: { [env: string]: IServerOptions } = {
127
127
  email: {
128
128
  smtp: {
129
129
  auth: {
130
- user: 'sandra98@ethereal.email',
131
- pass: 'JCQQdz8xJEfBSewahK',
130
+ user: 'cade72@ethereal.email',
131
+ pass: 'jpvTwGYeSajEqDvRKT',
132
132
  },
133
133
  host: 'smtp.ethereal.email',
134
134
  port: 587,
@@ -139,7 +139,7 @@ const config: { [env: string]: IServerOptions } = {
139
139
  api_key_private: 'MAILJET_API_KEY_PRIVATE',
140
140
  },
141
141
  defaultSender: {
142
- email: 'sandra98@ethereal.email',
142
+ email: 'cade72@ethereal.email',
143
143
  name: 'Sandra Klein',
144
144
  },
145
145
  verificationLink: 'http://localhost:4200/user/verification',
@@ -15,6 +15,16 @@ export class FilterArgs extends PaginationArgs {
15
15
  @IsOptional()
16
16
  filter?: FilterInput = undefined;
17
17
 
18
+ /**
19
+ * Get a specific number of random samples from filter results
20
+ */
21
+ @Field((type) => Number, {
22
+ description:
23
+ 'Request only a specified number of samples from the filter results; if not specified, all results are returned.',
24
+ nullable: true,
25
+ })
26
+ samples?: number = undefined;
27
+
18
28
  // ===================================================================================================================
19
29
  // Methods
20
30
  // ===================================================================================================================
@@ -39,11 +39,16 @@ export abstract class CrudService<T extends CoreModel = any> extends ModuleServi
39
39
  * Get items via filter
40
40
  */
41
41
  async find(
42
- filter?: FilterArgs | { filterQuery?: FilterQuery<any>; queryOptions?: QueryOptions },
42
+ filter?: FilterArgs | { filterQuery?: FilterQuery<any>; queryOptions?: QueryOptions; samples?: number },
43
43
  serviceOptions?: ServiceOptions
44
44
  ): Promise<T[]> {
45
45
  return this.process(
46
46
  async (data) => {
47
+ // Return only a certain number of random samples
48
+ if (filter?.samples) {
49
+ return (await this.findAndCount(filter, serviceOptions)).items;
50
+ }
51
+
47
52
  // Prepare filter query
48
53
  const filterQuery = { filterQuery: data?.input?.filterQuery, queryOptions: data?.input?.queryOptions };
49
54
  if (data?.input instanceof FilterArgs) {
@@ -63,7 +68,7 @@ export abstract class CrudService<T extends CoreModel = any> extends ModuleServi
63
68
  * Get items and total count via filter
64
69
  */
65
70
  async findAndCount(
66
- filter?: FilterArgs | { filterQuery?: FilterQuery<any>; queryOptions?: QueryOptions },
71
+ filter?: FilterArgs | { filterQuery?: FilterQuery<any>; queryOptions?: QueryOptions; samples?: number },
67
72
  serviceOptions?: ServiceOptions
68
73
  ): Promise<{ items: T[]; totalCount: number }> {
69
74
  return this.process(
@@ -77,12 +82,14 @@ export abstract class CrudService<T extends CoreModel = any> extends ModuleServi
77
82
  }
78
83
 
79
84
  // Prepare aggregation (with fixed defined sequence)
80
- const aggregation: PipelineStage[] = [
81
- {
82
- // Add pipeline stage 1: match
85
+ const aggregation: PipelineStage[] = [];
86
+
87
+ // Add pipeline stage 1: match
88
+ if (filterQuery.filterQuery) {
89
+ aggregation.push({
83
90
  $match: filterQuery.filterQuery,
84
- },
85
- ];
91
+ });
92
+ }
86
93
 
87
94
  // Prepare $facet
88
95
  const facet = {
@@ -109,6 +116,11 @@ export abstract class CrudService<T extends CoreModel = any> extends ModuleServi
109
116
  }
110
117
  }
111
118
 
119
+ // Get a certain number of random samples
120
+ if (filter?.samples) {
121
+ facet.items.push({ $sample: { size: filter.samples } });
122
+ }
123
+
112
124
  // Set pipeline stage 3: facet => items (with skip & limit) and totalCount
113
125
  aggregation.push({ $facet: facet });
114
126