refactor: move to utils

This commit is contained in:
Artemy 2023-08-17 17:06:21 +03:00
parent d498488875
commit 9ad4d3d353
6 changed files with 12 additions and 9 deletions

View File

@ -7,17 +7,20 @@ import { DOMWindow } from "jsdom";
import readability from "./readability";
import google from "./google";
import { generateProxyUrl } from "../utils";
import isLocalResource from "../islocal";
import { generateProxyUrl } from "../utils/generate";
import isLocalResource from "../utils/islocal";
import { InvalidParameterError, LocalResourceError, NotHtmlMimetypeError } from "../errors/main";
import {
InvalidParameterError,
LocalResourceError,
NotHtmlMimetypeError,
} from "../errors/main";
export default async function handlePage(
url: string, // remote URL
requestUrl: URL, // proxy URL
url: string, // remote URL
requestUrl: URL, // proxy URL
engine?: string
): Promise<IHandlerOutput> {
const urlObj = new URL(url);
if (await isLocalResource(urlObj)) {

View File

@ -2,7 +2,7 @@ import { FastifyInstance } from "fastify";
import { GetSchema, IGetSchema } from "../types/requests";
import handlePage from "../handlers/main";
import { generateRequestUrl } from "../utils";
import { generateRequestUrl } from "../utils/generate";
export default async function getRoute(fastify: FastifyInstance) {
fastify.get<IGetSchema>(

View File

@ -1,7 +1,7 @@
import { EngineRequest, IParseSchema, parseSchema } from "../types/requests";
import { FastifyInstance } from "fastify";
import handlePage from "../handlers/main";
import { generateRequestUrl } from "../utils";
import { generateRequestUrl } from "../utils/generate";
export default async function parseRoute(fastify: FastifyInstance) {
fastify.get<IParseSchema>(

View File

@ -2,7 +2,7 @@ import { FastifyInstance } from "fastify";
import { GetRequest, IParseSchema, rawHtmlSchema } from "../types/requests";
import handlePage from "../handlers/main";
import { generateRequestUrl } from "../utils";
import { generateRequestUrl } from "../utils/generate";
export default async function rawHtml(fastify: FastifyInstance) {
fastify.get<IParseSchema>(