From 9336bf12fd6206c8500987e28f63085f51d38f34 Mon Sep 17 00:00:00 2001 From: Divlo Date: Wed, 15 Apr 2020 16:40:09 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=91=8C=20IMPROVE:=20GET=20/admin/function?= =?UTF-8?q?s/:slug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/controllers/admin.js | 6 +++--- api/routes/admin.js | 6 ++++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/api/controllers/admin.js b/api/controllers/admin.js index f3802cc..bbe18c4 100644 --- a/api/controllers/admin.js +++ b/api/controllers/admin.js @@ -63,10 +63,10 @@ exports.getFunctions = (req, res, next) => { }); } -exports.getFunctionById = (req, res, next) => { - const { id } = req.params; +exports.getFunctionBySlug = (req, res, next) => { + const { slug } = req.params; Functions.findOne({ - where: { id }, + where: { slug }, include: [ { model: Categories, attributes: ["name", "color"] } ] diff --git a/api/routes/admin.js b/api/routes/admin.js index 2695ed6..8cfc7a6 100644 --- a/api/routes/admin.js +++ b/api/routes/admin.js @@ -95,10 +95,12 @@ AdminRouter.route('/functions') }) ], adminController.postFunction); -AdminRouter.route('/functions/:id') +AdminRouter.route('/functions/:slug') // Récupère les informations d'une fonction - .get(isAuth, isAdmin, adminController.getFunctionById) + .get(isAuth, isAdmin, adminController.getFunctionBySlug); + +AdminRouter.route('/functions/:id') // Modifie information basique d'une fonction .put(isAuth, isAdmin,