test stream-json
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
ale 2024-09-28 02:15:08 +02:00
parent a0cb8a891a
commit 7a17c28735
3 changed files with 15 additions and 6 deletions

View File

@ -1,14 +1,14 @@
version: '3'
services: services:
fediblock-instance: fediblock-instance:
# image: registry.gitlab.com/manalejandro/fediblock-instance/fediblock-instance:latest
image: fediblock-instance image: fediblock-instance
build: . build: .
hostname: fediblock-instance hostname: fediblock-instance
container_name: fediblock-instance container_name: fediblock-instance
restart: always restart: always
user: node user: node
cpus: "0.5"
mem_limit: "1g"
memswap_limit: "1g"
ports: ports:
- "4000:4000" - "4000:4000"
depends_on: depends_on:

View File

@ -3,6 +3,9 @@ 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'),
{ chain } = require('stream-chain'),
clean = str => { clean = str => {
return str.replace(/[/\\^$+?()`'¡¿¨!"·%&=;,\|\[\]{}]+/gmi, '') return str.replace(/[/\\^$+?()`'¡¿¨!"·%&=;,\|\[\]{}]+/gmi, '')
} }
@ -508,8 +511,13 @@ module.exports = (app, client) => {
query: { query: {
match_all: {} match_all: {}
} }
}, { asStream: true, meta: false }) }, { asStream: true, meta: false }),
result.pipe(zlib.createGzip()).pipe(res, { end: true }) pipeline = chain([
Pick.withParser({ filter: 'hits.hits' }),
streamArray(),
Pick.withParser({ filter: '_source' }),
])
result.pipe(pipeline).pipe(zlib.createGzip()).pipe(res, { end: true })
} catch (e) { } catch (e) {
console.error(e) console.error(e)
res.status(404).end() res.status(404).end()

View File

@ -9,7 +9,7 @@
}, },
"license": "MIT", "license": "MIT",
"scripts": { "scripts": {
"start": "rm -f core && node --max-old-space-size=1024 server.js", "start": "rm -f core && node server.js",
"build": "rm -rf dist/* && parcel build public/index.html --no-source-maps --dist-dir dist/", "build": "rm -rf dist/* && parcel build public/index.html --no-source-maps --dist-dir dist/",
"install": "cd node_modules && rm -rf http-signature && rm -rf request/node_modules/http-signature && mv @peertube/http-signature ." "install": "cd node_modules && rm -rf http-signature && rm -rf request/node_modules/http-signature && mv @peertube/http-signature ."
}, },
@ -25,6 +25,7 @@
"node-schedule": "^2.1.1", "node-schedule": "^2.1.1",
"parcel": "^2.12.0", "parcel": "^2.12.0",
"rotating-file-stream": "^3.2.5", "rotating-file-stream": "^3.2.5",
"stream-json": "^1.8.0",
"swagger-jsdoc": "^6.2.8", "swagger-jsdoc": "^6.2.8",
"swagger-ui-express": "^5.0.1" "swagger-ui-express": "^5.0.1"
} }