Use concrete resource name instead of generic "resource"
This commit is contained in:
@@ -21,14 +21,14 @@ async function load(req, res, next) {
|
||||
if (error) return next(BoxError.toHttpError(error));
|
||||
if (!result) return next(new HttpError(404, 'Notification not found'));
|
||||
|
||||
req.resource = result;
|
||||
req.notification = result;
|
||||
next();
|
||||
}
|
||||
|
||||
function get(req, res, next) {
|
||||
assert.strictEqual(typeof req.resource, 'object');
|
||||
assert.strictEqual(typeof req.notification, 'object');
|
||||
|
||||
next(new HttpSuccess(200, req.resource));
|
||||
next(new HttpSuccess(200, req.notification));
|
||||
}
|
||||
|
||||
async function list(req, res, next) {
|
||||
@@ -49,12 +49,12 @@ async function list(req, res, next) {
|
||||
}
|
||||
|
||||
async function update(req, res, next) {
|
||||
assert.strictEqual(typeof req.resource, 'object');
|
||||
assert.strictEqual(typeof req.notification, 'object');
|
||||
assert.strictEqual(typeof req.body, 'object');
|
||||
|
||||
if (typeof req.body.acknowledged !== 'boolean') return next(new HttpError(400, 'acknowledged must be a booliean'));
|
||||
|
||||
const [error] = await safe(notifications.update(req.resource, { acknowledged: req.body.acknowledged }));
|
||||
const [error] = await safe(notifications.update(req.notification, { acknowledged: req.body.acknowledged }));
|
||||
if (error) return next(BoxError.toHttpError(error));
|
||||
next(new HttpSuccess(204, {}));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user