refactor: rename minify function

rename minify function to getCorrespondingReaderView
This commit is contained in:
Artemy 2023-08-14 13:07:58 +03:00
parent 7fad4874ce
commit 3a1fac2b65
2 changed files with 5 additions and 3 deletions

View File

@ -2,7 +2,7 @@ import { IConfigService } from "./config/config.interface";
import { ConfigService } from "./config/config.service"; import { ConfigService } from "./config/config.service";
import NodeCache from "node-cache"; import NodeCache from "node-cache";
import { readability } from "./handlers/readability"; import { readability } from "./handlers/readability";
import minify from "./handlers/main"; import getCorrespondingReaderView from "./handlers/main";
import Fastify from "fastify"; import Fastify from "fastify";
import middie from "@fastify/middie"; import middie from "@fastify/middie";
import { Cached, EngineRequest, GetRequest } from "./schema/requests.types"; import { Cached, EngineRequest, GetRequest } from "./schema/requests.types";
@ -46,7 +46,7 @@ class App {
? "text/html; charset=utf-8" ? "text/html; charset=utf-8"
: "text/plain; charset=utf-8"; : "text/plain; charset=utf-8";
const parsed = await minify(url); const parsed = await getCorrespondingReaderView(url);
const content = type === "html" ? parsed?.content : parsed?.textContent; const content = type === "html" ? parsed?.content : parsed?.textContent;
this.cache.set(req.originalUrl || req.url, { this.cache.set(req.originalUrl || req.url, {

View File

@ -1,7 +1,9 @@
import { IHandlerOutput } from "./handler.interface"; import { IHandlerOutput } from "./handler.interface";
import { readability } from "./readability"; import { readability } from "./readability";
export default function minify(url: string): Promise<IHandlerOutput> { export default function getCorrespondingReaderView(
url: string
): Promise<IHandlerOutput> {
const host = new URL(url).hostname; const host = new URL(url).hostname;
return fallback[host]?.(url) || fallback["*"](url); return fallback[host]?.(url) || fallback["*"](url);