Add accordion and fix minor issues (#742)
* Add docs v0.0.1 * Add icon size warning * Fix sourcenover caution * Fix semver descriptions * Filters fix * Quickfix quickstart * Add icon warning v2 * Fix typos * Add NovelItem * Update plugins host * Update plugins host * Remove unnecesarry .js and .dist * Update plugins host * Add host.ps1 * Fix readme.txt * Fix READNE.txt, again * Remove .js and .dist * Add accordion * Working pagination * readme update with ost * Add linux/windows hosting functions * Add tswatch * Fix fetch function * Change plugin versions * Fix chrome * Fix workflows * Fix search not showing results * remove unnecesarry code * Revert novelupdates changes * Reverted NobleMTL instead of novelupdates, fixing that * Revert nobleMTL to e346c7d0 * WTF NobleMTL?
This commit is contained in:
@@ -9,7 +9,7 @@ import localizedFormat from "dayjs/plugin/localizedFormat";
|
||||
|
||||
const app = express();
|
||||
const port = Number(process.argv[2]);
|
||||
if(!port){
|
||||
if (!port) {
|
||||
process.exit(0);
|
||||
}
|
||||
const host = "localhost";
|
||||
@@ -23,7 +23,9 @@ export const getHeaders = () => {
|
||||
app.use((req, res, next) => {
|
||||
const xHeaders = req.headers["x-custom-headers"];
|
||||
if (xHeaders && typeof xHeaders === "string") {
|
||||
for (const [headerName, headerValue] of Object.entries(pluginApi.fetchHeaders)) {
|
||||
for (const [headerName, headerValue] of Object.entries(
|
||||
pluginApi.fetchHeaders
|
||||
)) {
|
||||
if (
|
||||
typeof headerName === "string" &&
|
||||
typeof headerValue === "string"
|
||||
@@ -56,41 +58,68 @@ app.post("/filters", async (req, res) => {
|
||||
res.json(filters || []);
|
||||
});
|
||||
app.post("/popularNovels/", async (req, res) => {
|
||||
const filters = req.body["filters"] || {};
|
||||
const requirePath = req.body["pluginRequirePath"];
|
||||
const showLatestNovels = req.body["showLatestNovels"] || false;
|
||||
const novels = await pluginApi.popularNovels(
|
||||
req.body["pluginRequirePath"],
|
||||
{ showLatestNovels, filters }
|
||||
);
|
||||
res.json(novels);
|
||||
const defaultFilters = await pluginApi.getFilter(requirePath);
|
||||
const filters = showLatestNovels
|
||||
? defaultFilters
|
||||
: req.body["filters"] || defaultFilters;
|
||||
const page = parseInt(req.body["page"]);
|
||||
try {
|
||||
const novels = await pluginApi.popularNovels(requirePath, page || 1, {
|
||||
showLatestNovels,
|
||||
filters,
|
||||
});
|
||||
res.json(novels);
|
||||
} catch (err) {
|
||||
res.json({ error: err });
|
||||
}
|
||||
});
|
||||
app.post("/searchNovels/", async (req, res) => {
|
||||
const novels = await pluginApi.searchNovels(
|
||||
req.body["pluginRequirePath"],
|
||||
req.body["searchTerm"]
|
||||
);
|
||||
res.json(novels);
|
||||
const page = parseInt(req.body["page"]) || 1;
|
||||
try {
|
||||
const novels = await pluginApi.searchNovels(
|
||||
req.body["pluginRequirePath"],
|
||||
page,
|
||||
req.body["searchTerm"]
|
||||
);
|
||||
res.json(novels);
|
||||
} catch (err) {
|
||||
res.json({ error: err });
|
||||
}
|
||||
});
|
||||
app.post("/parseNovelAndChapters/", async (req, res) => {
|
||||
const sourceNovel = await pluginApi.parseNovelAndChapters(
|
||||
req.body["pluginRequirePath"],
|
||||
req.body["novelUrl"]
|
||||
);
|
||||
res.json(sourceNovel);
|
||||
try {
|
||||
const sourceNovel = await pluginApi.parseNovelAndChapters(
|
||||
req.body["pluginRequirePath"],
|
||||
req.body["novelUrl"]
|
||||
);
|
||||
res.json(sourceNovel);
|
||||
} catch (err) {
|
||||
res.json({ error: err });
|
||||
}
|
||||
});
|
||||
app.post("/parseChapter/", async (req, res) => {
|
||||
const chapterText = await pluginApi.parseChapter(
|
||||
req.body["pluginRequirePath"],
|
||||
req.body["chapterUrl"]
|
||||
);
|
||||
res.send(chapterText);
|
||||
try {
|
||||
const chapterText = await pluginApi.parseChapter(
|
||||
req.body["pluginRequirePath"],
|
||||
req.body["chapterUrl"]
|
||||
);
|
||||
res.send(chapterText);
|
||||
} catch (err) {
|
||||
res.json({ error: err });
|
||||
}
|
||||
});
|
||||
app.post("/fetchImage/", async (req, res) => {
|
||||
const base64 = await pluginApi.fetchImage(
|
||||
req.body["pluginRequirePath"],
|
||||
req.body["url"]
|
||||
);
|
||||
res.send(base64);
|
||||
try {
|
||||
const base64 = await pluginApi.fetchImage(
|
||||
req.body["pluginRequirePath"],
|
||||
req.body["url"]
|
||||
);
|
||||
res.send(base64);
|
||||
} catch (err) {
|
||||
res.json({ error: err });
|
||||
}
|
||||
});
|
||||
|
||||
app.get("/", (req, res) => {
|
||||
|
||||
Reference in New Issue
Block a user