Last active
February 3, 2019 11:52
-
-
Save andregardi/f925b64d5bcdcf09acb408579ec9c3c8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { Router } from "express"; | |
| import UserController from "../controllers/UserController"; | |
| import { checkJwt } from "../middlewares/checkJwt"; | |
| import { checkRole } from "../middlewares/checkRole"; | |
| const router = Router(); | |
| //Get all users | |
| router.get("/", [checkJwt, checkRole(["ADMIN"])], UserController.listAll); | |
| // Get one user | |
| router.get( | |
| "/:id([0-9]+)", | |
| [checkJwt, checkRole(["ADMIN"])], | |
| UserController.getOneById | |
| ); | |
| //Create a new user | |
| router.post("/", [checkJwt, checkRole(["ADMIN"])], UserController.newUser); | |
| //Edit one user | |
| router.patch( | |
| "/:id([0-9]+)", | |
| [checkJwt, checkRole(["ADMIN"])], | |
| UserController.editUser | |
| ); | |
| //Delete one user | |
| router.delete( | |
| "/:id([0-9]+)", | |
| [checkJwt, checkRole(["ADMIN"])], | |
| UserController.deleteUser | |
| ); | |
| export default router; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment