watch.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. 'use strict';
  2. /** Get controllers */
  3. const watchController = require('../controllers/watch');
  4. const authMiddleware = require('../middlewares/auth');
  5. /**
  6. * Watch routes
  7. * You can watch productions and filtered productions by tag.
  8. * Also, add and update productions.
  9. *
  10. * @param {Router} - express router
  11. */
  12. module.exports = function (router) {
  13. /*
  14. * Get a production to watch
  15. * @param {string} permalink - Is the link to a individual production
  16. */
  17. router.route('/assistir/:permalink')
  18. /** GET /assistir/:permalink - Get a production to watch */
  19. .get(watchController.watchGet);
  20. /*
  21. * Create a new production
  22. */
  23. router.route('/novo')
  24. /** GET /novo - UI for new production */
  25. .get(authMiddleware, watchController.newWatchGet)
  26. /** POST /novo - Create new production */
  27. .post(authMiddleware, watchController.newWatchPost);
  28. /**
  29. * Update a production
  30. * @param {string} - Is the identifier of the production
  31. */
  32. router.route('/edit/:_id')
  33. /** GET /edit/:id - Update watch */
  34. .get(authMiddleware, watchController.watchEdit)
  35. /** GET /edit/:id - Update watch */
  36. .post(authMiddleware, watchController.watchPut);
  37. /**
  38. * Filter productions by specified tag
  39. */
  40. router.route('/t/:tags')
  41. /** GET /t/:tags - Get filtered productions by specified tags */
  42. .get(watchController.tagsGet);
  43. return router;
  44. }