user.js 823 B

123456789101112131415161718192021222324
  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',
  14. [guard, validation.updateUser],
  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. module.exports = router;