download index

This commit is contained in:
ale 2024-09-23 05:11:18 +02:00
parent 9f4c3aaa8a
commit 30cea142d1
2 changed files with 4 additions and 17 deletions

View File

@ -505,28 +505,15 @@ 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.jsonl.gz')
res.setHeader('Content-disposition', 'attachment; filename=fediblock-index.json.gz')
const result = await client.search({
index: constant.index,
size: 9999,
query: {
match_all: {}
}
}, { asStream: true })
result.pipe(chain([
parser(),
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
}),
stringer(),
zlib.createGzip()
])).pipe(res, { end: true })
}, { asStream: true, meta: false })
result.pipe(zlib.createGzip()).pipe(res, { end: true })
} catch (e) {
console.error(e)
res.status(404).end()

View File

@ -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.jsonl.gz'
a.download = 'fediblock-index.json.gz'
a.href = URL.createObjectURL(res)
a.type = 'application/x-gzip'
a.target = '_blank'