Merge branch 'main' into main

This commit is contained in:
Jyotirmoy Bandyopadhayaya 2022-02-02 01:31:56 +05:30 committed by GitHub
commit e00ae63658
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 8 deletions

View File

@ -1,6 +1,17 @@
const Minfy = require("../models/minifed_urls")
const base_url = 'https://minfy.xyz/'
module.exports.getAllData = async (req, res) => {
Minfy.find()
.then((data)=>{
res.send(data)
})
.catch((err)=>{
console.error(err)
res.sendStaus(500)
})
}
module.exports.getURLData = async (req, res) => {
try {
const {
@ -30,14 +41,14 @@ module.exports.findUrlById = async (req, res) => {
module.exports.addURL = async (req, res) => {
req.body.minifiedUrl = base_url + req.body.alias
Minfy.create(req.body).select("-__v")
.then((data) => {
res.send(data)
})
.catch((err) => {
console.error(err)
res.sendStatus(500)
})
Minfy.create(req.body)
.then((data)=>{
res.send(data)
})
.catch((err)=>{
console.error(err)
res.sendStatus(500)
})
}
module.exports.deleteUrlData = async (req, res) => {

View File

@ -3,6 +3,8 @@ const controller = require("../controllers/minify")
const router = Router();
router.get("/all", controller.getAllData)
router.get("/alias/:alias", controller.getURLData)
router.post("/add",controller.addURL)
@ -11,4 +13,6 @@ router.get("/id/:id", controller.findUrlById)
router.delete('/delete/:id',controller.deleteUrlData)
router.patch('/edit/:id', controller.updateUrlData)
module.exports = router;