tasks: refactor listByTypePaged into list with options
this way we can list by prefix (coming commit)
This commit is contained in:
+2
-2
@@ -43,9 +43,9 @@ async function list(req, res, next) {
|
||||
const perPage = typeof req.query.per_page === 'string'? parseInt(req.query.per_page) : 25;
|
||||
if (!perPage || perPage < 0) return next(new HttpError(400, 'per_page query param has to be a postive number'));
|
||||
|
||||
if (req.query.type && typeof req.query.type !== 'string') return next(new HttpError(400, 'type must be a string'));
|
||||
if ('type' in req.query && typeof req.query.type !== 'string') return next(new HttpError(400, 'type must be a string'));
|
||||
|
||||
const [error, result] = await safe(tasks.listByTypePaged(req.query.type || null, page, perPage));
|
||||
const [error, result] = await safe(tasks.list(page, perPage, { type: req.query.type || null }));
|
||||
if (error) return next(BoxError.toHttpError(error));
|
||||
|
||||
next(new HttpSuccess(200, { tasks: result.map(tasks.removePrivateFields) }));
|
||||
|
||||
Reference in New Issue
Block a user