Created
July 29, 2018 20:08
-
-
Save collins-b/bfcb287d2ab7069a7fb9d8773699c0da to your computer and use it in GitHub Desktop.
This file contains 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 usersController from '../controllers/users'; | |
// const auth = require('../../middleware/auth'); | |
const path = require('path'); | |
module.exports = (app) => { | |
// Creates a new user. | |
app.post('/api/users', usersController.create); | |
// Find matching instances of user. | |
app.get('/api/users', auth.authenticate, auth.checkIfAdmin, usersController.listUsers); | |
// Search a user by username | |
app.post('/api/users/search', usersController.searchUser); | |
app.get('/api/search/users', usersController.searchUserByQuery); | |
app.get('/api/users/session', auth.authenticate, auth.checkIfAdmin, usersController.session); | |
// Creates a new document instance. | |
app.post('/api/users/:userId/documents', auth.authenticate, documentsControllers.create); | |
// Find a specific user. | |
app.get('/api/users/:id', auth.authenticate, auth.checkIfAdmin, usersController.retrieveUser); | |
// Update user's attributes. | |
app.put('/api/users/:id', usersController.updateUser); | |
// Delete a specific user. | |
app.delete('/api/users/:userId', auth.authenticate, auth.checkIfAdmin, usersController.deleteUser); | |
// Login user | |
app.post('/api/login', usersController.login); | |
// Logout user | |
app.get('/api/logout', auth.authenticate, usersController.logout); | |
// Resets password / recover account | |
app.post('/api/users/:reset', usersController.forgot); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment