amphora 8.4.2-dev.9.0 → 8.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/render.js CHANGED
@@ -123,16 +123,10 @@ function renderPage(uri, req, res, hrStart) {
123
123
  locals.query = req.query;
124
124
  locals.extension = extension;
125
125
 
126
- log('INFO', '====INSIDE RENDER PAGE', { url: _.get(res, 'locals.url'), hostname: req.hostname });
127
-
128
126
  // look up page alias' component instance
129
127
  return getDBObject(uri)
130
- .then(() => {
131
- log('INFO', '====getdboject RESPONSE', { uri });
132
- return formDataFromLayout(locals, uri)
133
- })
128
+ .then(formDataFromLayout(locals, uri))
134
129
  .then(data => {
135
- log('INFO', '====formDataFromLayout RESPONSE', { data });
136
130
  logTime(hrStart, uri);
137
131
  return data;
138
132
  })
package/lib/responses.js CHANGED
@@ -364,7 +364,6 @@ function explicitError(err, res) {
364
364
  */
365
365
  function handleError(res) {
366
366
  return function (err) {
367
- log('INFO', '====handleError function RESPONSE', { res, err });
368
367
  if (err.status && err.name !== 'NotFoundError') {
369
368
  // If we're in this block, the error has a defined `status` property and
370
369
  // the error should be directed out immediately
package/lib/routes.js CHANGED
@@ -62,28 +62,23 @@ function addUri(req, res, next) {
62
62
  * @param {express.Router} router
63
63
  */
64
64
  function addControllerRoutes(router) {
65
- try {
66
- // load all controller routers
67
- _.each(reservedRoutes, routeName => {
68
- log('info', 'SETTING RESERVED ROUTES', { reservedRouteName: routeName });
69
- let pathRouter,
70
- filename = routeName + '.js',
71
- controller = files.tryRequire([__dirname, routesPath, filename].join(path.sep));
65
+ // load all controller routers
66
+ _.each(reservedRoutes, routeName => {
67
+ let pathRouter,
68
+ filename = routeName + '.js',
69
+ controller = files.tryRequire([__dirname, routesPath, filename].join(path.sep));
72
70
 
73
- // we're okay with an error occurring here because it means we're missing something important in a route
74
- pathRouter = express.Router();
71
+ // we're okay with an error occurring here because it means we're missing something important in a route
72
+ pathRouter = express.Router();
75
73
 
76
- // assume json or text for anything in request bodies
77
- pathRouter.use(require('body-parser').json({ strict: true, type: 'application/json', limit: '50mb' }));
78
- pathRouter.use(require('body-parser').text({ type: 'text/*' }));
74
+ // assume json or text for anything in request bodies
75
+ pathRouter.use(require('body-parser').json({ strict: true, type: 'application/json', limit: '50mb' }));
76
+ pathRouter.use(require('body-parser').text({ type: 'text/*' }));
79
77
 
80
- controller(pathRouter);
78
+ controller(pathRouter);
81
79
 
82
- router.use(`/${routeName}`, pathRouter);
83
- });
84
- } catch (error) {
85
- log('error', 'CATCH CONTROLLER ROUTES', { error });
86
- }
80
+ router.use(`/${routeName}`, pathRouter);
81
+ });
87
82
  }
88
83
 
89
84
  /**
@@ -127,7 +122,6 @@ function addCORS(site) {
127
122
  }
128
123
 
129
124
  function setRoutes(controller, router, site) {
130
- log('info', 'SET ROUTES: ', { site });
131
125
  if (_.isFunction(controller.legacyController)) {
132
126
  controller.legacyController(router, render, site);
133
127
  }
@@ -55,7 +55,7 @@ function composePage(pageData, locals) {
55
55
  const layoutReference = pageData.layout,
56
56
  pageDataNoConf = references.omitPageConfiguration(pageData);
57
57
 
58
- return components.get(layoutReference)
58
+ return components.get(layoutReference, locals)
59
59
  .then(layoutData => mapLayoutToPageData(pageDataNoConf, layoutData))
60
60
  .then(fullData => resolveComponentReferences(fullData, locals));
61
61
  }
@@ -189,6 +189,10 @@ function upgradeData(schemaVersion, dataVersion, ref, data, locals) {
189
189
  * @return {Promise}
190
190
  */
191
191
  function checkForUpgrade(ref, data, locals) {
192
+ if (locals && locals.disableUpgrades) {
193
+ return bluebird.resolve(data);
194
+ }
195
+
192
196
  return utils.getSchema(ref)
193
197
  .then(schema => {
194
198
  // If version does not match what's in the data
@@ -77,6 +77,19 @@ describe(_.startCase(filename), function () {
77
77
  expect(lib.upgradeData.calledOnce).to.be.true;
78
78
  });
79
79
  });
80
+
81
+ it('does not call upgradeData or getSchema if locals.disableUpgrades is true', function () {
82
+ let locals = {disableUpgrades: true};
83
+
84
+ sandbox.stub(lib, 'upgradeData');
85
+
86
+ return fn('site/_components/foo/instances/bar', {_version: 1, value: 'bar'}, locals)
87
+ .then(function () {
88
+ expect(lib.upgradeData.calledOnce).to.be.false;
89
+ expect(utils.getSchema.calledOnce).to.be.false;
90
+ });
91
+ });
92
+
80
93
  });
81
94
 
82
95
  describe('upgradeData', function () {
package/lib/setup.js CHANGED
@@ -42,8 +42,6 @@ module.exports = function (options = {}) {
42
42
  eventBus = false
43
43
  } = options, router;
44
44
 
45
- log('info', 'Testing logs setup line 45');
46
-
47
45
  if (sessionStore) {
48
46
  log('warn', 'Support for sessionStore will be dropped in Amphora v8');
49
47
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "amphora",
3
- "version": "8.4.2-dev.9.0",
3
+ "version": "8.6.0",
4
4
  "description": "An API mixin for Express that saves, publishes and composes data with the key-value store of your choice.",
5
5
  "main": "index.js",
6
6
  "scripts": {