aloux-iam 0.0.103 → 0.0.105
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 +38 -0
- package/lib/models/History.js +1 -1
- package/lib/router.js +66 -60
- package/lib/swagger.yaml +49 -1
- package/package.json +1 -1
|
@@ -31,3 +31,41 @@ self.response = async (_history, response, _createdBy) => {
|
|
|
31
31
|
return error;
|
|
32
32
|
}
|
|
33
33
|
};
|
|
34
|
+
|
|
35
|
+
self.retrieve = async (req, res) => {
|
|
36
|
+
try {
|
|
37
|
+
const query = {};
|
|
38
|
+
const response = { items: [], count: 0 };
|
|
39
|
+
|
|
40
|
+
if (req.body?.filter?.method) {
|
|
41
|
+
query = { method: req.body.filter.method };
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
response.count = await History.countDocuments(query);
|
|
45
|
+
response.items = await History.find(query)
|
|
46
|
+
.populate({ path: "_createdBy", select: { name: 1, lastName: 1 } })
|
|
47
|
+
.sort({ createdAt: -1 })
|
|
48
|
+
.skip((req.body.config.page - 1) * req.body.config.itemsPerPage)
|
|
49
|
+
.limit(req.body.config.itemsPerPage)
|
|
50
|
+
.lean();
|
|
51
|
+
|
|
52
|
+
res.status(200).send(response);
|
|
53
|
+
} catch (error) {
|
|
54
|
+
res.status(400).send(error);
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
self.detail = async (req, res) => {
|
|
59
|
+
try {
|
|
60
|
+
const history = await History.findOne({ _id: req.params.HISTORY_ID });
|
|
61
|
+
if (!history) {
|
|
62
|
+
return res.status(404).send({
|
|
63
|
+
error: "No se encontró el elemento",
|
|
64
|
+
suggestion: "Verifica que el id del registro sea correcto",
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
res.status(200).send(history);
|
|
68
|
+
} catch (error) {
|
|
69
|
+
res.status(400).send(error);
|
|
70
|
+
}
|
|
71
|
+
};
|
package/lib/models/History.js
CHANGED
|
@@ -6,7 +6,7 @@ const historySchema = mongoose.Schema({
|
|
|
6
6
|
path: { type: String, default: true },
|
|
7
7
|
payload: { type: Object, default: {} }, // Guarda cualquier estructura JSON
|
|
8
8
|
response: { type: Object, default: {} }, // Guarda cualquier estructura JSON
|
|
9
|
-
_createdBy: { type: ObjectId, required: false },
|
|
9
|
+
_createdBy: { type: ObjectId, required: false, ref: "User" },
|
|
10
10
|
createdAt: { type: Number, required: true },
|
|
11
11
|
});
|
|
12
12
|
|
package/lib/router.js
CHANGED
|
@@ -1,76 +1,82 @@
|
|
|
1
|
-
const express = require(
|
|
2
|
-
const middleware = require(
|
|
3
|
-
const router = express.Router()
|
|
1
|
+
const express = require("express");
|
|
2
|
+
const middleware = require("./middleware.js");
|
|
3
|
+
const router = express.Router();
|
|
4
4
|
|
|
5
|
-
const auth
|
|
6
|
-
const user
|
|
7
|
-
const menu
|
|
8
|
-
const permission
|
|
9
|
-
const functions
|
|
5
|
+
const auth = require("./controllers/auth");
|
|
6
|
+
const user = require("./controllers/user");
|
|
7
|
+
const menu = require("./controllers/menu");
|
|
8
|
+
const permission = require("./controllers/permission");
|
|
9
|
+
const functions = require("./controllers/functions");
|
|
10
|
+
const history = require("./controllers/history.js");
|
|
10
11
|
|
|
11
12
|
// User / user self (no auth)
|
|
12
|
-
router.post(
|
|
13
|
-
router.post(
|
|
14
|
-
router.post(
|
|
15
|
-
router.post(
|
|
16
|
-
router.post(
|
|
17
|
-
router.get(
|
|
18
|
-
router.post(
|
|
19
|
-
router.post(
|
|
13
|
+
router.post("/iam/auth/email", auth.email);
|
|
14
|
+
router.post("/iam/auth/login", auth.login);
|
|
15
|
+
router.post("/iam/auth/forgot/password", auth.recoverpassword);
|
|
16
|
+
router.post("/iam/auth/validate/code", auth.verifyCode);
|
|
17
|
+
router.post("/iam/auth/verify/mail", auth.sendVerifyMailAccount);
|
|
18
|
+
router.get("/iam/auth/verify/mail/token/:token", auth.verifyMailTokenAccount);
|
|
19
|
+
router.post("/iam/auth/reset/password", auth.resetPassword);
|
|
20
|
+
router.post("/iam/auth/signup", auth.createCustomer);
|
|
20
21
|
|
|
21
22
|
// User / user self
|
|
22
|
-
router.get(
|
|
23
|
-
router.patch(
|
|
24
|
-
router.put(
|
|
25
|
-
router.put(
|
|
26
|
-
router.post(
|
|
27
|
-
router.post(
|
|
28
|
-
router.post(
|
|
29
|
-
router.patch(
|
|
30
|
-
router.post(
|
|
23
|
+
router.get("/iam/auth/me", middleware, auth.me);
|
|
24
|
+
router.patch("/iam/auth/profile", middleware, auth.updateAny);
|
|
25
|
+
router.put("/iam/auth/profile/pictura", middleware, auth.updatePicture);
|
|
26
|
+
router.put("/iam/auth/reset/password", middleware, auth.resetPass);
|
|
27
|
+
router.post("/iam/auth/send/verify/phone", middleware, auth.verifyPhone);
|
|
28
|
+
router.post("/iam/auth/verify/phone", middleware, auth.validatePhone);
|
|
29
|
+
router.post("/iam/auth/logout", middleware, auth.logout);
|
|
30
|
+
router.patch("/iam/auth/mail", middleware, auth.mailChange);
|
|
31
|
+
router.post("/iam/auth/validate/mail", middleware, auth.validatEmailChange);
|
|
31
32
|
|
|
32
33
|
// IAM / User
|
|
33
|
-
router.post(
|
|
34
|
-
router.get(
|
|
35
|
-
router.get(
|
|
36
|
-
router.patch(
|
|
37
|
-
router.put(
|
|
38
|
-
router.put(
|
|
39
|
-
router.delete(
|
|
40
|
-
router.get(
|
|
41
|
-
|
|
34
|
+
router.post("/iam/user", middleware, user.create);
|
|
35
|
+
router.get("/iam/user", middleware, user.retrieve);
|
|
36
|
+
router.get("/iam/user/:USER_ID", middleware, user.get);
|
|
37
|
+
router.patch("/iam/user/:USER_ID", middleware, user.update);
|
|
38
|
+
router.put("/iam/user/:USER_ID/status", middleware, user.status);
|
|
39
|
+
router.put("/iam/user/password/:USER_ID", middleware, user.updatepassword);
|
|
40
|
+
router.delete("/iam/user/:USER_ID", middleware, user.delete);
|
|
41
|
+
router.get("/iam/user/count/all", middleware, user.count);
|
|
42
42
|
|
|
43
43
|
// IAM / Function
|
|
44
|
-
router.post(
|
|
45
|
-
router.patch(
|
|
46
|
-
router.put(
|
|
47
|
-
router.get(
|
|
48
|
-
router.get(
|
|
49
|
-
router.delete(
|
|
50
|
-
router.get(
|
|
51
|
-
|
|
44
|
+
router.post("/iam/functions", middleware, functions.create);
|
|
45
|
+
router.patch("/iam/functions/:FUNCTION_ID", middleware, functions.update);
|
|
46
|
+
router.put("/iam/functions/:FUNCTION_ID/status", middleware, functions.status);
|
|
47
|
+
router.get("/iam/functions", middleware, functions.retrieve);
|
|
48
|
+
router.get("/iam/functions/:FUNCTION_ID", middleware, functions.get);
|
|
49
|
+
router.delete("/iam/functions/:FUNCTION_ID", middleware, functions.delete);
|
|
50
|
+
router.get("/iam/functions/count/all", middleware, functions.count);
|
|
52
51
|
|
|
53
52
|
// IAM / Permission
|
|
54
|
-
router.post(
|
|
55
|
-
router.patch(
|
|
56
|
-
router.put(
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
53
|
+
router.post("/iam/permission", middleware, permission.create);
|
|
54
|
+
router.patch("/iam/permission/:PERMISSION_ID", middleware, permission.update);
|
|
55
|
+
router.put(
|
|
56
|
+
"/iam/permission/:PERMISSION_ID/status",
|
|
57
|
+
middleware,
|
|
58
|
+
permission.status
|
|
59
|
+
);
|
|
60
|
+
router.get("/iam/permission", middleware, permission.retrieve);
|
|
61
|
+
router.get("/iam/permission/:PERMISSION_ID", middleware, permission.get);
|
|
62
|
+
router.delete("/iam/permission/:PERMISSION_ID", middleware, permission.delete);
|
|
63
|
+
router.get("/iam/permission/count/all", middleware, permission.count);
|
|
62
64
|
|
|
63
65
|
// IAM / Menu
|
|
64
|
-
router.post(
|
|
65
|
-
router.patch(
|
|
66
|
-
router.put(
|
|
67
|
-
router.get(
|
|
68
|
-
router.get(
|
|
69
|
-
router.delete(
|
|
70
|
-
router.post(
|
|
71
|
-
router.get(
|
|
66
|
+
router.post("/iam/menu", middleware, menu.create);
|
|
67
|
+
router.patch("/iam/menu/:MENU_ID", middleware, menu.update);
|
|
68
|
+
router.put("/iam/menu/:MENU_ID/status", middleware, menu.status);
|
|
69
|
+
router.get("/iam/menu", middleware, menu.retrieve);
|
|
70
|
+
router.get("/iam/menu/:MENU_ID", middleware, menu.get);
|
|
71
|
+
router.delete("/iam/menu/:MENU_ID", middleware, menu.delete);
|
|
72
|
+
router.post("/iam/menu/order", middleware, menu.order);
|
|
73
|
+
router.get("/iam/menu/count/all", middleware, menu.count);
|
|
74
|
+
|
|
75
|
+
// IAM / History
|
|
76
|
+
router.post("/iam/retrieve/history", middleware, history.retrieve);
|
|
77
|
+
router.get("/iam/history/:HISTORY_ID", middleware, history.detail);
|
|
72
78
|
|
|
73
79
|
// Utilities
|
|
74
|
-
router.patch(
|
|
80
|
+
router.patch("/iam/add/time/:TOKEN", user.addTimeToken);
|
|
75
81
|
|
|
76
|
-
module.exports = router
|
|
82
|
+
module.exports = router;
|
package/lib/swagger.yaml
CHANGED
|
@@ -1178,4 +1178,52 @@ paths:
|
|
|
1178
1178
|
example: 54
|
|
1179
1179
|
responses:
|
|
1180
1180
|
'200': # status code
|
|
1181
|
-
description: Retorna el resultado de la respuesta
|
|
1181
|
+
description: Retorna el resultado de la respuesta
|
|
1182
|
+
/iam/history:
|
|
1183
|
+
post:
|
|
1184
|
+
summary: Obtener todo el historial paginado
|
|
1185
|
+
tags:
|
|
1186
|
+
- History
|
|
1187
|
+
description: Ordena los elementos de menú
|
|
1188
|
+
security:
|
|
1189
|
+
- bearerAuth: []
|
|
1190
|
+
requestBody:
|
|
1191
|
+
content:
|
|
1192
|
+
'application/json':
|
|
1193
|
+
schema:
|
|
1194
|
+
properties:
|
|
1195
|
+
filter:
|
|
1196
|
+
type: object
|
|
1197
|
+
properties:
|
|
1198
|
+
method:
|
|
1199
|
+
enum: [ GET, POST, PUT, PATCH, DELETE]
|
|
1200
|
+
config:
|
|
1201
|
+
type: object
|
|
1202
|
+
properties:
|
|
1203
|
+
page:
|
|
1204
|
+
type: number
|
|
1205
|
+
example: 1
|
|
1206
|
+
itemsPerPage:
|
|
1207
|
+
type: number
|
|
1208
|
+
example: 10
|
|
1209
|
+
responses:
|
|
1210
|
+
'200': # status code
|
|
1211
|
+
description: Retorna el resultado de la respuesta
|
|
1212
|
+
/iam/history/{HISTORY_ID}:
|
|
1213
|
+
get:
|
|
1214
|
+
parameters:
|
|
1215
|
+
- name: HISTORY_ID
|
|
1216
|
+
in: path
|
|
1217
|
+
description: ID de un registro de historial
|
|
1218
|
+
required: true
|
|
1219
|
+
schema:
|
|
1220
|
+
type: string
|
|
1221
|
+
format: ObjectId
|
|
1222
|
+
tags:
|
|
1223
|
+
- History
|
|
1224
|
+
description: Detalle de u registro de historial
|
|
1225
|
+
security:
|
|
1226
|
+
- bearerAuth: []
|
|
1227
|
+
responses:
|
|
1228
|
+
'200': # status code
|
|
1229
|
+
description: Retorna un objeto
|