aloux-iam 0.0.21 → 0.0.22
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/.gitattributes +2 -2
- package/CONTRIBUTING.md +1 -1
- package/LICENSE +21 -21
- package/README.md +270 -272
- package/index.js +33 -33
- package/lib/auth.js +90 -90
- package/lib/config/utils.js +13 -13
- package/lib/controllers/auth.js +147 -147
- package/lib/controllers/functions.js +86 -86
- package/lib/controllers/menu.js +101 -101
- package/lib/controllers/operationsAWS.js +218 -218
- package/lib/controllers/permission.js +90 -90
- package/lib/controllers/user.js +746 -746
- package/lib/middleware.js +90 -90
- package/lib/models/Functions.js +13 -13
- package/lib/models/Menu.js +15 -15
- package/lib/models/Permission.js +14 -14
- package/lib/models/User.js +105 -104
- package/lib/router.js +72 -72
- package/lib/services/auth.js +500 -500
- package/lib/services/s3.js +71 -71
- package/lib/services/ses.js +97 -97
- package/lib/services/sns.js +21 -21
- package/lib/services/user.js +98 -98
- package/lib/swagger.yaml +1176 -1176
- package/package-lock.json +4521 -0
- package/package.json +38 -38
|
@@ -1,87 +1,87 @@
|
|
|
1
|
-
const Functions = require('../models/Functions')
|
|
2
|
-
const user = require('./user')
|
|
3
|
-
const self = module.exports
|
|
4
|
-
|
|
5
|
-
self.create = async (req, res) => {
|
|
6
|
-
try {
|
|
7
|
-
const functions = new Functions(req.body)
|
|
8
|
-
functions.createdAt = (new Date()).getTime()
|
|
9
|
-
functions.status = 'Activo'
|
|
10
|
-
await functions.save()
|
|
11
|
-
res.status(201).send(functions)
|
|
12
|
-
} catch (error) {
|
|
13
|
-
console.log(error)
|
|
14
|
-
res.status(400).send({error:error.message})
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
self.update = async (req, resp) => {
|
|
19
|
-
try {
|
|
20
|
-
await (new Functions(req.body)).validate()
|
|
21
|
-
const count = await Functions.findOne({_id:req.params.FUNCTION_ID}).countDocuments()
|
|
22
|
-
if(!count)
|
|
23
|
-
throw new Error('Upss! No se encontró el registro')
|
|
24
|
-
req.body.lastUpdate = (new Date()).getTime()
|
|
25
|
-
const result = await Functions.updateOne({_id:req.params.FUNCTION_ID}, req.body)
|
|
26
|
-
resp.status(200).send(req.body)
|
|
27
|
-
} catch (error) {
|
|
28
|
-
resp.status(400).send({error:error.message})
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
self.status = async (req, resp) => {
|
|
32
|
-
try {
|
|
33
|
-
const _id = req.params.FUNCTION_ID
|
|
34
|
-
const functions = await Functions.findOne({ _id })
|
|
35
|
-
if(!functions)
|
|
36
|
-
throw new Error('Upss! No se encontró el Elemento')
|
|
37
|
-
functions.status = req.body.status
|
|
38
|
-
functions.lastUpdate = (new Date()).getTime()
|
|
39
|
-
const result = await functions.save()
|
|
40
|
-
resp.status(200).send(result)
|
|
41
|
-
} catch (error) {
|
|
42
|
-
resp.status(400).send({error:error.message})
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
self.retrieve = async(req, res) => {
|
|
46
|
-
try {
|
|
47
|
-
const response = await Functions.find({}).sort({ createdAt:-1 })
|
|
48
|
-
res.status(200).send(response)
|
|
49
|
-
} catch (error) {
|
|
50
|
-
res.status(400).send(error)
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
self.get = async(req, res) => {
|
|
55
|
-
try {
|
|
56
|
-
const _id = req.params.FUNCTION_ID
|
|
57
|
-
const functions = await Functions.findOne({ _id }).populate([{ path: "_permissions" },{ path: "_menus" }]).lean()
|
|
58
|
-
if(!functions)
|
|
59
|
-
res.status(404).send()
|
|
60
|
-
res.status(200).send(functions)
|
|
61
|
-
} catch (error) {
|
|
62
|
-
res.status(400).send(error)
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
self.delete = async(req, res) => {
|
|
67
|
-
try {
|
|
68
|
-
|
|
69
|
-
const _id = req.params.FUNCTION_ID
|
|
70
|
-
const response = await Functions.deleteOne({ _id })
|
|
71
|
-
if(!response.deletedCount)
|
|
72
|
-
res.status(404).send({ error : "El registro no existe"})
|
|
73
|
-
else
|
|
74
|
-
res.status(200).send({})
|
|
75
|
-
} catch (error) {
|
|
76
|
-
res.status(400).send({error:error.message})
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
self.count = async(req, res) => {
|
|
81
|
-
try {
|
|
82
|
-
let result = await Functions.find({}).countDocuments()
|
|
83
|
-
res.status(200).send({ count: result })
|
|
84
|
-
} catch (error) {
|
|
85
|
-
res.status(400).send({error:error.message})
|
|
86
|
-
}
|
|
1
|
+
const Functions = require('../models/Functions')
|
|
2
|
+
const user = require('./user')
|
|
3
|
+
const self = module.exports
|
|
4
|
+
|
|
5
|
+
self.create = async (req, res) => {
|
|
6
|
+
try {
|
|
7
|
+
const functions = new Functions(req.body)
|
|
8
|
+
functions.createdAt = (new Date()).getTime()
|
|
9
|
+
functions.status = 'Activo'
|
|
10
|
+
await functions.save()
|
|
11
|
+
res.status(201).send(functions)
|
|
12
|
+
} catch (error) {
|
|
13
|
+
console.log(error)
|
|
14
|
+
res.status(400).send({error:error.message})
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
self.update = async (req, resp) => {
|
|
19
|
+
try {
|
|
20
|
+
await (new Functions(req.body)).validate()
|
|
21
|
+
const count = await Functions.findOne({_id:req.params.FUNCTION_ID}).countDocuments()
|
|
22
|
+
if(!count)
|
|
23
|
+
throw new Error('Upss! No se encontró el registro')
|
|
24
|
+
req.body.lastUpdate = (new Date()).getTime()
|
|
25
|
+
const result = await Functions.updateOne({_id:req.params.FUNCTION_ID}, req.body)
|
|
26
|
+
resp.status(200).send(req.body)
|
|
27
|
+
} catch (error) {
|
|
28
|
+
resp.status(400).send({error:error.message})
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
self.status = async (req, resp) => {
|
|
32
|
+
try {
|
|
33
|
+
const _id = req.params.FUNCTION_ID
|
|
34
|
+
const functions = await Functions.findOne({ _id })
|
|
35
|
+
if(!functions)
|
|
36
|
+
throw new Error('Upss! No se encontró el Elemento')
|
|
37
|
+
functions.status = req.body.status
|
|
38
|
+
functions.lastUpdate = (new Date()).getTime()
|
|
39
|
+
const result = await functions.save()
|
|
40
|
+
resp.status(200).send(result)
|
|
41
|
+
} catch (error) {
|
|
42
|
+
resp.status(400).send({error:error.message})
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
self.retrieve = async(req, res) => {
|
|
46
|
+
try {
|
|
47
|
+
const response = await Functions.find({}).sort({ createdAt:-1 })
|
|
48
|
+
res.status(200).send(response)
|
|
49
|
+
} catch (error) {
|
|
50
|
+
res.status(400).send(error)
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
self.get = async(req, res) => {
|
|
55
|
+
try {
|
|
56
|
+
const _id = req.params.FUNCTION_ID
|
|
57
|
+
const functions = await Functions.findOne({ _id }).populate([{ path: "_permissions" },{ path: "_menus" }]).lean()
|
|
58
|
+
if(!functions)
|
|
59
|
+
res.status(404).send()
|
|
60
|
+
res.status(200).send(functions)
|
|
61
|
+
} catch (error) {
|
|
62
|
+
res.status(400).send(error)
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
self.delete = async(req, res) => {
|
|
67
|
+
try {
|
|
68
|
+
|
|
69
|
+
const _id = req.params.FUNCTION_ID
|
|
70
|
+
const response = await Functions.deleteOne({ _id })
|
|
71
|
+
if(!response.deletedCount)
|
|
72
|
+
res.status(404).send({ error : "El registro no existe"})
|
|
73
|
+
else
|
|
74
|
+
res.status(200).send({})
|
|
75
|
+
} catch (error) {
|
|
76
|
+
res.status(400).send({error:error.message})
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
self.count = async(req, res) => {
|
|
81
|
+
try {
|
|
82
|
+
let result = await Functions.find({}).countDocuments()
|
|
83
|
+
res.status(200).send({ count: result })
|
|
84
|
+
} catch (error) {
|
|
85
|
+
res.status(400).send({error:error.message})
|
|
86
|
+
}
|
|
87
87
|
}
|
package/lib/controllers/menu.js
CHANGED
|
@@ -1,102 +1,102 @@
|
|
|
1
|
-
const Menu = require('../models/Menu')
|
|
2
|
-
const self = module.exports
|
|
3
|
-
|
|
4
|
-
self.create = async (req, res) => {
|
|
5
|
-
try {
|
|
6
|
-
const menu = new Menu(req.body)
|
|
7
|
-
menu.createdAt = (new Date()).getTime()
|
|
8
|
-
menu.status = 'Activo'
|
|
9
|
-
await menu.save()
|
|
10
|
-
res.status(201).send(menu)
|
|
11
|
-
} catch (error) {
|
|
12
|
-
res.status(400).send({error:error.message})
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
self.update = async (req, resp) => {
|
|
17
|
-
try {
|
|
18
|
-
await (new Menu(req.body)).validate()
|
|
19
|
-
const _id = req.params.MENU_ID
|
|
20
|
-
const count = await Menu.findOne({_id}).countDocuments()
|
|
21
|
-
if(!count)
|
|
22
|
-
throw new Error('Upss! No se encontró el registro')
|
|
23
|
-
req.body.lastUpdate = (new Date()).getTime()
|
|
24
|
-
const result = await Menu.updateOne({_id}, req.body)
|
|
25
|
-
resp.status(200).send(req.body)
|
|
26
|
-
} catch (error) {
|
|
27
|
-
resp.status(400).send({error:error.message})
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
self.status = async (req, resp) => {
|
|
31
|
-
try {
|
|
32
|
-
const _id = req.params.MENU_ID
|
|
33
|
-
const user = await Menu.findOne({ _id })
|
|
34
|
-
if(!user)
|
|
35
|
-
throw new Error('Upss! No se encontró el Elemento')
|
|
36
|
-
user.status = req.body.status
|
|
37
|
-
user.lastUpdate = (new Date()).getTime()
|
|
38
|
-
const result = await user.save()
|
|
39
|
-
resp.status(200).send(result)
|
|
40
|
-
} catch (error) {
|
|
41
|
-
resp.status(400).send({error:error.message})
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
self.retrieve = async(req, res) => {
|
|
45
|
-
try {
|
|
46
|
-
const consulta = await Menu.find({}).sort({index:1})
|
|
47
|
-
if(!consulta)
|
|
48
|
-
res.status(404).send()
|
|
49
|
-
res.status(200).send(consulta)
|
|
50
|
-
} catch (error) {
|
|
51
|
-
res.status(400).send(error)
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
self.get = async(req, res) => {
|
|
56
|
-
try {
|
|
57
|
-
const _id = req.params.MENU_ID
|
|
58
|
-
const menu = await Menu.findOne({_id})
|
|
59
|
-
if(!menu)
|
|
60
|
-
res.status(404).send()
|
|
61
|
-
res.status(200).send(menu)
|
|
62
|
-
} catch (error) {
|
|
63
|
-
res.status(400).send(error)
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
self.delete = async(req, res) => {
|
|
68
|
-
try {
|
|
69
|
-
const _id = req.params.MENU_ID
|
|
70
|
-
const response = await Menu.deleteOne({ _id })
|
|
71
|
-
if(!response.deletedCount)
|
|
72
|
-
res.status(404).send({ error : "El registro no existe"})
|
|
73
|
-
else
|
|
74
|
-
res.status(200).send({})
|
|
75
|
-
} catch (error) {
|
|
76
|
-
res.status(400).send({error:error.message})
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
self.order = async (req, resp) => {
|
|
81
|
-
try {
|
|
82
|
-
if(!req.body.length)
|
|
83
|
-
throw new Error('Upss! No se encontró el registro')
|
|
84
|
-
|
|
85
|
-
for(let i in req.body){
|
|
86
|
-
const item = req.body[i]
|
|
87
|
-
await Menu.updateOne({ _id:item._id }, { $set: { index: item.index } })
|
|
88
|
-
}
|
|
89
|
-
resp.status(200).send({})
|
|
90
|
-
} catch (error) {
|
|
91
|
-
resp.status(400).send({error:error.message})
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
self.count = async(req, res) => {
|
|
96
|
-
try {
|
|
97
|
-
let result = await Menu.find({}).countDocuments()
|
|
98
|
-
res.status(200).send({ count: result })
|
|
99
|
-
} catch (error) {
|
|
100
|
-
res.status(400).send({error:error.message})
|
|
101
|
-
}
|
|
1
|
+
const Menu = require('../models/Menu')
|
|
2
|
+
const self = module.exports
|
|
3
|
+
|
|
4
|
+
self.create = async (req, res) => {
|
|
5
|
+
try {
|
|
6
|
+
const menu = new Menu(req.body)
|
|
7
|
+
menu.createdAt = (new Date()).getTime()
|
|
8
|
+
menu.status = 'Activo'
|
|
9
|
+
await menu.save()
|
|
10
|
+
res.status(201).send(menu)
|
|
11
|
+
} catch (error) {
|
|
12
|
+
res.status(400).send({error:error.message})
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
self.update = async (req, resp) => {
|
|
17
|
+
try {
|
|
18
|
+
await (new Menu(req.body)).validate()
|
|
19
|
+
const _id = req.params.MENU_ID
|
|
20
|
+
const count = await Menu.findOne({_id}).countDocuments()
|
|
21
|
+
if(!count)
|
|
22
|
+
throw new Error('Upss! No se encontró el registro')
|
|
23
|
+
req.body.lastUpdate = (new Date()).getTime()
|
|
24
|
+
const result = await Menu.updateOne({_id}, req.body)
|
|
25
|
+
resp.status(200).send(req.body)
|
|
26
|
+
} catch (error) {
|
|
27
|
+
resp.status(400).send({error:error.message})
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
self.status = async (req, resp) => {
|
|
31
|
+
try {
|
|
32
|
+
const _id = req.params.MENU_ID
|
|
33
|
+
const user = await Menu.findOne({ _id })
|
|
34
|
+
if(!user)
|
|
35
|
+
throw new Error('Upss! No se encontró el Elemento')
|
|
36
|
+
user.status = req.body.status
|
|
37
|
+
user.lastUpdate = (new Date()).getTime()
|
|
38
|
+
const result = await user.save()
|
|
39
|
+
resp.status(200).send(result)
|
|
40
|
+
} catch (error) {
|
|
41
|
+
resp.status(400).send({error:error.message})
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
self.retrieve = async(req, res) => {
|
|
45
|
+
try {
|
|
46
|
+
const consulta = await Menu.find({}).sort({index:1})
|
|
47
|
+
if(!consulta)
|
|
48
|
+
res.status(404).send()
|
|
49
|
+
res.status(200).send(consulta)
|
|
50
|
+
} catch (error) {
|
|
51
|
+
res.status(400).send(error)
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
self.get = async(req, res) => {
|
|
56
|
+
try {
|
|
57
|
+
const _id = req.params.MENU_ID
|
|
58
|
+
const menu = await Menu.findOne({_id})
|
|
59
|
+
if(!menu)
|
|
60
|
+
res.status(404).send()
|
|
61
|
+
res.status(200).send(menu)
|
|
62
|
+
} catch (error) {
|
|
63
|
+
res.status(400).send(error)
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
self.delete = async(req, res) => {
|
|
68
|
+
try {
|
|
69
|
+
const _id = req.params.MENU_ID
|
|
70
|
+
const response = await Menu.deleteOne({ _id })
|
|
71
|
+
if(!response.deletedCount)
|
|
72
|
+
res.status(404).send({ error : "El registro no existe"})
|
|
73
|
+
else
|
|
74
|
+
res.status(200).send({})
|
|
75
|
+
} catch (error) {
|
|
76
|
+
res.status(400).send({error:error.message})
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
self.order = async (req, resp) => {
|
|
81
|
+
try {
|
|
82
|
+
if(!req.body.length)
|
|
83
|
+
throw new Error('Upss! No se encontró el registro')
|
|
84
|
+
|
|
85
|
+
for(let i in req.body){
|
|
86
|
+
const item = req.body[i]
|
|
87
|
+
await Menu.updateOne({ _id:item._id }, { $set: { index: item.index } })
|
|
88
|
+
}
|
|
89
|
+
resp.status(200).send({})
|
|
90
|
+
} catch (error) {
|
|
91
|
+
resp.status(400).send({error:error.message})
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
self.count = async(req, res) => {
|
|
96
|
+
try {
|
|
97
|
+
let result = await Menu.find({}).countDocuments()
|
|
98
|
+
res.status(200).send({ count: result })
|
|
99
|
+
} catch (error) {
|
|
100
|
+
res.status(400).send({error:error.message})
|
|
101
|
+
}
|
|
102
102
|
}
|