📕 Testing call against covers
This commit is contained in:
@@ -12,8 +12,8 @@ export const greet = async (
|
|||||||
): Promise<IExtractedComicBookCoverFile[] | unknown | any> => {
|
): Promise<IExtractedComicBookCoverFile[] | unknown | any> => {
|
||||||
const targetOptions = {
|
const targetOptions = {
|
||||||
sourceFolder: path,
|
sourceFolder: path,
|
||||||
extractTarget: "all",
|
extractTarget: "cover",
|
||||||
targetExtractionFolder: "./userdata/expanded",
|
targetExtractionFolder: "./userdata/covers",
|
||||||
extractionMode: "bulk",
|
extractionMode: "bulk",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -23,8 +23,8 @@ router.route("/getComicCovers").post(async (req: Request, res: Response) => {
|
|||||||
typeof req.body.extractionOptions === "object"
|
typeof req.body.extractionOptions === "object"
|
||||||
? req.body.extractionOptions
|
? req.body.extractionOptions
|
||||||
: {};
|
: {};
|
||||||
const foo = await axios({
|
const comicBookCoversData = await axios({
|
||||||
url: "http://localhost:3853/api/import/getComicCovers",
|
url: "http://localhost:3000/api/import/getComicCovers",
|
||||||
method: "POST",
|
method: "POST",
|
||||||
data: {
|
data: {
|
||||||
extractionOptions: req.body.extractionOptions,
|
extractionOptions: req.body.extractionOptions,
|
||||||
@@ -37,9 +37,6 @@ router.route("/getComicCovers").post(async (req: Request, res: Response) => {
|
|||||||
read() {},
|
read() {},
|
||||||
});
|
});
|
||||||
|
|
||||||
// We create the stream transform using through2 library..
|
|
||||||
// We instruct it to handle objects, buffer size and transform function,
|
|
||||||
// that is, we convert our object to text to be able to send it through the stream response, which does not handle objects..
|
|
||||||
const ndjsonStream = through2(
|
const ndjsonStream = through2(
|
||||||
{ objectMode: true, highWaterMark: 1 },
|
{ objectMode: true, highWaterMark: 1 },
|
||||||
(data, enc, cb) => {
|
(data, enc, cb) => {
|
||||||
@@ -47,11 +44,8 @@ router.route("/getComicCovers").post(async (req: Request, res: Response) => {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
// console.log(ndjsonStream);
|
|
||||||
// Through pipe we do a double addressing, our reading stream goes through the transformation
|
|
||||||
// to finally go through the stream response..
|
|
||||||
stream.pipe(ndjsonStream).pipe(res);
|
stream.pipe(ndjsonStream).pipe(res);
|
||||||
stream.push({ source1: foo.data });
|
stream.push({ data: comicBookCoversData.data });
|
||||||
stream.push(null);
|
stream.push(null);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -60,7 +54,7 @@ router.route("/walkFolder").post(async (req: Request, res: Response) => {
|
|||||||
typeof req.body.basePathToWalk === "string" ? req.body.basePathToWalk : "";
|
typeof req.body.basePathToWalk === "string" ? req.body.basePathToWalk : "";
|
||||||
const walkedFolders = await axios
|
const walkedFolders = await axios
|
||||||
.request({
|
.request({
|
||||||
url: "http://localhost:3853/api/import/walkFolders",
|
url: "http://localhost:3000/api/import/walkFolders",
|
||||||
method: "POST",
|
method: "POST",
|
||||||
data: {
|
data: {
|
||||||
basePathToWalk,
|
basePathToWalk,
|
||||||
|
|||||||
Reference in New Issue
Block a user