Merge pull request #30 from dakshgupta2002/dakshgupta2002router

added patch alias route
This commit is contained in:
Jyotirmoy Bandyopadhayaya 2022-02-02 01:22:18 +05:30 committed by GitHub
commit 949ee9e9d6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 2 deletions

View File

@ -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)
})
}

View File

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