42 lines
1.3 KiB
TypeScript
42 lines
1.3 KiB
TypeScript
import router from "../router";
|
|
import { default as paginate } from "express-paginate";
|
|
import {
|
|
walkFolder,
|
|
extractArchive,
|
|
unrar,
|
|
unzip,
|
|
extractMetadataFromImage,
|
|
explodePath,
|
|
} from "../../utils/fs.utils";
|
|
import { IExtractionOptions } from "../../interfaces/folder.interface";
|
|
import { Request, Response } from "express";
|
|
|
|
router.route("/getComicCovers").post(async (req: Request, res: Response) => {
|
|
typeof req.body.extractionOptions === "object"
|
|
? req.body.extractionOptions
|
|
: {};
|
|
const extractedData = await extractArchive(req.body);
|
|
console.log(extractedData);
|
|
// const pageCount = Math.ceil( / req.body.paginationOptions.pageLimit);
|
|
// 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");
|
|
res.json({
|
|
extractedData,
|
|
});
|
|
});
|
|
|
|
router.route("/walkFolder").post(async (req: Request, res: Response) => {
|
|
const basePathToWalk =
|
|
typeof req.query.basePathToWalk === "string"
|
|
? req.query.basePathToWalk
|
|
: "";
|
|
const results = await walkFolder(basePathToWalk);
|
|
res.json(results);
|
|
});
|
|
|
|
export default router;
|