Compare commits
2 Commits
3d935af6f1
...
3e8a8997b9
Author | SHA1 | Date | |
---|---|---|---|
|
3e8a8997b9 | ||
|
04bce4b90f |
4
package-lock.json
generated
4
package-lock.json
generated
@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "multi-stub",
|
"name": "multi-stub",
|
||||||
"version": "1.1.2",
|
"version": "1.2.0",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "multi-stub",
|
"name": "multi-stub",
|
||||||
"version": "1.1.2",
|
"version": "1.2.0",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"axios": "^1.7.9",
|
"axios": "^1.7.9",
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "multi-stub",
|
"name": "multi-stub",
|
||||||
"version": "1.1.2",
|
"version": "1.2.0",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
@ -63,5 +63,38 @@ router.post('/item', requiredValidate('todoId', 'title'), async (req, res) => {
|
|||||||
res.send(getAnswer(null, item))
|
res.send(getAnswer(null, item))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// closed = new Date().toISOString()
|
||||||
|
router.patch('/item/:itemId', async (req, res) => {
|
||||||
|
const { itemId } = req.params
|
||||||
|
const { title, done } = req.body
|
||||||
|
|
||||||
|
const item = await ItemModel.findById(itemId)
|
||||||
|
|
||||||
|
if (!item) {
|
||||||
|
throw new Error('item not found')
|
||||||
|
}
|
||||||
|
|
||||||
|
if (title) {
|
||||||
|
item.title = title
|
||||||
|
}
|
||||||
|
|
||||||
|
if (done) {
|
||||||
|
item.done = done
|
||||||
|
item.closed = done ? new Date().toISOString() : null
|
||||||
|
}
|
||||||
|
|
||||||
|
await item.save()
|
||||||
|
|
||||||
|
res.send(getAnswer(null, item))
|
||||||
|
})
|
||||||
|
|
||||||
|
router.delete('/item/:itemId', async (req, res) => {
|
||||||
|
const { itemId } = req.params
|
||||||
|
|
||||||
|
await ItemModel.findByIdAndDelete(itemId)
|
||||||
|
|
||||||
|
res.send(getAnswer(null, { ok: true }))
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
module.exports = router
|
module.exports = router
|
||||||
|
Loading…
x
Reference in New Issue
Block a user