@ewb/mongoose-query-express 1.0.1 → 1.0.2
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/lib/QueryExpress.d.ts +0 -1
- package/lib/QueryExpress.js +0 -15
- package/package.json +2 -2
package/lib/QueryExpress.d.ts
CHANGED
|
@@ -50,7 +50,6 @@ export declare class QueryExpress<R extends Request, T extends mongoose.Document
|
|
|
50
50
|
query(req: R): Query<T, object, import("@ewb/mongoose-query").IMongooseQueryOptions>;
|
|
51
51
|
pageLinkHeader(req: R, data: ISearchPaginate<any>): string;
|
|
52
52
|
private getDoc;
|
|
53
|
-
private validateBody;
|
|
54
53
|
private getFindOpts;
|
|
55
54
|
private validateReq;
|
|
56
55
|
private validateIdsInBody;
|
package/lib/QueryExpress.js
CHANGED
|
@@ -30,7 +30,6 @@ export class QueryExpress {
|
|
|
30
30
|
if (req.ewb.queryOptions.skipHandlerAction === 'post') {
|
|
31
31
|
return next();
|
|
32
32
|
}
|
|
33
|
-
this.validateBody(req);
|
|
34
33
|
this.init(req);
|
|
35
34
|
if (req.ewb.queryPostBody) {
|
|
36
35
|
for (const key in req.ewb.queryPostBody) {
|
|
@@ -122,7 +121,6 @@ export class QueryExpress {
|
|
|
122
121
|
return next();
|
|
123
122
|
}
|
|
124
123
|
this.validateReq(req);
|
|
125
|
-
this.validateBody(req);
|
|
126
124
|
this.init(req);
|
|
127
125
|
const query = this.query(req);
|
|
128
126
|
req[this.param] = (await this.handler.findOneAndUpdate(query, { _id: this.getDoc(req)._id }, { $set: req.body }));
|
|
@@ -185,7 +183,6 @@ export class QueryExpress {
|
|
|
185
183
|
try {
|
|
186
184
|
const ids = this.validateIdsInBody(req);
|
|
187
185
|
delete req.body.ids;
|
|
188
|
-
this.handler.validateBody(req.body);
|
|
189
186
|
await this.handler.updateMany(this.query(req).root || {}, ids, req.body);
|
|
190
187
|
this.query(req).addRoot({ _id: { $in: ids } });
|
|
191
188
|
this.query(req).setSkipAndLimit(0, ids.length);
|
|
@@ -359,18 +356,6 @@ export class QueryExpress {
|
|
|
359
356
|
getDoc(req, param = this.param) {
|
|
360
357
|
return req[param];
|
|
361
358
|
}
|
|
362
|
-
validateBody(req) {
|
|
363
|
-
const invalidFields = this.handler.validateBody(req.body);
|
|
364
|
-
if (invalidFields) {
|
|
365
|
-
throw new QueryError(httpStatus.BAD_REQUEST, 'Invalid body', {
|
|
366
|
-
detail: 'Body contained invalid keys, remove keys located in source.body to post or patch',
|
|
367
|
-
errors: invalidFields.map((x) => ({
|
|
368
|
-
message: 'Invalid field',
|
|
369
|
-
detail: x,
|
|
370
|
-
})),
|
|
371
|
-
});
|
|
372
|
-
}
|
|
373
|
-
}
|
|
374
359
|
getFindOpts(_req) {
|
|
375
360
|
return {
|
|
376
361
|
select: false,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ewb/mongoose-query-express",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Routes and controllers for express to handle mongoose queries",
|
|
6
6
|
"main": "./lib/index.js",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"preversion": "yarn build"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@ewb/mongoose-query": "^1.1.
|
|
20
|
+
"@ewb/mongoose-query": "^1.1.2",
|
|
21
21
|
"http-status": "^1.6.2"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|