justinhelmer
2/12/2018 - 7:14 PM

test.js

app.get('/test/product/*', [
  getProduct, // populates req.locals.productResponse

  (req, res, next) => {
    const productResponse = req.locals.productResponse; // comes from get-product middleware
    let partial;
    
    req.locals.context['product-details-feature'] = Object.assign({
      layout: 'product',
      uiBootstrap: JSON.stringify(Object.assign({ properties }, req.locals.productResponse || {})),
      partial: productResponse ? 'product-details-feature/main' : 'product-details-feature/product-not-found',
    }, productResponse || {}),
    
    if (productResponse) {
      next();
    } else {
      res.sendStatus(500);
    }
  },
]);