Refactor/cleanup: moved types to other file

This commit is contained in:
DarkCat09 2023-09-11 11:23:27 +04:00
parent f6dc1f953e
commit 62d408ef98
No known key found for this signature in database
GPG Key ID: 0A26CD5B3345D6E3
2 changed files with 15 additions and 12 deletions

View File

@ -1,8 +1,8 @@
import { IHandlerOutput } from "./handler.interface";
import { Engines, EngineFunction, EnginesMatch } from "../types/handlers";
import axios from "../types/axios";
import { JSDOM } from "jsdom";
import { DOMWindow } from "jsdom";
import micromatch from "micromatch";
@ -64,23 +64,12 @@ function getFallbackEngine(host: string, specified?: string): EngineFunction {
return engines.readability;
}
interface Engines {
[key: string]: EngineFunction;
}
export const engines: Engines = {
readability,
google,
stackoverflow,
};
type EngineFunction = (window: DOMWindow) => Promise<IHandlerOutput>;
export type EngineMatch = {
pattern: string | string[];
engine: EngineFunction;
};
export type EnginesMatch = EngineMatch[];
export const engineList: string[] = Object.keys(engines);
export const fallback: EnginesMatch = [

14
src/types/handlers.ts Normal file
View File

@ -0,0 +1,14 @@
import { DOMWindow } from "jsdom";
import { IHandlerOutput } from "../handlers/handler.interface";
export interface Engines {
[key: string]: EngineFunction;
}
export type EngineMatch = {
pattern: string | string[];
engine: EngineFunction;
};
export type EngineFunction = (window: DOMWindow) => Promise<IHandlerOutput>;
export type EnginesMatch = EngineMatch[];