From 54dc49d0554781d8d9545e82b0628f68f2502fe9 Mon Sep 17 00:00:00 2001 From: ale Date: Sat, 28 Sep 2024 04:58:38 +0200 Subject: [PATCH] playing stream-json --- lib/apiswagger.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/apiswagger.js b/lib/apiswagger.js index c77c6b0..0422a15 100644 --- a/lib/apiswagger.js +++ b/lib/apiswagger.js @@ -3,8 +3,8 @@ const nodeinfo = require('activitypub-express/pub/nodeinfo') module.exports = (app, client) => { const constant = require('./constant'), zlib = require('zlib'), - StreamArray = require('stream-json/streamers/StreamArray'), - { parser } = require('stream-json'), + Pick = require('stream-json/filters/Pick'), + { streamArray } = require('stream-json/streamers/StreamArray'), { chain } = require('stream-chain'), clean = str => { return str.replace(/[/\\^$+?()`'¡¿¨!"·%&=;,\|\[\]{}]+/gmi, '') @@ -513,9 +513,8 @@ module.exports = (app, client) => { } }, { asStream: true, meta: false }), pipeline = chain([ - parser(), - data => data.value.hits.hits, - StreamArray.withParser(), + Pick.withParser({ filter: 'hits.hits' }), + streamArray(), data => data.value._source, zlib.createGzip() ])