🧑🏻‍🔧 Worker Streams

This commit is contained in:
2021-05-10 23:10:22 -07:00
parent 924453b22d
commit 325024afd1
7 changed files with 177 additions and 62 deletions

View File

@@ -1,18 +1,19 @@
import axios from "axios";
import fetch, { Response } from "node-fetch";
import {
IExtractComicBookCoverErrorResponse,
IExtractedComicBookCoverFile,
IExtractionOptions,
IFolderData,
} from "../../server/interfaces/folder.interface";
import { FS_API_BASE_URI } from "../constants/endpoints";
import { API_BASE_URI } from "../constants/endpoints";
export async function walkFolder(path: string): Promise<Array<IFolderData>> {
return axios
.request<Array<IFolderData>>({
url: FS_API_BASE_URI + "walkFolder",
url: API_BASE_URI + "walkFolder",
method: "POST",
params: {
data: {
basePathToWalk: path,
},
transformResponse: (r: string) => JSON.parse(r),
@@ -26,17 +27,16 @@ export async function walkFolder(path: string): Promise<Array<IFolderData>> {
export async function extractCoverFromComicBookArchive(
extractionOptions: IExtractionOptions,
walkedFolders: Array<IFolderData>,
): Promise<
| IExtractedComicBookCoverFile
| IExtractedComicBookCoverFile[]
| IExtractComicBookCoverErrorResponse
> {
return await axios.request({
url: FS_API_BASE_URI + "getComicCovers",
): Promise<Response> {
return await fetch(API_BASE_URI + "getComicCovers", {
method: "POST",
data: {
headers: {
Accept: "application/json",
"Content-Type": "application/json",
},
body: JSON.stringify({
extractionOptions,
walkedFolders,
},
}),
});
}