🧑🏻🔧 Worker Streams
This commit is contained in:
@@ -4,6 +4,8 @@ import {
|
||||
} from "../actions/fileops.actions";
|
||||
import { IExtractedComicBookCoverFile } from "../../server/interfaces/folder.interface";
|
||||
const ndjsonStream = require("can-ndjson-stream");
|
||||
import fetch from "node-fetch";
|
||||
import { API_BASE_URI } from "../constants/endpoints";
|
||||
|
||||
export const greet = async (
|
||||
path: string,
|
||||
@@ -19,14 +21,23 @@ export const greet = async (
|
||||
pageLimit: 25,
|
||||
page: 1,
|
||||
};
|
||||
|
||||
const extractionOptions = {
|
||||
...targetOptions,
|
||||
paginationOptions: pagingConfig,
|
||||
};
|
||||
const fileObjects = await walkFolder("./comics");
|
||||
const fo = await extractCoverFromComicBookArchive(
|
||||
{
|
||||
...targetOptions,
|
||||
paginationOptions: pagingConfig,
|
||||
},
|
||||
const fetchedResource = await extractCoverFromComicBookArchive(
|
||||
extractionOptions,
|
||||
fileObjects,
|
||||
);
|
||||
// return JSON.stringify(fo);
|
||||
|
||||
const reader = await ndjsonStream(fetchedResource.body).getReader();
|
||||
reader.read().then(function process({ done, value }) {
|
||||
if (done) {
|
||||
console.log("done");
|
||||
return;
|
||||
}
|
||||
|
||||
return reader.read().then(process);
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user