amphora 8.4.2-dev.8.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/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/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