👌 IMPROVE: GET /admin/functions/:slug

This commit is contained in:
Divlo 2020-04-15 16:40:09 +02:00
parent 5d791f34d6
commit 9336bf12fd
2 changed files with 7 additions and 5 deletions

View File

@ -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"] }
]

View File

@ -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,