tasks: refactor listByTypePaged into list with options

this way we can list by prefix (coming commit)
This commit is contained in:
Girish Ramakrishnan
2025-10-06 19:28:47 +02:00
parent d010330b58
commit b21d29098b
3 changed files with 11 additions and 11 deletions
+2 -2
View File
@@ -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) }));