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.
@@ -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 = { method: req.body.filter.method };
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
- const exists = endpoints.some((endpoint) =>
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
@@ -1197,6 +1197,9 @@ paths:
1197
1197
  properties:
1198
1198
  method:
1199
1199
  enum: [ GET, POST, PUT, PATCH, DELETE]
1200
+ description:
1201
+ type: string
1202
+ example: crear
1200
1203
  config:
1201
1204
  type: object
1202
1205
  properties:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aloux-iam",
3
- "version": "0.0.108",
3
+ "version": "0.0.109",
4
4
  "description": "Aloux IAM for APIs ",
5
5
  "main": "index.js",
6
6
  "scripts": {