From 3cf8f296cd012e2883deb1edf934e508795f6075 Mon Sep 17 00:00:00 2001 From: ale Date: Sun, 22 Sep 2024 06:48:19 +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 be4ca3f..e7bc2a7 100644 --- a/lib/apiswagger.js +++ b/lib/apiswagger.js @@ -504,13 +504,14 @@ module.exports = (app, client) => { 'Content-Type': 'application/x-gzip', '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()