@igea/oac_backend 1.0.21 → 1.0.23
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/package.json +1 -1
- package/src/controllers/users.js +5 -1
- package/src/models/users.js +1 -1
package/package.json
CHANGED
package/src/controllers/users.js
CHANGED
|
@@ -47,6 +47,7 @@ router.get('/:id', async (req, res) => {
|
|
|
47
47
|
|
|
48
48
|
// Create new user
|
|
49
49
|
router.post('/', async (req, res) => {
|
|
50
|
+
console.log("POST new user");
|
|
50
51
|
const user = req.body;
|
|
51
52
|
Users.add(user).then(id => {
|
|
52
53
|
res.status(201).json({
|
|
@@ -65,8 +66,9 @@ router.post('/', async (req, res) => {
|
|
|
65
66
|
|
|
66
67
|
// Update existing user
|
|
67
68
|
router.put('/:id', async (req, res) => {
|
|
68
|
-
|
|
69
|
+
console.log("PUT update user");
|
|
69
70
|
const user = req.body;
|
|
71
|
+
console.log(user);
|
|
70
72
|
Users.update(user).then(count=>{
|
|
71
73
|
if (count === 0) {
|
|
72
74
|
res.status(404).json({
|
|
@@ -91,6 +93,7 @@ router.put('/:id', async (req, res) => {
|
|
|
91
93
|
})
|
|
92
94
|
|
|
93
95
|
router.delete('/:id', async (req, res) => {
|
|
96
|
+
console.log("DELETE user");
|
|
94
97
|
Users.delete(req.params.id).then(deletedCount=>{
|
|
95
98
|
if (deletedCount === 0) {
|
|
96
99
|
res.status(404).json({
|
|
@@ -106,6 +109,7 @@ router.delete('/:id', async (req, res) => {
|
|
|
106
109
|
});
|
|
107
110
|
}
|
|
108
111
|
}).catch(err=>{
|
|
112
|
+
console.log(err)
|
|
109
113
|
res.status(500).json({
|
|
110
114
|
success: false,
|
|
111
115
|
data: null,
|
package/src/models/users.js
CHANGED
|
@@ -50,7 +50,7 @@ class Users {
|
|
|
50
50
|
}
|
|
51
51
|
}else{
|
|
52
52
|
console.log("ALLL USERS")
|
|
53
|
-
const users = await db(table).select(fields);
|
|
53
|
+
const users = await db(table).select(fields).orderByRaw('id ASC') ;
|
|
54
54
|
const safeUsers = users.map(({ password, ...rest }) => rest);
|
|
55
55
|
resolve(safeUsers)
|
|
56
56
|
}
|