Compare commits
	
		
			4 Commits
		
	
	
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
						 | 
					ffa91fcee8 | ||
| 
						 | 
					7ba511056b | ||
| 
						 | 
					fcdd468a4d | ||
| 
						 | 
					1b36afbb34 | 
							
								
								
									
										2
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							@@ -1,3 +1,3 @@
 | 
			
		||||
build/
 | 
			
		||||
node_modules/
 | 
			
		||||
.idea/
 | 
			
		||||
.idea/
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										41
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										41
									
								
								README.md
									
									
									
									
									
								
							@@ -1,19 +1,20 @@
 | 
			
		||||
# Listener-rss-agregator
 | 
			
		||||
# Listener-rss-aggregator
 | 
			
		||||
---
 | 
			
		||||
## Brief
 | 
			
		||||
This is an agregator of rss's listener (more information about it here : ).
 | 
			
		||||
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.
 | 
			
		||||
```typescript
 | 
			
		||||
import { ManageListener } from 'Listener-rss-agregator';
 | 
			
		||||
import { ListenerRssAggregator } from 'Listener-rss-aggregator';
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
const path = '/my/data/directorie/bd.sqlite'
 | 
			
		||||
const myManager = new ManageListener(path);
 | 
			
		||||
const path = '/my/data/directorie/bd.sqlite'  
 | 
			
		||||
const configAggregator = await ListenerRssAggregator.instantiateAggregator(
 | 
			
		||||
    path
 | 
			
		||||
  );
 | 
			
		||||
myManager = new ListenerRssAggregator(configAggregator);
 | 
			
		||||
 | 
			
		||||
await ml.load(); // he is reading the database
 | 
			
		||||
 | 
			
		||||
const listenerConfig =
 | 
			
		||||
const listenerConfig: ListenerRss.Config =
 | 
			
		||||
	{
 | 
			
		||||
    	"address": "fake.rss.service.1",
 | 
			
		||||
    	"timeloop": 10
 | 
			
		||||
@@ -23,7 +24,6 @@ ml.registerListener(listenerConfig);
 | 
			
		||||
 | 
			
		||||
ml.on('update', (obj) => {
 | 
			
		||||
	doSomethingWithNewEntries(obj);
 | 
			
		||||
	ml.save();
 | 
			
		||||
})
 | 
			
		||||
 | 
			
		||||
ml.startAll();
 | 
			
		||||
@@ -31,7 +31,6 @@ ml.startAll();
 | 
			
		||||
//...
 | 
			
		||||
 | 
			
		||||
ml.stopAll();
 | 
			
		||||
ml.save();
 | 
			
		||||
``` 
 | 
			
		||||
## Documentation
 | 
			
		||||
### Why SQLITE
 | 
			
		||||
@@ -39,16 +38,24 @@ This project use SQLITE to store the listener-rss configs and keep an correct hi
 | 
			
		||||
### 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
 | 
			
		||||
#### `load()`
 | 
			
		||||
An async method who would read the sqlite file and create the corresponding objects
 | 
			
		||||
#### `save()`
 | 
			
		||||
An method who would store the actual configuration and erase the older
 | 
			
		||||
#### `registerListener(listenerConfig)`
 | 
			
		||||
He's create an new listener-rss with the corresponding config data. (More information about the listenerConfig here : )
 | 
			
		||||
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.:
 | 
			
		||||
```typescript
 | 
			
		||||
myManager.editConfig((actualConfig: ListenerRss.Config[]) : ListenerRss.Config[] => {
 | 
			
		||||
	const modifiedConfig = doSomethingToThisConfig(actualConfig);
 | 
			
		||||
	return modifiedConfig;
 | 
			
		||||
})
 | 
			
		||||
 | 
			
		||||
```
 | 
			
		||||
### Events
 | 
			
		||||
Like listener-rss, listener-rss-agregator implement EventEmitter.  
 | 
			
		||||
The event who's used is named `update`. He's called for each new entries detection per listener. he's giving back an object who contains all the new entries
 | 
			
		||||
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. 
 | 
			
		||||
							
								
								
									
										8
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										8
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							@@ -1,12 +1,12 @@
 | 
			
		||||
{
 | 
			
		||||
  "name": "listener-rss-agregator",
 | 
			
		||||
  "version": "0.0.3",
 | 
			
		||||
  "name": "listener-rss-aggregator",
 | 
			
		||||
  "version": "0.0.4",
 | 
			
		||||
  "lockfileVersion": 2,
 | 
			
		||||
  "requires": true,
 | 
			
		||||
  "packages": {
 | 
			
		||||
    "": {
 | 
			
		||||
      "name": "listener-rss-agregator",
 | 
			
		||||
      "version": "0.0.3",
 | 
			
		||||
      "name": "listener-rss-aggregator",
 | 
			
		||||
      "version": "0.0.4",
 | 
			
		||||
      "license": "MIT",
 | 
			
		||||
      "dependencies": {
 | 
			
		||||
        "@databases/sqlite": "^3.0.0",
 | 
			
		||||
 
 | 
			
		||||
@@ -1,6 +1,6 @@
 | 
			
		||||
{
 | 
			
		||||
  "name": "listener-rss-agregator",
 | 
			
		||||
  "version": "0.0.3",
 | 
			
		||||
  "name": "listener-rss-aggregator",
 | 
			
		||||
  "version": "0.0.5",
 | 
			
		||||
  "description": "",
 | 
			
		||||
  "main": "build/index.js",
 | 
			
		||||
  "types": "build/index.d.ts",
 | 
			
		||||
@@ -9,9 +9,12 @@
 | 
			
		||||
    "url": "https://zeteo.me/gitea/Outils-PeerTube/listener-rss-agregators/issues"
 | 
			
		||||
  },
 | 
			
		||||
  "files": [
 | 
			
		||||
    "build/"
 | 
			
		||||
    "build/",
 | 
			
		||||
    "README.md",
 | 
			
		||||
    "package.json"
 | 
			
		||||
  ],
 | 
			
		||||
  "scripts": {
 | 
			
		||||
    "prepublish": "npm run build",
 | 
			
		||||
    "test": "cross-env TS_NODE_PROJECT='./tests/tsconfig.json' mocha --require ts-node/register ./tests/**/*-spec.ts",
 | 
			
		||||
    "build": "tsc"
 | 
			
		||||
  },
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user