diff --git a/backend/controllers/minify.js b/backend/controllers/minify.js index a5ce1c3..4cd0696 100644 --- a/backend/controllers/minify.js +++ b/backend/controllers/minify.js @@ -47,7 +47,7 @@ module.exports.addURL = async (req, res) => { Minfy.create({ originalUrl: req.body.originalUrl, alias: alias, - minifiedUrl: minifiedUrl + minifiedUrl: minifiedUrl, }) .then((data) => { res.json(data) @@ -118,3 +118,14 @@ module.exports.visitor = async (req, res) => { res.sendStatus(500) }) } + +module.exports.getAllurlsforUser = async (req, res) => { + Minfy.find({ createdBy: req.user.data.email }) + .then((data) => { + res.send(data) + }) + .catch((err) => { + console.error(err) + res.sendStatus(500) + }) +} diff --git a/backend/routers/minify.js b/backend/routers/minify.js index 4e5941f..722e868 100644 --- a/backend/routers/minify.js +++ b/backend/routers/minify.js @@ -10,6 +10,7 @@ router.get('/alias/:alias', controller.getURLData) router.post('/add', controller.addURL) router.post('/add/custom', auth, controller.addURLAuthed) +router.get('/all/user', auth, controller.getAllurlsforUser) router.patch('/edit/:id', auth, controller.updateUrlData)