minor changes
This commit is contained in:
parent
e6931bd13a
commit
fba9a1f062
|
@ -43,13 +43,13 @@ module.exports.findUrlById = async (req, res) => {
|
||||||
|
|
||||||
module.exports.getAliasStatus = async (req, res) => {
|
module.exports.getAliasStatus = async (req, res) => {
|
||||||
try{
|
try{
|
||||||
const alias = req.body.alias;
|
const alias = req.params.alias;
|
||||||
const aliasStatus = await minifed_urls.findOne({ alias });
|
const aliasStatus = await minifed_urls.findOne({ alias });
|
||||||
|
|
||||||
if(!aliasStatus){
|
if(!aliasStatus){
|
||||||
return res.status(200).json("success: true");
|
return res.status(200).json({success: true});
|
||||||
}else{
|
}else{
|
||||||
return res.status(400).json("success: false")
|
return res.status(400).json({success: false})
|
||||||
}
|
}
|
||||||
}catch (error){
|
}catch (error){
|
||||||
console.error(error)
|
console.error(error)
|
||||||
|
@ -63,7 +63,7 @@ module.exports.addURL = async (req, res) => {
|
||||||
try{
|
try{
|
||||||
const aliasPresent = await minifed_urls.findOne({ alias });
|
const aliasPresent = await minifed_urls.findOne({ alias });
|
||||||
if(aliasPresent){
|
if(aliasPresent){
|
||||||
return res.status(400).json("success: false");
|
return res.status(400).json({success: false});
|
||||||
}
|
}
|
||||||
}catch (error){
|
}catch (error){
|
||||||
console.error(error)
|
console.error(error)
|
||||||
|
|
|
@ -7,10 +7,10 @@ const router = Router()
|
||||||
router.get('/all', controller.getAllData)
|
router.get('/all', controller.getAllData)
|
||||||
router.get('/id/:id', controller.findUrlById)
|
router.get('/id/:id', controller.findUrlById)
|
||||||
router.get('/alias/:alias', controller.getURLData)
|
router.get('/alias/:alias', controller.getURLData)
|
||||||
|
router.get('/alias/:alias/status', controller.getAliasStatus)
|
||||||
|
|
||||||
router.post('/add', controller.addURL)
|
router.post('/add', controller.addURL)
|
||||||
router.post('/add/custom', auth, controller.addURLAuthed)
|
router.post('/add/custom', auth, controller.addURLAuthed)
|
||||||
router.post('/alias/:alias/status', controller.getAliasStatus)
|
|
||||||
|
|
||||||
router.patch('/edit/:id', auth, controller.updateUrlData)
|
router.patch('/edit/:id', auth, controller.updateUrlData)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue