index.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. 'use strict';
  2. const express = require('express');
  3. const router = express.Router();
  4. const notFoundMiddleware = require('../middlewares/not-found');
  5. /**
  6. * Home Controller
  7. */
  8. const HomeController = require('../controllers/home');
  9. function init(app, passport) {
  10. /**
  11. * Set up routes
  12. */
  13. const contactRoutes = require('./contact')(router);
  14. const listRoutes = require('./list')(router);
  15. const pagesRoutes = require('./pages')(router);
  16. const profileRoutes = require('./profile')(router);
  17. const uploadRoutes = require('./upload')(router);
  18. const userRoutes = require('./user')(router, passport);
  19. const watchRoutes = require('./watch')(router);
  20. const filmRoutes = require('./film')(router);
  21. /**
  22. * Mount routes
  23. */
  24. /** GET / - Home */
  25. app.get('/', HomeController.index);
  26. app.use('/', contactRoutes);
  27. app.use('/', listRoutes);
  28. app.use('/', pagesRoutes);
  29. app.use('/', profileRoutes);
  30. app.use('/', uploadRoutes);
  31. app.use('/', userRoutes);
  32. app.use('/', watchRoutes);
  33. app.use('/', filmRoutes);
  34. /**
  35. * Error handling middleware
  36. */
  37. app.use(notFoundMiddleware);
  38. }
  39. module.exports = { init };