diff --git a/lib/apiswagger.js b/lib/apiswagger.js index 8efe53c..d6f3cb3 100644 --- a/lib/apiswagger.js +++ b/lib/apiswagger.js @@ -504,7 +504,7 @@ module.exports = (app, client) => { app.use('/api/download_index', async (req, res) => { try { res.setHeader('Content-Type', 'application/x-gzip') - res.setHeader('Content-disposition', 'attachment; filename=fediblock-index.json.gz') + res.setHeader('Content-disposition', 'attachment; filename=fediblock-index.jsonl.gz') const result = await client.search({ index: constant.index, size: 9999, @@ -516,15 +516,18 @@ module.exports = (app, client) => { result, parser(), streamValues(), - data => [data.value.hits.hits.map(hit => ({ - instance: hit._source.instance, - blocks: hit._source.blocks, - api: hit._source.api, - last: hit._source.last, - nodeinfo: hit._source.nodeinfo - }))], - zlib.createGzip() - ]).pipe(res, { end: true }) + data => data.value.hits.hits, + streamArray(), + data => ({ + instance: data.value._source.instance, + blocks: data.value._source.blocks, + api: data.value._source.api, + last: data.value._source.last, + nodeinfo: data.value._source.nodeinfo + }), + zlib.createGzip(), + res + ]) } catch (e) { console.error(e) res.status(404).end() diff --git a/public/main.js b/public/main.js index be2928c..531eab5 100644 --- a/public/main.js +++ b/public/main.js @@ -115,7 +115,7 @@ document.addEventListener('DOMContentLoaded', function () { fetch('/api/download_index', { signal: ac.signal }).then(async function (result) { var res = await result.blob(), a = document.createElement('a') - a.download = 'fediblock-index.json.gz' + a.download = 'fediblock-index.jsonl.gz' a.href = URL.createObjectURL(res) a.type = 'application/x-gzip' a.target = '_blank'