🪛 Data transferring over sockets!

This commit is contained in:
2021-05-27 15:50:10 -07:00
parent ef4e1f75b0
commit 0aea022208
5 changed files with 268 additions and 448 deletions

View File

@@ -1,33 +1,8 @@
"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 { map, flatten, isUndefined } from "lodash";
import {
extractArchive,
getCovers,
walkFolder,
} from "../utils/uncompression.utils";
import {
IExtractionOptions,
IExtractedComicBookCoverFile,
IFolderData,
} 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";
const JsonStreamStringify = require("json-stream-stringify");
const IO = require("socket.io")();
const { chain } = require("stream-chain");
const { parser } = require("stream-json");
const { pick } = require("stream-json/filters/Pick");
const { ignore } = require("stream-json/filters/Ignore");
const { streamValues } = require("stream-json/streamers/StreamValues");
const StreamArray = require("stream-json/streamers/StreamArray");
import { walkFolder } from "../utils/uncompression.utils";
export default class ProductsService extends Service {
// @ts-ignore
@@ -66,57 +41,6 @@ export default class ProductsService extends Service {
);
},
},
// getComicCovers: {
// rest: "POST /getComicCovers",
// params: {
// extractionOptions: "object",
// walkedFolders: "array",
// },
// async handler(
// ctx: Context<{
// extractionOptions: IExtractionOptions;
// walkedFolders: IFolderData[];
// }>
// ) {
// switch (
// ctx.params.extractionOptions.extractionMode
// ) {
// case "bulk":
// map(
// ctx.params.walkedFolders,
// async (folder, idx) => {
// let foo = await extractArchive(
// ctx.params
// .extractionOptions,
// folder
// );
// // console.log("levar", foo);
// let jsonStream =
// new JsonStreamStringify({
// foo,
// });
// return jsonStream;
// }
// );
//
// case "single":
// return await extractArchive(
// ctx.params.extractionOptions,
// ctx.params.walkedFolders[0]
// );
// default:
// console.log(
// "Unknown extraction mode selected."
// );
// return {
// message:
// "Unknown extraction mode selected.",
// errorCode: "90",
// data: `${ctx.params.extractionOptions}`,
// };
// }
// },
// },
},
methods: {},
},