tasks: add route to list tasks

This commit is contained in:
Girish Ramakrishnan
2018-12-08 20:12:23 -08:00
parent d8225ad653
commit 8502bf4bfa
5 changed files with 92 additions and 4 deletions

View File

@@ -3,6 +3,7 @@
exports = module.exports = {
get: get,
update: update,
listPaged: listPaged,
startTask: startTask,
stopTask: stopTask,
@@ -170,3 +171,16 @@ function stopTask(id, auditSource, callback) {
callback(null);
}
function listPaged(type, page, perPage, callback) {
assert(typeof type === 'string' || type === null);
assert.strictEqual(typeof page, 'number');
assert.strictEqual(typeof perPage, 'number');
assert.strictEqual(typeof callback, 'function');
taskdb.listPaged(type, page, perPage, function (error, tasks) {
if (error) return callback(new TaskError(TaskError.INTERNAL_ERROR, error));
callback(null, tasks);
});
}