👷🏽 Refactoring fs.utils
This commit is contained in:
@@ -1,13 +1,6 @@
|
||||
import router from "../router";
|
||||
import { default as paginate } from "express-paginate";
|
||||
import {
|
||||
walkFolder,
|
||||
extractArchive,
|
||||
unrar,
|
||||
unzip,
|
||||
extractMetadataFromImage,
|
||||
explodePath,
|
||||
} from "../../utils/fs.utils";
|
||||
import { walkFolder, extractArchive, getCovers } from "../../utils/fs.utils";
|
||||
import _ from "lodash";
|
||||
import { IExtractionOptions } from "../../interfaces/folder.interface";
|
||||
import { Request, Response } from "express";
|
||||
@@ -16,32 +9,28 @@ router.route("/getComicCovers").post(async (req: Request, res: Response) => {
|
||||
typeof req.body.extractionOptions === "object"
|
||||
? req.body.extractionOptions
|
||||
: {};
|
||||
const extractedData = await extractArchive(req.body);
|
||||
if (
|
||||
_.isArray(extractedData) &&
|
||||
!_.isUndefined(req.body.paginationOptions.pageLimit)
|
||||
) {
|
||||
const pageCount = Math.ceil(
|
||||
extractedData.length / req.body.paginationOptions.pageLimit,
|
||||
);
|
||||
const foo = await getCovers(req.body);
|
||||
return res.json({ foo });
|
||||
// const extractedData = await extractArchive(req.body);
|
||||
// if (
|
||||
// _.isArray(extractedData) &&
|
||||
// !_.isUndefined(req.body.paginationOptions.pageLimit)
|
||||
// ) {
|
||||
// const pageCount = Math.ceil(
|
||||
// extractedData.length / req.body.paginationOptions.pageLimit,
|
||||
// );
|
||||
|
||||
return res.json({
|
||||
object: "list",
|
||||
has_more: paginate.hasNextPages(req)(pageCount),
|
||||
pageCount,
|
||||
itemCount: extractedData.length,
|
||||
extractedData,
|
||||
});
|
||||
}
|
||||
// const foo = await extractMetadataFromImage(
|
||||
// "./comics/covers/Ghosts and Ruins-001.jpg",
|
||||
// );
|
||||
// const foo = await unzipOne(options);
|
||||
// const foo = await unzip("asd");
|
||||
// const foo = explodePath("Chapter Three/HELLBOY - The Chained Coffin - 069.jpg");
|
||||
return res.json({
|
||||
extractedData,
|
||||
});
|
||||
// return res.json({
|
||||
// object: "list",
|
||||
// has_more: paginate.hasNextPages(req)(pageCount),
|
||||
// pageCount,
|
||||
// itemCount: extractedData.length,
|
||||
// extractedData,
|
||||
// });
|
||||
// }
|
||||
// return res.json({
|
||||
// extractedData,
|
||||
// });
|
||||
});
|
||||
|
||||
router.route("/walkFolder").post(async (req: Request, res: Response) => {
|
||||
|
||||
Reference in New Issue
Block a user