🧃 Worker is... working.
This commit is contained in:
@@ -31,7 +31,8 @@ export async function extractCoverFromComicBookArchive(
|
|||||||
| IExtractComicBookCoverErrorResponse
|
| IExtractComicBookCoverErrorResponse
|
||||||
> {
|
> {
|
||||||
return await axios.request({
|
return await axios.request({
|
||||||
url: FS_API_BASE_URI + "/getComicCovers",
|
url: FS_API_BASE_URI + "getComicCovers",
|
||||||
|
method: "POST",
|
||||||
data: {
|
data: {
|
||||||
...options,
|
...options,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import * as React from "react";
|
import * as React from "react";
|
||||||
import _ from "lodash";
|
import _ from "lodash";
|
||||||
import { connect } from "react-redux";
|
import { connect } from "react-redux";
|
||||||
import * as Comlink from "comlink";
|
|
||||||
import { greet } from "../workers/extractCovers.worker";
|
import { greet } from "../workers/extractCovers.worker";
|
||||||
interface IProps {
|
interface IProps {
|
||||||
matches: unknown;
|
matches: unknown;
|
||||||
|
|||||||
1
src/client/constants/importer.config.ts
Normal file
1
src/client/constants/importer.config.ts
Normal file
@@ -0,0 +1 @@
|
|||||||
|
export const SUPPORTED_COMIC_ARCHIVES = [".cbz", ".cbr"];
|
||||||
@@ -1,7 +1,28 @@
|
|||||||
import { walkFolder } from "../actions/fileops.actions";
|
import {
|
||||||
import { IFolderData } from "../../server/interfaces/folder.interface";
|
walkFolder,
|
||||||
|
extractCoverFromComicBookArchive,
|
||||||
|
} from "../actions/fileops.actions";
|
||||||
|
import { SUPPORTED_COMIC_ARCHIVES } from "../constants/importer.config";
|
||||||
|
import { IExtractedComicBookCoverFile } from "../../server/interfaces/folder.interface";
|
||||||
|
import _ from "lodash";
|
||||||
|
|
||||||
export async function greet(path: string): Promise<IFolderData[]> {
|
export const greet = async (
|
||||||
|
path: string,
|
||||||
|
): Promise<IExtractedComicBookCoverFile[] | unknown> => {
|
||||||
console.log(path);
|
console.log(path);
|
||||||
return await walkFolder("./comics");
|
const targetOptions = {
|
||||||
|
sourceFolder: path,
|
||||||
|
extractTarget: "cover",
|
||||||
|
targetExtractionFolder: "../covers",
|
||||||
|
};
|
||||||
|
const fileObjects = await walkFolder("./comics");
|
||||||
|
_.map(fileObjects, async (fileObject) => {
|
||||||
|
console.log(fileObject);
|
||||||
|
if (SUPPORTED_COMIC_ARCHIVES.includes(fileObject.extension)) {
|
||||||
|
await extractCoverFromComicBookArchive({
|
||||||
|
...targetOptions,
|
||||||
|
folderDetails: fileObject,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ const port: number = Number(process.env.PORT) || 8050; // set our port
|
|||||||
|
|
||||||
// Send index.html on root request
|
// Send index.html on root request
|
||||||
app.use(express.static("dist"));
|
app.use(express.static("dist"));
|
||||||
app.use(express.static("src/client/workers"));
|
|
||||||
app.get("/", (req: Request, res: Response) => {
|
app.get("/", (req: Request, res: Response) => {
|
||||||
console.log("sending index.html");
|
console.log("sending index.html");
|
||||||
res.sendFile("/dist/index.html");
|
res.sendFile("/dist/index.html");
|
||||||
|
|||||||
@@ -223,8 +223,6 @@ export const explodePath = (filePath: string): IExplodedPathResponse => {
|
|||||||
const constructPaths = (extractionOptions: IExtractionOptions) => {
|
const constructPaths = (extractionOptions: IExtractionOptions) => {
|
||||||
return {
|
return {
|
||||||
targetPath:
|
targetPath:
|
||||||
extractionOptions.sourceFolder +
|
|
||||||
"/" +
|
|
||||||
extractionOptions.targetExtractionFolder +
|
extractionOptions.targetExtractionFolder +
|
||||||
"/" +
|
"/" +
|
||||||
extractionOptions.folderDetails.name,
|
extractionOptions.folderDetails.name,
|
||||||
|
|||||||
@@ -8,17 +8,17 @@
|
|||||||
"module": "commonjs",
|
"module": "commonjs",
|
||||||
"sourceMap": true,
|
"sourceMap": true,
|
||||||
"outDir": "./dist/",
|
"outDir": "./dist/",
|
||||||
"noImplicitAny": true,
|
|
||||||
"skipLibCheck": true,
|
"skipLibCheck": true,
|
||||||
"lib": [
|
"lib": [
|
||||||
"dom",
|
"dom",
|
||||||
"dom.iterable",
|
"dom.iterable",
|
||||||
"esnext"
|
"esnext",
|
||||||
|
"webworker"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"settings": {
|
"settings": {
|
||||||
"eslint.workingDirectories": [
|
"eslint.workingDirectories": [
|
||||||
{"directory": "./node_modules", "changeProcessCWD": true }
|
{ "directory": "./node_modules", "changeProcessCWD": true }
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"exclude": [
|
"exclude": [
|
||||||
|
|||||||
@@ -65,6 +65,9 @@ module.exports = {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
optimization: {
|
||||||
|
usedExports: false,
|
||||||
|
},
|
||||||
plugins: [
|
plugins: [
|
||||||
// new CleanWebpackPlugin([outputDirectory]),
|
// new CleanWebpackPlugin([outputDirectory]),
|
||||||
new HtmlWebpackPlugin({
|
new HtmlWebpackPlugin({
|
||||||
|
|||||||
Reference in New Issue
Block a user