pipeline parser
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
ale 2024-09-28 02:59:28 +02:00
parent 7a17c28735
commit 597c7ba005
2 changed files with 14 additions and 9 deletions

View File

@ -3,8 +3,8 @@ const nodeinfo = require('activitypub-express/pub/nodeinfo')
module.exports = (app, client) => { module.exports = (app, client) => {
const constant = require('./constant'), const constant = require('./constant'),
zlib = require('zlib'), zlib = require('zlib'),
Pick = require('stream-json/filters/Pick'), StreamArray = require('stream-json/streamers/StreamArray'),
{ streamArray } = require('stream-json/streamers/StreamArray'), { parser } = require('stream-json'),
{ chain } = require('stream-chain'), { chain } = require('stream-chain'),
clean = str => { clean = str => {
return str.replace(/[/\\^$+?()`'¡¿¨!"·%&=;,\|\[\]{}]+/gmi, '') return str.replace(/[/\\^$+?()`'¡¿¨!"·%&=;,\|\[\]{}]+/gmi, '')
@ -513,11 +513,13 @@ module.exports = (app, client) => {
} }
}, { asStream: true, meta: false }), }, { asStream: true, meta: false }),
pipeline = chain([ pipeline = chain([
Pick.withParser({ filter: 'hits.hits' }), parser(),
streamArray(), data => data.value.hits.hits,
Pick.withParser({ filter: '_source' }), StreamArray.withParser(),
data => data.value._source,
zlib.createGzip()
]) ])
result.pipe(pipeline).pipe(zlib.createGzip()).pipe(res, { end: true }) result.pipe(pipeline).pipe(res)
} catch (e) { } catch (e) {
console.error(e) console.error(e)
res.status(404).end() res.status(404).end()

View File

@ -31,9 +31,12 @@
<h3>Search in <a href="/api/stats" target="_blank"><span id="count"></span></a> public instances<span id="apigit"> - <h3>Search in <a href="/api/stats" target="_blank"><span id="count"></span></a> public instances<span id="apigit"> -
<a href="api-docs" target="_blank">API docs</a> - <a <a href="api-docs" target="_blank">API docs</a> - <a
href="https://git.manalejandro.com/ale/fediblock-instance" target="_blank">Git</a> href="https://git.manalejandro.com/ale/fediblock-instance" target="_blank">Git</a>
<img <a href="https://sonar.manalejandro.com/dashboard?id=ale%3Afediblock-instance">
src="https://sonar.manalejandro.com/api/project_badges/measure?project=ale%3Afediblock-instance&metric=alert_status&token=sqb_b85f22162c314a3c5d781cf356e90ce304ce6a13" /> <img
<img src="https://drone.manalejandro.com/api/badges/ale/fediblock-instance/status.svg" /></span></h3> src="https://sonar.manalejandro.com/api/project_badges/measure?project=ale%3Afediblock-instance&metric=alert_status&token=sqb_b85f22162c314a3c5d781cf356e90ce304ce6a13" />
</a><a href="https://drone.manalejandro.com/ale/fediblock-instance">
<img src="https://drone.manalejandro.com/api/badges/ale/fediblock-instance/status.svg" />
</a></span></h3>
<section> <section>
<input type="text" id="instance" name="instance" placeholder="Type the name of the instance" /> <input type="text" id="instance" name="instance" placeholder="Type the name of the instance" />
<button id="reverse" title="Reverse search...">Reverse</button> <button id="reverse" title="Reverse search...">Reverse</button>