index.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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. const adminRoutes = require('./admin')(router, passport);
  22. /**
  23. * Mount routes
  24. */
  25. /** GET / - Home */
  26. app.get('/', HomeController.index);
  27. app.use('/', contactRoutes);
  28. app.use('/', listRoutes);
  29. app.use('/', pagesRoutes);
  30. app.use('/', profileRoutes);
  31. app.use('/', uploadRoutes);
  32. app.use('/', userRoutes);
  33. app.use('/', watchRoutes);
  34. app.use('/', filmRoutes);
  35. /**
  36. * Error handling middleware
  37. */
  38. app.use(notFoundMiddleware);
  39. }
  40. module.exports = { init };