@lenne.tech/nest-server 9.0.11 → 9.0.13
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/config.env.js +9 -0
- package/dist/config.env.js.map +1 -1
- package/dist/core/common/helpers/filter.helper.js +5 -7
- package/dist/core/common/helpers/filter.helper.js.map +1 -1
- package/dist/core/common/helpers/input.helper.js +1 -1
- package/dist/core/common/helpers/input.helper.js.map +1 -1
- package/dist/core/common/interfaces/server-options.interface.d.ts +3 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +4 -4
- package/src/config.env.ts +9 -0
- package/src/core/common/helpers/filter.helper.ts +5 -7
- package/src/core/common/helpers/input.helper.ts +1 -1
- package/src/core/common/interfaces/server-options.interface.ts +10 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lenne.tech/nest-server",
|
|
3
|
-
"version": "9.0.
|
|
3
|
+
"version": "9.0.13",
|
|
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",
|
|
@@ -102,7 +102,7 @@
|
|
|
102
102
|
"@types/jest": "29.1.2",
|
|
103
103
|
"@types/lodash": "4.14.186",
|
|
104
104
|
"@types/multer": "1.4.7",
|
|
105
|
-
"@types/node": "18.8.
|
|
105
|
+
"@types/node": "18.8.5",
|
|
106
106
|
"@types/nodemailer": "6.4.6",
|
|
107
107
|
"@types/passport": "1.0.11",
|
|
108
108
|
"@types/supertest": "2.0.12",
|
|
@@ -118,8 +118,8 @@
|
|
|
118
118
|
"grunt-contrib-watch": "1.1.0",
|
|
119
119
|
"grunt-sync": "0.8.2",
|
|
120
120
|
"husky": "8.0.1",
|
|
121
|
-
"jest": "29.
|
|
122
|
-
"pm2": "5.2.
|
|
121
|
+
"jest": "29.2.0",
|
|
122
|
+
"pm2": "5.2.2",
|
|
123
123
|
"prettier": "2.7.1",
|
|
124
124
|
"pretty-quick": "3.1.3",
|
|
125
125
|
"supertest": "6.3.0",
|
package/src/config.env.ts
CHANGED
|
@@ -44,6 +44,9 @@ const config: { [env: string]: IServerOptions } = {
|
|
|
44
44
|
},
|
|
45
45
|
env: 'local',
|
|
46
46
|
execAfterInit: 'npm run docs:bootstrap',
|
|
47
|
+
filter: {
|
|
48
|
+
maxLimit: null,
|
|
49
|
+
},
|
|
47
50
|
graphQl: {
|
|
48
51
|
driver: {
|
|
49
52
|
debug: true,
|
|
@@ -97,6 +100,9 @@ const config: { [env: string]: IServerOptions } = {
|
|
|
97
100
|
},
|
|
98
101
|
env: 'development',
|
|
99
102
|
execAfterInit: 'npm run docs:bootstrap',
|
|
103
|
+
filter: {
|
|
104
|
+
maxLimit: null,
|
|
105
|
+
},
|
|
100
106
|
graphQl: {
|
|
101
107
|
driver: {
|
|
102
108
|
debug: true,
|
|
@@ -150,6 +156,9 @@ const config: { [env: string]: IServerOptions } = {
|
|
|
150
156
|
},
|
|
151
157
|
env: 'productive',
|
|
152
158
|
execAfterInit: 'npm run docs:bootstrap',
|
|
159
|
+
filter: {
|
|
160
|
+
maxLimit: null,
|
|
161
|
+
},
|
|
153
162
|
graphQl: {
|
|
154
163
|
driver: {
|
|
155
164
|
debug: false,
|
|
@@ -163,11 +163,9 @@ export function generateFilterQuery<T = any>(
|
|
|
163
163
|
// Set both the string filter and the ObjectID filtering in an OR construction
|
|
164
164
|
const alternativeQuery = clone(filter.singleFilter, { circles: false });
|
|
165
165
|
alternativeQuery.value = getObjectIds(value);
|
|
166
|
+
const conf = Object.assign({}, config, { automaticObjectIdFiltering: false });
|
|
166
167
|
return {
|
|
167
|
-
$or: [
|
|
168
|
-
generateFilterQuery(filter.singleFilter, Object.assign({}, config, { automaticObjectIdFiltering: false })),
|
|
169
|
-
generateFilterQuery(alternativeQuery, Object.assign({}, config, { automaticObjectIdFiltering: false })),
|
|
170
|
-
],
|
|
168
|
+
$or: [generateFilterQuery(filter, conf), generateFilterQuery({ singleFilter: alternativeQuery }, conf)],
|
|
171
169
|
};
|
|
172
170
|
}
|
|
173
171
|
|
|
@@ -228,7 +226,7 @@ export function generateFindOptions<T = any>(
|
|
|
228
226
|
|
|
229
227
|
// Config
|
|
230
228
|
const config = {
|
|
231
|
-
maxLimit:
|
|
229
|
+
maxLimit: ConfigService.get('filter.maxLimit'),
|
|
232
230
|
...options,
|
|
233
231
|
};
|
|
234
232
|
|
|
@@ -245,8 +243,8 @@ export function generateFindOptions<T = any>(
|
|
|
245
243
|
}
|
|
246
244
|
|
|
247
245
|
// Check limit
|
|
248
|
-
if (!queryOptions.limit || queryOptions.limit > config.maxLimit) {
|
|
249
|
-
queryOptions.limit =
|
|
246
|
+
if (config.maxLimit && (!queryOptions.limit || queryOptions.limit > config.maxLimit)) {
|
|
247
|
+
queryOptions.limit = config.maxLimit;
|
|
250
248
|
}
|
|
251
249
|
|
|
252
250
|
// Prepare order
|
|
@@ -347,7 +347,7 @@ export function combinePlain(...args: Record<any, any>[]): any {
|
|
|
347
347
|
* Get deep frozen object
|
|
348
348
|
*/
|
|
349
349
|
export function deepFreeze(object: any) {
|
|
350
|
-
if (typeof object !== 'object') {
|
|
350
|
+
if (!object || typeof object !== 'object') {
|
|
351
351
|
return object;
|
|
352
352
|
}
|
|
353
353
|
for (const [key, value] of Object.entries(object)) {
|
|
@@ -78,6 +78,16 @@ export interface IServerOptions {
|
|
|
78
78
|
*/
|
|
79
79
|
execAfterInit?: string;
|
|
80
80
|
|
|
81
|
+
/**
|
|
82
|
+
* Filter configuration and defaults
|
|
83
|
+
*/
|
|
84
|
+
filter?: {
|
|
85
|
+
/**
|
|
86
|
+
* Maximum limit for the number of results
|
|
87
|
+
*/
|
|
88
|
+
maxLimit?: number;
|
|
89
|
+
};
|
|
90
|
+
|
|
81
91
|
/**
|
|
82
92
|
* Configuration of the GraphQL module
|
|
83
93
|
* see https://docs.nestjs.com/graphql/quick-start
|