index.js 1.0 KB

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