From 6caf3d6d406f799314f52816a42973328eab71f7 Mon Sep 17 00:00:00 2001 From: ale Date: Mon, 14 Oct 2024 01:10:36 +0200 Subject: [PATCH] stream-json --- lib/apiswagger.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/lib/apiswagger.js b/lib/apiswagger.js index 42a147e..d8cd8dd 100644 --- a/lib/apiswagger.js +++ b/lib/apiswagger.js @@ -481,20 +481,21 @@ module.exports = (app, client) => { parser(), pick({ filter: 'hits.hits' }), streamArray(), - data => { - block_count++ - instancescomment.push({ - instance: data.value._source.instance, comment: data.value._source.blocks.find(block => block.domain === clean(req.params.instance)).comment - }) - } + data => data.value._source ]) - result.pipe(pipeline) + pipeline.on('data', data => { + block_count++ + instancescomment.push({ + instance: data.instance, comment: data.blocks.find(block => block.domain === clean(req.params.instance)).comment + }) + }) pipeline.on('end', () => { res.json({ block_count, instances: instancescomment }) }) + result.pipe(pipeline) } else { res.status(404).end() }