From bc52c4b8ccad423c8ee9804526774256005d7b3a Mon Sep 17 00:00:00 2001 From: ale Date: Sun, 22 Sep 2024 07:17:46 +0200 Subject: [PATCH] gzip download --- lib/apiswagger.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/lib/apiswagger.js b/lib/apiswagger.js index 373d4ed..d8f7c7e 100644 --- a/lib/apiswagger.js +++ b/lib/apiswagger.js @@ -502,13 +502,14 @@ module.exports = (app, client) => { try { res.header('Content-Type', 'application/x-gzip') res.header('Content-disposition', 'attachment; filename=fediblock-index.json.gz') - (await client.search({ - index: constant.index, - size: 9999, - query: { - match_all: {} - } - }, { asStream: true })).pipe(zlib.createGzip()).pipe(res, { end: true }) + const result = await client.search({ + index: constant.index, + size: 9999, + query: { + match_all: {} + } + }, { asStream: true }) + result.pipe(zlib.createGzip()).pipe(res, { end: true }) } catch (e) { console.error(e) res.status(404).end()