Use concrete resource name instead of generic "resource"

This commit is contained in:
Girish Ramakrishnan
2021-09-20 22:39:35 -07:00
parent d1e8fded65
commit 0cfc3e03bb
4 changed files with 85 additions and 85 deletions
+5 -5
View File
@@ -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, {}));
}