gzip download
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
ale 2024-09-22 06:53:35 +02:00
parent 3cf8f296cd
commit 8356295433

View File

@ -500,18 +500,15 @@ module.exports = (app, client) => {
*/
app.use('/api/download_index', async (req, res) => {
try {
res.writeHead(200, {
'Content-Type': 'application/x-gzip',
'Content-disposition': 'attachment; filename=fediblock-index.json.gz'
})
const result = await client.search({
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 })
result.pipe(zlib.createGzip()).pipe(res, { end: true })
}, { asStream: true })).pipe(zlib.createGzip()).pipe(res, { end: true })
} catch (e) {
console.error(e)
res.status(404).end()