SFRA Server-side Javascript - Source: app_storefront_base/cartridge/controllers/Home.js menu

SFRA / Server-side JS / Source: app_storefront_base/cartridge/controllers/Home.js

  1. 'use strict';
  2. /**
  3. * @namespace Home
  4. */
  5. var server = require('server');
  6. var cache = require('*/cartridge/scripts/middleware/cache');
  7. var consentTracking = require('*/cartridge/scripts/middleware/consentTracking');
  8. var pageMetaData = require('*/cartridge/scripts/middleware/pageMetaData');
  9. /**
  10. * Any customization on this endpoint, also requires update for Default-Start endpoint
  11. */
  12. /**
  13. * Home-Show : This endpoint is called when a shopper navigates to the home page
  14. * @name Base/Home-Show
  15. * @function
  16. * @memberof Home
  17. * @param {middleware} - consentTracking.consent
  18. * @param {middleware} - cache.applyDefaultCache
  19. * @param {category} - non-sensitive
  20. * @param {renders} - isml
  21. * @param {serverfunction} - get
  22. */
  23. server.get('Show', consentTracking.consent, cache.applyDefaultCache, function (req, res, next) {
  24. var Site = require('dw/system/Site');
  25. var pageMetaHelper = require('*/cartridge/scripts/helpers/pageMetaHelper');
  26. pageMetaHelper.setPageMetaTags(req.pageMetaData, Site.current);
  27. res.render('/home/homePage');
  28. next();
  29. }, pageMetaData.computedPageMetaData);
  30. server.get('ErrorNotFound', function (req, res, next) {
  31. res.setStatusCode(404);
  32. res.render('error/notFound');
  33. next();
  34. });
  35. module.exports = server.exports();