From d53ab0432ead8cfe5403542d26a2a2dc42466bd9 Mon Sep 17 00:00:00 2001 From: Rishi Ghan Date: Sun, 17 Apr 2022 19:38:31 -0700 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20Refactoring?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package-lock.json | 4 +--- package.json | 2 +- services/socket.service.ts | 2 +- utils/uncompression.utils.ts | 28 ++++++++++++++-------------- 4 files changed, 17 insertions(+), 19 deletions(-) diff --git a/package-lock.json b/package-lock.json index 59b8db6..f69103f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -35,6 +35,7 @@ "moleculer-db": "^0.8.17", "moleculer-db-adapter-mongo": "^0.4.7", "moleculer-db-adapter-mongoose": "^0.8.12", + "moleculer-io": "^2.0.0", "moleculer-web": "^0.10.4", "mongoosastic-ts": "^5.0.7", "mongoose": "^5.12.7", @@ -61,7 +62,6 @@ "install": "^0.13.0", "jest": "^27.2.5", "jest-cli": "^27.2.5", - "moleculer-io": "^2.0.0", "moleculer-repl": "^0.7.0", "npm": "^8.4.1", "ts-jest": "^25.3.0", @@ -9234,7 +9234,6 @@ "version": "2.0.0", "resolved": "https://registry.npmjs.org/moleculer-io/-/moleculer-io-2.0.0.tgz", "integrity": "sha512-de/t7cG5at5KYPiukkR+cEnZ0nb0xRmSHkCoLrd7mmHfNI8+FwoUbg1fE2+Yt5aoEnVhpvY7UE2x8qcBOT6T3w==", - "dev": true, "dependencies": { "kleur": "^4.1.4", "lodash": "^4.17.21", @@ -22359,7 +22358,6 @@ "version": "2.0.0", "resolved": "https://registry.npmjs.org/moleculer-io/-/moleculer-io-2.0.0.tgz", "integrity": "sha512-de/t7cG5at5KYPiukkR+cEnZ0nb0xRmSHkCoLrd7mmHfNI8+FwoUbg1fE2+Yt5aoEnVhpvY7UE2x8qcBOT6T3w==", - "dev": true, "requires": { "kleur": "^4.1.4", "lodash": "^4.17.21", diff --git a/package.json b/package.json index 0ba88a3..6550761 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,6 @@ "install": "^0.13.0", "jest": "^27.2.5", "jest-cli": "^27.2.5", - "moleculer-io": "^2.0.0", "moleculer-repl": "^0.7.0", "npm": "^8.4.1", "ts-jest": "^25.3.0", @@ -47,6 +46,7 @@ "axios": "^0.25.0", "axios-retry": "^3.2.4", "bree": "^7.1.5", + "moleculer-io": "^2.0.0", "chokidar": "^3.5.3", "delay": "^5.0.0", "dotenv": "^10.0.0", diff --git a/services/socket.service.ts b/services/socket.service.ts index acfa822..4b0f25f 100644 --- a/services/socket.service.ts +++ b/services/socket.service.ts @@ -68,7 +68,7 @@ export default class SocketService extends Service { actions: {}, methods: {}, async started() { - this.io.on("connection", (data) => console.log("Connected to socket.io server.")) + this.io.on("connection", (data) => console.log("socket.io server initialized.")) } }, schema diff --git a/utils/uncompression.utils.ts b/utils/uncompression.utils.ts index fd3ee24..cef4bba 100644 --- a/utils/uncompression.utils.ts +++ b/utils/uncompression.utils.ts @@ -32,23 +32,22 @@ SOFTWARE. */ import { - createWriteStream, - createReadStream, - promises as fs, - readFileSync, - existsSync, + createReadStream, createWriteStream, + + + + existsSync } from "fs"; +import { isEmpty, isNil, isUndefined, remove } from "lodash"; +import * as p7zip from "p7zip-threetwo"; +import path from "path"; +import sharp from "sharp"; +import { IMPORT_IMAGE_FILE_FORMATS } from "../constants/allowedFileFormats"; +import { USERDATA_DIRECTORY } from "../constants/directories"; +import { checkFileExists, getFileConstituents } from "../utils/file.utils"; +import { convertXMLToJSON } from "./xml.utils"; const fse = require("fs-extra"); const Unrar = require("unrar"); -import path, { parse } from "path"; -import * as p7zip from "p7zip-threetwo"; -import { IExtractedComicBookCoverFile } from "threetwo-ui-typings"; -import sharp from "sharp"; -import { getFileConstituents, checkFileExists } from "../utils/file.utils"; -import { flatten, isEmpty, isNil, isUndefined, remove } from "lodash"; -import { convertXMLToJSON } from "./xml.utils"; -import { USERDATA_DIRECTORY, COMICS_DIRECTORY } from "../constants/directories"; -import { IMPORT_IMAGE_FILE_FORMATS } from "../constants/allowedFileFormats"; interface RarFile { name: string; type: string; @@ -63,6 +62,7 @@ interface RarFile { } const UNRAR_BIN_PATH = process.env.UNRAR_BIN_PATH || "/opt/homebrew/bin/unrar"; + export const extractComicInfoXMLFromRar = async ( filePath: string ): Promise => {