aloux-iam 0.0.108 → 0.0.109
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/controllers/history.js +12 -2
- package/lib/middleware.js +1 -4
- package/lib/swagger.yaml +3 -0
- package/package.json +1 -1
|
@@ -37,11 +37,21 @@ self.response = async (_history, response, _createdBy, permission) => {
|
|
|
37
37
|
|
|
38
38
|
self.retrieve = async (req, res) => {
|
|
39
39
|
try {
|
|
40
|
-
let query = {};
|
|
40
|
+
let query = { $and: [] };
|
|
41
41
|
const response = { items: [], count: 0 };
|
|
42
42
|
|
|
43
43
|
if (req.body?.filter?.method) {
|
|
44
|
-
query
|
|
44
|
+
query.$and.push({ method: req.body.filter.method });
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if (req.body?.filter?.description) {
|
|
48
|
+
query.$and.push({
|
|
49
|
+
permission: { $regex: req.body.filter.description, $options: "i" },
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if (query.$and.length === 0) {
|
|
54
|
+
query = {};
|
|
45
55
|
}
|
|
46
56
|
|
|
47
57
|
response.count = await History.countDocuments(query);
|
package/lib/middleware.js
CHANGED
|
@@ -26,10 +26,7 @@ const auth = async (req, res, next) => {
|
|
|
26
26
|
if (process.env.HISTORY === "true") {
|
|
27
27
|
const endpoints = process.env.HISTORY_ENDPOINTS.split(",");
|
|
28
28
|
const urlToCheck = req.route.path;
|
|
29
|
-
|
|
30
|
-
new RegExp(`^${endpoint}(/|\\?|$)`).test(urlToCheck)
|
|
31
|
-
);
|
|
32
|
-
if (exists) {
|
|
29
|
+
if (endpoints.includes(urlToCheck)) {
|
|
33
30
|
newHistory = await historyController.create(req);
|
|
34
31
|
req.history = newHistory._id.toString();
|
|
35
32
|
}
|
package/lib/swagger.yaml
CHANGED