amphora 8.4.2-dev.9.0 → 8.5.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 +1 -7
- package/lib/responses.js +0 -1
- package/lib/routes.js +13 -19
- package/lib/services/upgrade.js +4 -0
- package/lib/services/upgrade.test.js +13 -0
- package/lib/setup.js +0 -2
- package/package.json +1 -1
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
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
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
|
-
|
|
74
|
-
|
|
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
|
-
|
|
77
|
-
|
|
78
|
-
|
|
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
|
-
|
|
78
|
+
controller(pathRouter);
|
|
81
79
|
|
|
82
|
-
|
|
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
|
}
|
package/lib/services/upgrade.js
CHANGED
|
@@ -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