diff --git a/package.json b/package.json index ff3d2e0..87251ae 100644 --- a/package.json +++ b/package.json @@ -50,6 +50,6 @@ "typescript": "^4.1.3" }, "dependencies": { - "rss-parser": "3.11.0" + "rss-parser": "^3.11.0" } } diff --git a/src/Models/ListenerRSSInfos.ts b/src/Models/ListenerRSSInfos.ts deleted file mode 100644 index 0da2390..0000000 --- a/src/Models/ListenerRSSInfos.ts +++ /dev/null @@ -1,6 +0,0 @@ -export interface ListenerRSSInfos { - readonly address: string; // feed's address - readonly timeloop?: number; // update time RSS feed - readonly customfields?: { [key: string]: string | string[] }; // rss fields custom - readonly lastEntriesLinks?: string[]; // links from lastentries -} diff --git a/src/index.ts b/src/index.ts index 4046865..f28ed04 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,2 +1 @@ export { ListenerRss } from "./listener-rss"; -export { ListenerRSSInfos } from "./Models/ListenerRSSInfos"; diff --git a/src/listener-rss.ts b/src/listener-rss.ts index 43e217d..7e4ffbc 100644 --- a/src/listener-rss.ts +++ b/src/listener-rss.ts @@ -1,15 +1,23 @@ import Parser from "rss-parser"; -import { ListenerRSSInfos } from "./Models/ListenerRSSInfos"; import EventEmitter from "events"; const DEFAULT_TIMELOOP: number = 5 * 60; // default timeloop is 5 min +namespace ListenerRss { + export type Config = { + address: string; // feed's address + timeloop?: number; // update time RSS feed + customfields?: { [key: string]: string | string[] }; // rss fields custom + lastEntriesLinks?: string[]; // links from lastentries + }; +} + /** * Emit 'update' when he's making a fetch during the start fun * Emit 'error' when the fetch has an issue * Emit 'newEntries' when the fetch has new entris */ -export class ListenerRss extends EventEmitter { +class ListenerRss extends EventEmitter { address: string = ""; timeloop: number = DEFAULT_TIMELOOP; // time in seconds customfields?: { [key: string]: string[] | string }; @@ -23,7 +31,7 @@ export class ListenerRss extends EventEmitter { * @brief constructor * @param config ListenerRSSInfos interface who contains the ListenerInfos */ - constructor(config: ListenerRSSInfos) { + constructor(config: ListenerRss.Config) { super(); this.address = config.address; @@ -107,7 +115,7 @@ export class ListenerRss extends EventEmitter { * @brief parse the datas inti a ListenerRSSInfos object * @return return a ListenerRSSInfos object */ - getProperty(): ListenerRSSInfos { + getProperty(): ListenerRss.Config { return { address: this.address, customfields: this.customfields, @@ -116,3 +124,5 @@ export class ListenerRss extends EventEmitter { }; } } + +export { ListenerRss }; diff --git a/tests/index-spec.ts b/tests/index-spec.ts index 8ddef98..9f66760 100644 --- a/tests/index-spec.ts +++ b/tests/index-spec.ts @@ -2,10 +2,9 @@ import * as Parser from "rss-parser"; // tested class -import { - ListenerRSSInfos as ListenerRRSInfo, - ListenerRss as Listeners, -} from "../"; +import { ListenerRss } from "../"; + +const ListenerRSSInfo = ListenerRss.Config; // Unit test import assert from "assert";