user.js 1007 B

123456789101112131415161718192021222324252627282930
  1. const express = require('express');
  2. const router = express.Router();
  3. const controllers = require('../controllers/user');
  4. const validation = require('../validation/user');
  5. const guard = require('../helpers/guard');
  6. const upload = require('../helpers/upload');
  7. router
  8. .post('/auth/register', validation.registration, controllers.createNewUser)
  9. .patch('/auth/login', validation.logIn, controllers.logIn)
  10. .patch('/auth/logout', guard, controllers.logOut)
  11. .patch('/auth/online', guard, controllers.online)
  12. .patch(
  13. '/users/current/credentials',
  14. [guard, validation.updateCredentials],
  15. controllers.updateCredentials
  16. )
  17. .get('/users/current', guard, controllers.getCurrent)
  18. .patch(
  19. '/users/avatars',
  20. [guard, upload.uploadImage.single('avatar'), validation.validateUploadFile],
  21. controllers.updateAvatar
  22. )
  23. .patch(
  24. '/users/current/update',
  25. [guard, validation.updateUser],
  26. controllers.updateUser
  27. )
  28. .delete('/users/current/:index', guard, controllers.removeAvatar);
  29. module.exports = router;