Skip to content

Instantly share code, notes, and snippets.

@paulobunga
Last active January 28, 2019 13:01
Show Gist options
  • Save paulobunga/bc43f27f40d16566d2814505327eafa2 to your computer and use it in GitHub Desktop.
Save paulobunga/bc43f27f40d16566d2814505327eafa2 to your computer and use it in GitHub Desktop.
const express = require('express');
const router = express.Router();
const authMiddleware = require('../middleware/auth-middleware');
const userController = require('../controllers/user-controller');
//Get a list of all the users
//We are using the authentication middleware to protect this route from unauthorised access
router.get('/', authMiddleware.isAuthenticated, userController.getUsers);
router.get('/:userId', authMiddleware.isAuthenticated, userController.getSingleUser);
router.post('/', authMiddleware.isAuthenticated, userController.createUser);
router.put('/:userId', authMiddleware.isAuthenticated, userController.updateUser);
router.delete('/:userId', authMiddleware.isAuthenticated, userController.deleteUser);
module.exports = router;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment