This commit is contained in:
parent
832ae9ea34
commit
1fcadc150d
@ -5,6 +5,7 @@ module.exports = (app, client) => {
|
||||
{ parser } = require('stream-json'),
|
||||
{ streamArray } = require('stream-json/streamers/StreamArray'),
|
||||
{ chain } = require('stream-chain'),
|
||||
{ stringer } = require('stream-json/jsonl/Stringer'),
|
||||
clean = str => {
|
||||
return str.replace(/[/\\^$+?()`'¡¿¨!"·%&=;,\|\[\]{}]+/gmi, '')
|
||||
}
|
||||
@ -472,9 +473,12 @@ module.exports = (app, client) => {
|
||||
parser(),
|
||||
pick({ filter: 'hits.hits' }),
|
||||
streamArray(),
|
||||
data => ({ instance: data.value._source.instance, comment: data.value._source.blocks.find(block => block.domain === clean(req.params.instance)).comment })
|
||||
data => ({ instance: data.value._source.instance, comment: data.value._source.blocks.find(block => block.domain === clean(req.params.instance)).comment }),
|
||||
stringer()
|
||||
])
|
||||
result.pipe(pipeline).pipe(res, { end: true })
|
||||
res.once('data', data => '[' + data.toString())
|
||||
res.on('finish', () => res.end(']'))
|
||||
result.pipe(pipeline).pipe(res)
|
||||
} else {
|
||||
res.status(404).end()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user