create-sipere 1.2.1 → 1.2.2
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
CHANGED
|
@@ -123,6 +123,28 @@ const UserController = {
|
|
|
123
123
|
success: true,
|
|
124
124
|
data: user
|
|
125
125
|
})
|
|
126
|
+
},
|
|
127
|
+
async destroy(req, res) {
|
|
128
|
+
try {
|
|
129
|
+
await UserController.tryDestroy(req, res)
|
|
130
|
+
}catch(error) {
|
|
131
|
+
res.status(500)
|
|
132
|
+
res.json({
|
|
133
|
+
success: false,
|
|
134
|
+
message: 'Error! The query is failed!',
|
|
135
|
+
error: error.message
|
|
136
|
+
})
|
|
137
|
+
}
|
|
138
|
+
},
|
|
139
|
+
async tryDestroy(req, res) {
|
|
140
|
+
const user = await User.destroy({
|
|
141
|
+
where: { id: req.params.id }
|
|
142
|
+
})
|
|
143
|
+
res.status(200)
|
|
144
|
+
res.json({
|
|
145
|
+
success: true,
|
|
146
|
+
data: user
|
|
147
|
+
})
|
|
126
148
|
}
|
|
127
149
|
}
|
|
128
150
|
|
|
@@ -10,5 +10,6 @@ router.post('/login', AuthController.login)
|
|
|
10
10
|
router.get('/users', [verifyToken], UserController.index)
|
|
11
11
|
router.get('/users/:id', [verifyToken], UserController.show)
|
|
12
12
|
router.put('/users/:id/password', [verifyToken], UserController.updatePassword)
|
|
13
|
+
router.delete('/users/:id', [verifyToken], UserController.destroy)
|
|
13
14
|
|
|
14
15
|
export default router
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"description": "Express API with simple Sequelize",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
7
|
-
"test": "NODE_ENV=test mocha --file test/mocha.setup.js 'test/**/*.spec.js'",
|
|
7
|
+
"test": "cross-env NODE_ENV=test mocha --file test/mocha.setup.js 'test/**/*.spec.js'",
|
|
8
8
|
"dev": "nodemon app",
|
|
9
9
|
"start": "node app"
|
|
10
10
|
},
|
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@types/bcryptjs": "^2.4.6",
|
|
32
|
+
"cross-env": "^10.1.0",
|
|
32
33
|
"fs-extra": "^11.3.0",
|
|
33
34
|
"mocha": "^11.7.4",
|
|
34
35
|
"nodemon": "^2.0.22",
|