Start using req.resources = { app, volume, ...} pattern
Reason was that req.app was clashing with expressjs v5 which stores the main expressjs app object there
This commit is contained in:
@@ -26,7 +26,7 @@ async function load(req, res, next) {
|
||||
if (error) return next(BoxError.toHttpError(error));
|
||||
if (!result) return next(new HttpError(404, 'Backup not found'));
|
||||
|
||||
req.resource = result;
|
||||
req.resources.archive = result;
|
||||
|
||||
next();
|
||||
}
|
||||
@@ -47,12 +47,12 @@ async function list(req, res, next) {
|
||||
async function get(req, res, next) {
|
||||
assert.strictEqual(typeof req.params.id, 'string');
|
||||
|
||||
next(new HttpSuccess(200, req.resource));
|
||||
next(new HttpSuccess(200, req.resources.archive));
|
||||
}
|
||||
|
||||
async function getIcon(req, res, next) {
|
||||
assert.strictEqual(typeof req.params.id, 'string');
|
||||
assert.strictEqual(typeof req.resource, 'object');
|
||||
assert.strictEqual(typeof req.resources.archive, 'object');
|
||||
|
||||
const [error, icon] = await safe(archives.getIcon(req.params.id, { original: req.query.original }));
|
||||
if (error) return next(BoxError.toHttpError(error));
|
||||
@@ -62,9 +62,9 @@ async function getIcon(req, res, next) {
|
||||
|
||||
async function del(req, res, next) {
|
||||
assert.strictEqual(typeof req.params.id, 'string');
|
||||
assert.strictEqual(typeof req.resource, 'object');
|
||||
assert.strictEqual(typeof req.resources.archive, 'object');
|
||||
|
||||
const [error] = await safe(archives.del(req.resource, AuditSource.fromRequest(req)));
|
||||
const [error] = await safe(archives.del(req.resources.archive, AuditSource.fromRequest(req)));
|
||||
if (error) return next(BoxError.toHttpError(error));
|
||||
|
||||
next(new HttpSuccess(204));
|
||||
@@ -72,7 +72,7 @@ async function del(req, res, next) {
|
||||
|
||||
async function unarchive(req, res, next) {
|
||||
assert.strictEqual(typeof req.params.id, 'string');
|
||||
assert.strictEqual(typeof req.resource, 'object');
|
||||
assert.strictEqual(typeof req.resources.archive, 'object');
|
||||
assert.strictEqual(typeof req.body, 'object');
|
||||
|
||||
const data = req.body;
|
||||
@@ -89,7 +89,7 @@ async function unarchive(req, res, next) {
|
||||
if (Object.keys(data.secondaryDomains).some(function (key) { return typeof data.secondaryDomains[key].domain !== 'string' || typeof data.secondaryDomains[key].subdomain !== 'string'; })) return next(new HttpError(400, 'secondaryDomain object must contain domain and subdomain strings'));
|
||||
}
|
||||
|
||||
const [error, result] = await safe(apps.unarchive(req.resource, req.body, AuditSource.fromRequest(req)));
|
||||
const [error, result] = await safe(apps.unarchive(req.resources.archive, req.body, AuditSource.fromRequest(req)));
|
||||
if (error) return next(BoxError.toHttpError(error));
|
||||
|
||||
next(new HttpSuccess(202, { id: result.id, taskId: result.taskId }));
|
||||
|
||||
Reference in New Issue
Block a user