Skip to content

Instantly share code, notes, and snippets.

@bchiang7
Last active November 8, 2019 02:52
Show Gist options
  • Save bchiang7/5feaf2290fde372dd69cb7a475db356c to your computer and use it in GitHub Desktop.
Save bchiang7/5feaf2290fde372dd69cb7a475db356c to your computer and use it in GitHub Desktop.
// routes/index.js
const express = require('express');
const router = express.Router();
// App routes (for the mobile app)
const APP = express.Router();
router.use('/', APP);
APP.get('/users/:id', isAuthenticated, userController.getUser);
...
// Admin routes (for the admin tool)
const ADMIN = express.Router();
router.use('/admin', ADMIN);
ADMIN.get('/users', isAuthenticated, isAdmin, adminUserController.getUsers);
ADMIN.get('/users/:id', isAuthenticated, isAdmin, adminUserController.getUser);
ADMIN.patch('/users/:id', isAuthenticated, isAdmin, adminUserController.updateUser);
ADMIN.delete('/users/:id', isAuthenticated, isAdmin, adminUserController.deleteUser);
module.exports = router;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment