Refactor/cleanup: moved types to other file
This commit is contained in:
parent
f6dc1f953e
commit
62d408ef98
@ -1,8 +1,8 @@
|
|||||||
import { IHandlerOutput } from "./handler.interface";
|
import { IHandlerOutput } from "./handler.interface";
|
||||||
|
import { Engines, EngineFunction, EnginesMatch } from "../types/handlers";
|
||||||
import axios from "../types/axios";
|
import axios from "../types/axios";
|
||||||
|
|
||||||
import { JSDOM } from "jsdom";
|
import { JSDOM } from "jsdom";
|
||||||
import { DOMWindow } from "jsdom";
|
|
||||||
|
|
||||||
import micromatch from "micromatch";
|
import micromatch from "micromatch";
|
||||||
|
|
||||||
@ -64,23 +64,12 @@ function getFallbackEngine(host: string, specified?: string): EngineFunction {
|
|||||||
return engines.readability;
|
return engines.readability;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface Engines {
|
|
||||||
[key: string]: EngineFunction;
|
|
||||||
}
|
|
||||||
|
|
||||||
export const engines: Engines = {
|
export const engines: Engines = {
|
||||||
readability,
|
readability,
|
||||||
google,
|
google,
|
||||||
stackoverflow,
|
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 engineList: string[] = Object.keys(engines);
|
||||||
|
|
||||||
export const fallback: EnginesMatch = [
|
export const fallback: EnginesMatch = [
|
||||||
|
14
src/types/handlers.ts
Normal file
14
src/types/handlers.ts
Normal 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[];
|
Loading…
x
Reference in New Issue
Block a user