Streaming JSON WIP

This commit is contained in:
2021-05-13 10:31:33 -07:00
parent 51206db9c2
commit e017028610
3 changed files with 37 additions and 11408 deletions

11414
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -18,6 +18,7 @@
"author": "",
"devDependencies": {
"@types/lodash": "^4.14.168",
"@types/oboe": "^2.1.0",
"@types/unzipper": "^0.10.3",
"@typescript-eslint/eslint-plugin": "^2.26.0",
"@typescript-eslint/parser": "^2.26.0",

View File

@@ -1,11 +1,9 @@
"use strict";
import { Context, Service, ServiceBroker, ServiceSchema } from "moleculer";
import fs from "fs";
import { DbMixin } from "../mixins/db.mixin";
import Comic from "../models/comic.model";
import {
walkFolder,
getCovers,
} from "../utils/uncompression.utils";
import { walkFolder, getCovers } from "../utils/uncompression.utils";
import {
IExtractionOptions,
IFolderData,
@@ -19,7 +17,10 @@ import { stringify } from "highland-json";
export default class ProductsService extends Service {
// @ts-ignore
public constructor(public broker: ServiceBroker, schema: ServiceSchema<{}> = {}) {
public constructor(
public broker: ServiceBroker,
schema: ServiceSchema<{}> = { name: "import" }
) {
super(broker);
this.parseServiceSchema(
Service.mergeSchemas(
@@ -43,16 +44,19 @@ export default class ProductsService extends Service {
params: {
basePathToWalk: "string",
},
async handler(ctx: Context<{ basePathToWalk: string}>) {
return await walkFolder(ctx.params.basePathToWalk);
}
async handler(
ctx: Context<{ basePathToWalk: string }>
) {
return await walkFolder(
ctx.params.basePathToWalk
);
},
},
getComicCovers: {
rest: "POST /getComicCovers",
params: {
extractionOptions: "object",
walkedFolders: "array",
},
async handler(
ctx: Context<{
@@ -60,12 +64,14 @@ export default class ProductsService extends Service {
walkedFolders: IFolderData[];
}>
) {
const comicBookCoversData = await getCovers(
const readStream = fs.createReadStream(
"./userdata/comicBooksForImport.js"
);
const comicBooksForImport = await getCovers(
ctx.params.extractionOptions,
ctx.params.walkedFolders
);
const foo = H(comicBookCoversData)
return foo;
readStream.pipe(comicBooksForImport);
},
},
},