Streaming JSON WIP
This commit is contained in:
11414
package-lock.json
generated
11414
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -18,6 +18,7 @@
|
|||||||
"author": "",
|
"author": "",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/lodash": "^4.14.168",
|
"@types/lodash": "^4.14.168",
|
||||||
|
"@types/oboe": "^2.1.0",
|
||||||
"@types/unzipper": "^0.10.3",
|
"@types/unzipper": "^0.10.3",
|
||||||
"@typescript-eslint/eslint-plugin": "^2.26.0",
|
"@typescript-eslint/eslint-plugin": "^2.26.0",
|
||||||
"@typescript-eslint/parser": "^2.26.0",
|
"@typescript-eslint/parser": "^2.26.0",
|
||||||
|
|||||||
@@ -1,11 +1,9 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
import { Context, Service, ServiceBroker, ServiceSchema } from "moleculer";
|
import { Context, Service, ServiceBroker, ServiceSchema } from "moleculer";
|
||||||
|
import fs from "fs";
|
||||||
import { DbMixin } from "../mixins/db.mixin";
|
import { DbMixin } from "../mixins/db.mixin";
|
||||||
import Comic from "../models/comic.model";
|
import Comic from "../models/comic.model";
|
||||||
import {
|
import { walkFolder, getCovers } from "../utils/uncompression.utils";
|
||||||
walkFolder,
|
|
||||||
getCovers,
|
|
||||||
} from "../utils/uncompression.utils";
|
|
||||||
import {
|
import {
|
||||||
IExtractionOptions,
|
IExtractionOptions,
|
||||||
IFolderData,
|
IFolderData,
|
||||||
@@ -19,7 +17,10 @@ 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<{}> = { name: "import" }
|
||||||
|
) {
|
||||||
super(broker);
|
super(broker);
|
||||||
this.parseServiceSchema(
|
this.parseServiceSchema(
|
||||||
Service.mergeSchemas(
|
Service.mergeSchemas(
|
||||||
@@ -43,16 +44,19 @@ export default class ProductsService extends Service {
|
|||||||
params: {
|
params: {
|
||||||
basePathToWalk: "string",
|
basePathToWalk: "string",
|
||||||
},
|
},
|
||||||
async handler(ctx: Context<{ basePathToWalk: string}>) {
|
async handler(
|
||||||
return await walkFolder(ctx.params.basePathToWalk);
|
ctx: Context<{ basePathToWalk: string }>
|
||||||
}
|
) {
|
||||||
|
return await walkFolder(
|
||||||
|
ctx.params.basePathToWalk
|
||||||
|
);
|
||||||
|
},
|
||||||
},
|
},
|
||||||
getComicCovers: {
|
getComicCovers: {
|
||||||
rest: "POST /getComicCovers",
|
rest: "POST /getComicCovers",
|
||||||
params: {
|
params: {
|
||||||
extractionOptions: "object",
|
extractionOptions: "object",
|
||||||
walkedFolders: "array",
|
walkedFolders: "array",
|
||||||
|
|
||||||
},
|
},
|
||||||
async handler(
|
async handler(
|
||||||
ctx: Context<{
|
ctx: Context<{
|
||||||
@@ -60,12 +64,14 @@ export default class ProductsService extends Service {
|
|||||||
walkedFolders: IFolderData[];
|
walkedFolders: IFolderData[];
|
||||||
}>
|
}>
|
||||||
) {
|
) {
|
||||||
const comicBookCoversData = await getCovers(
|
const readStream = fs.createReadStream(
|
||||||
|
"./userdata/comicBooksForImport.js"
|
||||||
|
);
|
||||||
|
const comicBooksForImport = await getCovers(
|
||||||
ctx.params.extractionOptions,
|
ctx.params.extractionOptions,
|
||||||
ctx.params.walkedFolders
|
ctx.params.walkedFolders
|
||||||
);
|
);
|
||||||
const foo = H(comicBookCoversData)
|
readStream.pipe(comicBooksForImport);
|
||||||
return foo;
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user