EgoJS
The actual 'core' for EgoJS. This class saves the packages into the local db, manages the cache, makes the requests and returns the package stats.
Constructor Summary
Public Constructor | ||
public |
Class constructor |
Member Summary
Public Members | ||
public set |
Set the module settings object. |
|
public get |
Get the module settings object. |
Method Summary
Public Methods | ||
public |
Add a new package to the database. |
|
public |
deleteCache(id: Number) Delete all the cached requests for all the packages or for an specific one. |
|
public |
editPackage(id: Number, name: String, repository: String, npmPackage: String): Promise<Object, Error> Edit the information of an existing package. |
|
public |
Get a package from the database. |
|
public |
Get the stats for all the packages saved on the database. |
|
public |
Remove a package from the database. |
|
public |
setGitHubToken(token: String) Shortcut method to set the GitHub token on the settings. |
Public Constructors
Public Members
Public Methods
public addPackage(name: String, repository: String, npmPackage: String): Promise<Object, Error> source
Add a new package to the database.
public deleteCache(id: Number) source
Delete all the cached requests for all the packages or for an specific one.
Params:
Name | Type | Attribute | Description |
id | Number |
|
If specified, the cache will be only removed for that package. |
public editPackage(id: Number, name: String, repository: String, npmPackage: String): Promise<Object, Error> source
Edit the information of an existing package.
public getPackage(id: String | Number, property: String): Promise<Object, Error> source
Get a package from the database.
Params:
Name | Type | Attribute | Description |
id | String | Number | By default, this is the package unique id, but if you change the value of the second argument, this can be the value you are looking for. |
|
property | String |
|
The name of the filter property that will be used to make the search. |
Example:
instance.getPackage(12)
.then((pckg) => doSomethig(pckg))
.catch((err) => console.log(err));
// ...or...
instance.getPackage('The Pckg', 'name')
.then((pckg) => doSomethig(pckg))
.catch((err) => console.log(err));
public getStats(): Promise<Array, Error> source
Get the stats for all the packages saved on the database.
Example:
instance.getStats()
.then((list) => {
for (let i = 0; i < list.length; i++) {
console.log('Package ', list[i].name);
}
});
public removePackage(id: String | Number, property: String): Promise<Object, Error> source
Remove a package from the database.
Params:
Name | Type | Attribute | Description |
id | String | Number | By default, this is the package unique id, but if you change the value of the second argument, this can be the value that the property has to have. |
|
property | String |
|
The name of the filter property that will be used to make the search. |
Example:
instance.removePackage(12)
.then((pckg) => confirmRemove(pckg))
.catch((err) => console.log(err));
// ...or...
instance.removePackage('The Pckg', 'name')
.then((pckg) => confirmRemove(pckg))
.catch((err) => console.log(err));