nooline/nooline

View on GitHub
routes/error-404.js

Summary

Maintainability
A
1 hr
Test Coverage

/**
 * @route error404
 * Render out an error for any 404 the client might have hit.
 *
 * @param {Object}  error   The error object generated by the server.
 * @param {Object}  info    Contains information relevant to the template.
 */
module.exports = function error404 (error, info) {

  console.error(error);

  // TODO: These options, particularly the partials and startPath,
  // need to get pulled in from a config file.
  info.res.status(404).render('common/views/error', {
    status: 404,
    message: info.errorMessage,
    redirect: info.domain,
    port: info.nooline.settings.prettyport,
    error: info.errorDetail,
    currentYear: new Date().getFullYear(),
    startPath: '/common/js/nooline/start',
    partials: {
      'head': '../../sites/'
        + info.nooline.settings.redirect
        + '/views/partials/head',
      'global-header': '../../sites/'
        + info.nooline.settings.redirect
        + '/views/partials/global-header',
      'meta': '../../sites/'
        + info.nooline.settings.redirect
        + '/views/partials/meta',
      'global-footer': '../../sites/'
        + info.nooline.settings.redirect
        + '/views/partials/global-footer',
      'global-scripts': '../../sites/'
        + info.nooline.settings.redirect
        + '/views/partials/global-scripts'
    }
  });
};