@ewb/mongoose-query-express 1.0.2 → 1.0.3
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 +1 -0
- package/lib/QueryExpress.js +16 -8
- package/package.json +2 -2
package/lib/QueryExpress.d.ts
CHANGED
package/lib/QueryExpress.js
CHANGED
|
@@ -27,7 +27,7 @@ export class QueryExpress {
|
|
|
27
27
|
}
|
|
28
28
|
async post(req, res, next) {
|
|
29
29
|
try {
|
|
30
|
-
if (
|
|
30
|
+
if (this.skipHandlerAction(req, 'post')) {
|
|
31
31
|
return next();
|
|
32
32
|
}
|
|
33
33
|
this.init(req);
|
|
@@ -47,7 +47,8 @@ export class QueryExpress {
|
|
|
47
47
|
}
|
|
48
48
|
async findOne(req, _res, next) {
|
|
49
49
|
try {
|
|
50
|
-
if (
|
|
50
|
+
if (this.skipHandlerAction(req, 'findOne')) {
|
|
51
|
+
req.ewb.queryOptions.skipHandlerAction = undefined;
|
|
51
52
|
return next();
|
|
52
53
|
}
|
|
53
54
|
this.init(req);
|
|
@@ -65,7 +66,7 @@ export class QueryExpress {
|
|
|
65
66
|
}
|
|
66
67
|
async search(req, res, next) {
|
|
67
68
|
try {
|
|
68
|
-
if (
|
|
69
|
+
if (this.skipHandlerAction(req, 'search')) {
|
|
69
70
|
return next();
|
|
70
71
|
}
|
|
71
72
|
const data = await this._search(req, res);
|
|
@@ -80,7 +81,7 @@ export class QueryExpress {
|
|
|
80
81
|
}
|
|
81
82
|
async searchNext(req, res, next) {
|
|
82
83
|
try {
|
|
83
|
-
if (
|
|
84
|
+
if (this.skipHandlerAction(req, 'search')) {
|
|
84
85
|
return next();
|
|
85
86
|
}
|
|
86
87
|
req.ewb.querySearchJson = await this._search(req, res);
|
|
@@ -100,7 +101,7 @@ export class QueryExpress {
|
|
|
100
101
|
}
|
|
101
102
|
async export(req, res, next) {
|
|
102
103
|
try {
|
|
103
|
-
if (
|
|
104
|
+
if (this.skipHandlerAction(req, 'export')) {
|
|
104
105
|
return next();
|
|
105
106
|
}
|
|
106
107
|
this.init(req);
|
|
@@ -117,7 +118,7 @@ export class QueryExpress {
|
|
|
117
118
|
}
|
|
118
119
|
async patch(req, _res, next) {
|
|
119
120
|
try {
|
|
120
|
-
if (
|
|
121
|
+
if (this.skipHandlerAction(req, 'patch')) {
|
|
121
122
|
return next();
|
|
122
123
|
}
|
|
123
124
|
this.validateReq(req);
|
|
@@ -134,7 +135,7 @@ export class QueryExpress {
|
|
|
134
135
|
}
|
|
135
136
|
async archive(req, _res, next) {
|
|
136
137
|
try {
|
|
137
|
-
if (
|
|
138
|
+
if (this.skipHandlerAction(req, 'archive')) {
|
|
138
139
|
return next();
|
|
139
140
|
}
|
|
140
141
|
this.validateReq(req);
|
|
@@ -149,7 +150,7 @@ export class QueryExpress {
|
|
|
149
150
|
}
|
|
150
151
|
async delete(req, _res, next) {
|
|
151
152
|
try {
|
|
152
|
-
if (
|
|
153
|
+
if (this.skipHandlerAction(req, 'delete')) {
|
|
153
154
|
return next();
|
|
154
155
|
}
|
|
155
156
|
this.validateReq(req);
|
|
@@ -377,4 +378,11 @@ export class QueryExpress {
|
|
|
377
378
|
}
|
|
378
379
|
return req.body.ids.map((x) => new mongoose.Types.ObjectId(x));
|
|
379
380
|
}
|
|
381
|
+
skipHandlerAction(req, action) {
|
|
382
|
+
if (req.ewb.queryOptions.skipHandlerAction === action) {
|
|
383
|
+
req.ewb.queryOptions.skipHandlerAction = undefined;
|
|
384
|
+
return true;
|
|
385
|
+
}
|
|
386
|
+
return false;
|
|
387
|
+
}
|
|
380
388
|
}
|
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.3",
|
|
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": "
|
|
20
|
+
"@ewb/mongoose-query": "*",
|
|
21
21
|
"http-status": "^1.6.2"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|