added patch alias route

This commit is contained in:
dakshgupta2002 2022-02-02 00:45:36 +05:30
parent 1e75fe71dc
commit 0ba17f361d
2 changed files with 18 additions and 2 deletions

View File

@ -21,7 +21,7 @@ module.exports.addURL = async (req, res) => {
})
.catch((err)=>{
console.error(err)
res.sendStaus(500)
res.sendStatus(500)
})
}
@ -32,6 +32,20 @@ module.exports.deleteUrlData = async (req,res) =>{
})
.catch((err)=>{
console.error(err)
res.sendStaus(500)
res.sendStatus(500)
})
}
module.exports.updateUrlData = async (req,res) =>{
//find a data object with url's id and update the alias
Minfy.findByIdAndUpdate(req.params.id, {'alias': req.body.alias})
.then((data)=>{
//send back the updated data object
res.send(data);
})
.catch((err)=>{
//found error
console.error(err)
res.sendStatus(500)
})
}

View File

@ -9,4 +9,6 @@ router.post("/add",controller.addURL)
router.delete('/delete/:id',controller.deleteUrlData)
router.patch('/edit/:id', controller.updateUrlData)
module.exports = router;