not-found.js 420 B

12345678910111213141516171819202122
  1. 'use strict';
  2. const Watch = require('../models/Watch');
  3. /**
  4. * Resolve 404 with 2 last uploaded productions
  5. */
  6. module.exports = (req, res) => {
  7. Watch.find({ }, null, {sort: '-year'}, function(err, watches){
  8. let options = {
  9. title: 'Ops, não encontramos o que você procura',
  10. watches: []
  11. }
  12. if (watches) {
  13. options.watches = watches
  14. }
  15. res.status(404).render('error/404', options);
  16. }).limit(4);
  17. };