Move the ListenerRSSInfos inside the ListenerRSS namespace
This commit is contained in:
parent
e6395483e2
commit
1f4029dad2
|
@ -50,6 +50,6 @@
|
|||
"typescript": "^4.1.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"rss-parser": "3.11.0"
|
||||
"rss-parser": "^3.11.0"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
|
@ -1,2 +1 @@
|
|||
export { ListenerRss } from "./listener-rss";
|
||||
export { ListenerRSSInfos } from "./Models/ListenerRSSInfos";
|
||||
|
|
|
@ -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 };
|
||||
|
|
|
@ -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";
|
||||
|
|
Loading…
Reference in New Issue
Block a user