Adding streaming JSON support to endpoint

This commit is contained in:
2021-05-11 22:07:14 -07:00
parent 6c12700957
commit aa9927d5c5
3 changed files with 87 additions and 11880 deletions

11950
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -36,7 +36,10 @@
"@types/mkdirp": "^1.0.0", "@types/mkdirp": "^1.0.0",
"@types/node": "^13.9.8", "@types/node": "^13.9.8",
"@types/pino": "^6.3.8", "@types/pino": "^6.3.8",
"axios": "^0.21.1",
"fs-extra": "^10.0.0", "fs-extra": "^10.0.0",
"highland": "^2.13.5",
"highland-json": "^1.4.1",
"lodash": "^4.17.21", "lodash": "^4.17.21",
"moleculer": "^0.14.0", "moleculer": "^0.14.0",
"moleculer-db": "^0.8.4", "moleculer-db": "^0.8.4",
@@ -47,9 +50,11 @@
"mongoose-paginate": "^5.0.3", "mongoose-paginate": "^5.0.3",
"nats": "^1.3.2", "nats": "^1.3.2",
"node-unrar-js": "^1.0.2", "node-unrar-js": "^1.0.2",
"oboe": "^2.1.5",
"pino": "^6.11.3", "pino": "^6.11.3",
"pino-pretty": "^4.7.1", "pino-pretty": "^4.7.1",
"sharp": "^0.28.1", "sharp": "^0.28.1",
"through2": "^4.0.2",
"typescript": "^3.8.3", "typescript": "^3.8.3",
"unzipper": "^0.10.11" "unzipper": "^0.10.11"
}, },

View File

@@ -10,7 +10,12 @@ import {
IExtractionOptions, IExtractionOptions,
IFolderData, IFolderData,
} from "../interfaces/folder.interface"; } from "../interfaces/folder.interface";
import axios from "axios";
import { Readable } from "stream";
import through2 from "through2";
import oboe from "oboe";
import H from "highland";
import { stringify } from "highland-json";
export default class ProductsService extends Service { export default class ProductsService extends Service {
// @ts-ignore // @ts-ignore
public constructor(public broker: ServiceBroker, schema: ServiceSchema<{}> = {}) { public constructor(public broker: ServiceBroker, schema: ServiceSchema<{}> = {}) {
@@ -54,11 +59,12 @@ export default class ProductsService extends Service {
walkedFolders: IFolderData[]; walkedFolders: IFolderData[];
}> }>
) { ) {
return await getCovers( const comicBookCoversData = await getCovers(
ctx.params.extractionOptions, ctx.params.extractionOptions,
ctx.params.walkedFolders ctx.params.walkedFolders
); );
return H(comicBookCoversData)
.through(stringify);
}, },
}, },
}, },