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:
@@ -25,7 +25,7 @@ async function load(req, res, next) {
|
||||
if (error) return next(BoxError.toHttpError(error));
|
||||
if (!result) return next(new HttpError(404, 'Applink not found'));
|
||||
|
||||
req.resource = result;
|
||||
req.resources.applink = result;
|
||||
|
||||
next();
|
||||
}
|
||||
@@ -63,9 +63,9 @@ async function get(req, res, next) {
|
||||
assert.strictEqual(typeof req.params.id, 'string');
|
||||
|
||||
// we have a separate route for this
|
||||
delete req.resource.icon;
|
||||
delete req.resources.applink.icon;
|
||||
|
||||
next(new HttpSuccess(200, req.resource));
|
||||
next(new HttpSuccess(200, req.resources.applink));
|
||||
}
|
||||
|
||||
async function update(req, res, next) {
|
||||
@@ -78,7 +78,7 @@ async function update(req, res, next) {
|
||||
if ('tags' in req.body && !Array.isArray(req.body.tags)) return next(new HttpError(400, 'tags must be an array with strings'));
|
||||
if ('icon' in req.body && typeof req.body.icon !== 'string') return next(new HttpError(400, 'icon must be a string'));
|
||||
|
||||
const [error] = await safe(applinks.update(req.resource, req.body));
|
||||
const [error] = await safe(applinks.update(req.resources.applink, req.body));
|
||||
if (error) return next(BoxError.toHttpError(error));
|
||||
|
||||
next(new HttpSuccess(200, {}));
|
||||
@@ -87,14 +87,14 @@ async function update(req, res, next) {
|
||||
async function del(req, res, next) {
|
||||
assert.strictEqual(typeof req.params.id, 'string');
|
||||
|
||||
const [error] = await safe(applinks.del(req.resource));
|
||||
const [error] = await safe(applinks.del(req.resources.applink));
|
||||
if (error) return next(BoxError.toHttpError(error));
|
||||
|
||||
next(new HttpSuccess(204));
|
||||
}
|
||||
|
||||
async function getIcon(req, res, next) {
|
||||
async function getIcon(req, res) {
|
||||
assert.strictEqual(typeof req.params.id, 'string');
|
||||
|
||||
res.send(req.resource.icon);
|
||||
res.send(req.resources.applink.icon);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user