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 readability from "./readability";
|
||||||
import google from "./google";
|
import google from "./google";
|
||||||
|
|
||||||
import { generateProxyUrl } from "../utils";
|
import { generateProxyUrl } from "../utils/generate";
|
||||||
import isLocalResource from "../islocal";
|
import isLocalResource from "../utils/islocal";
|
||||||
|
|
||||||
import { InvalidParameterError, LocalResourceError, NotHtmlMimetypeError } from "../errors/main";
|
import {
|
||||||
|
InvalidParameterError,
|
||||||
|
LocalResourceError,
|
||||||
|
NotHtmlMimetypeError,
|
||||||
|
} from "../errors/main";
|
||||||
|
|
||||||
export default async function handlePage(
|
export default async function handlePage(
|
||||||
url: string, // remote URL
|
url: string, // remote URL
|
||||||
requestUrl: URL, // proxy URL
|
requestUrl: URL, // proxy URL
|
||||||
engine?: string
|
engine?: string
|
||||||
): Promise<IHandlerOutput> {
|
): Promise<IHandlerOutput> {
|
||||||
|
|
||||||
const urlObj = new URL(url);
|
const urlObj = new URL(url);
|
||||||
|
|
||||||
if (await isLocalResource(urlObj)) {
|
if (await isLocalResource(urlObj)) {
|
||||||
|
@ -2,7 +2,7 @@ import { FastifyInstance } from "fastify";
|
|||||||
|
|
||||||
import { GetSchema, IGetSchema } from "../types/requests";
|
import { GetSchema, IGetSchema } from "../types/requests";
|
||||||
import handlePage from "../handlers/main";
|
import handlePage from "../handlers/main";
|
||||||
import { generateRequestUrl } from "../utils";
|
import { generateRequestUrl } from "../utils/generate";
|
||||||
|
|
||||||
export default async function getRoute(fastify: FastifyInstance) {
|
export default async function getRoute(fastify: FastifyInstance) {
|
||||||
fastify.get<IGetSchema>(
|
fastify.get<IGetSchema>(
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { EngineRequest, IParseSchema, parseSchema } from "../types/requests";
|
import { EngineRequest, IParseSchema, parseSchema } from "../types/requests";
|
||||||
import { FastifyInstance } from "fastify";
|
import { FastifyInstance } from "fastify";
|
||||||
import handlePage from "../handlers/main";
|
import handlePage from "../handlers/main";
|
||||||
import { generateRequestUrl } from "../utils";
|
import { generateRequestUrl } from "../utils/generate";
|
||||||
|
|
||||||
export default async function parseRoute(fastify: FastifyInstance) {
|
export default async function parseRoute(fastify: FastifyInstance) {
|
||||||
fastify.get<IParseSchema>(
|
fastify.get<IParseSchema>(
|
||||||
|
@ -2,7 +2,7 @@ import { FastifyInstance } from "fastify";
|
|||||||
|
|
||||||
import { GetRequest, IParseSchema, rawHtmlSchema } from "../types/requests";
|
import { GetRequest, IParseSchema, rawHtmlSchema } from "../types/requests";
|
||||||
import handlePage from "../handlers/main";
|
import handlePage from "../handlers/main";
|
||||||
import { generateRequestUrl } from "../utils";
|
import { generateRequestUrl } from "../utils/generate";
|
||||||
|
|
||||||
export default async function rawHtml(fastify: FastifyInstance) {
|
export default async function rawHtml(fastify: FastifyInstance) {
|
||||||
fastify.get<IParseSchema>(
|
fastify.get<IParseSchema>(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user