Skip to content

Commit

Permalink
add document id and total to API
Browse files Browse the repository at this point in the history
review suggestions
  • Loading branch information
ashokaditya committed Jun 9, 2021
1 parent bfc8e96 commit 4f7d18b
Showing 1 changed file with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,16 @@ export const actionsLogRequestHandler = (
}

return res.ok({
body: result.body.hits.hits.map((e) => {
const type = /^.fleet-actions-\d+$/.test(e._index) ? 'action' : 'response';
return { type, item: e._source };
}),
body: {
total:
typeof result.body.hits.total === 'number'
? result.body.hits.total
: result.body.hits.total.value,
items: result.body.hits.hits.map((e) => ({
type: e._index.startsWith('.fleet-actions') ? 'action' : 'response',
item: { id: e._id, data: e._source },
})),
},
});
};
};

0 comments on commit 4f7d18b

Please sign in to comment.