Go to file
2021-07-27 16:12:14 +02:00
src fix typos and minor improvements 2021-07-12 15:49:31 +02:00
tests Added editConfig Function 2021-07-12 13:49:02 +02:00
.eslintrc.json first commit 2021-03-12 13:02:02 +01:00
.gitignore release 0.0.4 2021-07-24 18:24:52 +02:00
.prettierrc.json first commit 2021-03-12 13:02:02 +01:00
package-lock.json release 0.0.5. (0.0.4 deprecated) 2021-07-27 16:12:14 +02:00
package.json release 0.0.5. (0.0.4 deprecated) 2021-07-27 16:12:14 +02:00
README.md release 0.0.4 2021-07-24 18:24:52 +02:00
tsconfig.base.json issue 4 and 5 2021-07-03 12:47:06 +02:00
tsconfig.json issue 4 and 5 2021-07-03 12:47:06 +02:00

Listener-rss-aggregator


Brief

This is an aggregator of rss's listener (more information about it here : https://www.npmjs.com/package/listener-rss).

Usage

The basic usage is to use many listener-rss with a unique class.

import { ListenerRssAggregator } from 'Listener-rss-aggregator';


const path = '/my/data/directorie/bd.sqlite'  
const configAggregator = await ListenerRssAggregator.instantiateAggregator(
    path
  );
myManager = new ListenerRssAggregator(configAggregator);

const listenerConfig: ListenerRss.Config =
	{
    	"address": "fake.rss.service.1",
    	"timeloop": 10
  	};

ml.registerListener(listenerConfig);

ml.on('update', (obj) => {
	doSomethingWithNewEntries(obj);
})

ml.startAll();

//...

ml.stopAll();

Documentation

Why SQLITE

This project use SQLITE to store the listener-rss configs and keep an correct historic of this. Sqlite was choice for her difficulty to access and read it. The database dont need to be modify by the user.

Constructor

The constructor need to have a file to store the sqlite data. If the file does not exist he will be create, but the path must be valid.

Function

registerListener(listenerConfig)

He's create an new listener-rss with the corresponding config data. (More information about the listenerConfig here : https://www.npmjs.com/package/listener-rss)

startAll()

Start all the listener who are actually register

stopAll()

Start all the listener who are actually register

editConfig(callback)

This method will call the callback with the actual config of the Manager and override the actual config with the returned object.
e.g.:

myManager.editConfig((actualConfig: ListenerRss.Config[]) : ListenerRss.Config[] => {
	const modifiedConfig = doSomethingToThisConfig(actualConfig);
	return modifiedConfig;
})

Events

Like listener-rss, listener-rss-aggregator implement EventEmitter.
He call the same events than listener-rss. One call is made for each listener who triggered an event.
The update event return all the rss file content in one json object. The newEntries event return an object with a file items who's contains the new items detected. And a field called addressListener who's a string with the address of the the rss service.