Merge pull request #30 from dakshgupta2002/dakshgupta2002router
added patch alias route
This commit is contained in:
commit
949ee9e9d6
|
@ -32,7 +32,7 @@ module.exports.addURL = async (req, res) => {
|
|||
})
|
||||
.catch((err)=>{
|
||||
console.error(err)
|
||||
res.sendStaus(500)
|
||||
res.sendStatus(500)
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -43,6 +43,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)
|
||||
})
|
||||
}
|
|
@ -11,4 +11,6 @@ router.post("/add",controller.addURL)
|
|||
|
||||
router.delete('/delete/:id',controller.deleteUrlData)
|
||||
|
||||
router.patch('/edit/:id', controller.updateUrlData)
|
||||
|
||||
module.exports = router;
|
Loading…
Reference in New Issue