refactor: move to utils
This commit is contained in:
parent
d498488875
commit
9ad4d3d353
@ -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)) {
|
||||
|
@ -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>(
|
||||
|
@ -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>(
|
||||
|
@ -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>(
|
||||
|
Loading…
x
Reference in New Issue
Block a user