OpenRepo

Create repo systems with ease.

Developed by Zenith.

About

OpenRepo is all about ease. You shouldn't need to do too much work to get your app up and running. We took that mindset and developed an easy-to-use repo manager in JavaScript. The possiblities are endless for creations with repos, so we think everyone should be able to get in on the fun. As an added benefit, we patch cross-site scripting (XSS) for you! It uses ES6, so expect issues on older devices.

Setup

Setting up a repo object is very simple. You put in the storage key in the first argument. The second argument is completely optional, and is where you define your default items, proxy, and storage handler. Your default items are what are added by default, if not defined it will be []. The proxy is for the use of proxies automatically, just add in a "{{url}}" where the URL should go. The storage handler is for a custom storage handler, like "sessionStorage". If left null the storage handler will be localStorage. Each item in the optional object is also optional. You only have to define what you need.

var repos = new OpenRepo("key", {
	default: [],
	proxy: "https://proxy.com/{{url}}",
	storageHandler: localStorage
});

Add

Adding a repo is just as simple. You just plug in the URL.

repos.add("url");

Remove

Removing a repo can be done in two ways. You can pass the index of the repo, or pass the URL string. Whichever is easier for you.

// Remove with index
repos.remove(0);
// Remove with url
repos.remove("https://example.com/repo.json");

Reset

Reset the repos object.

repos.reset();

Get

The get function fetches a URL and returns the data using a promise function.

repos.get(url).then(function(data){
	// handle returned data
}).catch(function(status, statusText){
	//handle error
});

List

The list function can be used in two ways, both returning the data using a promise function. Passing no arguments through the list function will return the stored repos. Passing an object with the "fetch" key will get each repo and return its data. Adding "successHTML" to the object will return the data in the format that you pass. Adding "failureHTML" will return the error in the format that you pass.

repos.list({
	fetch: true
	successHTML: (repo) => (`${repo.name}`),
	failureHTML: (repo) => (`Failure loading ${repo.repo} at ${repo.index}`)
}).then(function(data){
	// handle returned array
}).catch(function(err){
	//handle error
});

Patch XSS

Patching XSS is simpler than ever. Just plug in a string or an object, and all your worries will go away. Returns the patched version of what you pass through it. We automatically use this in the add, get, and list functions. No need to worry.

var patchedItem = repos.patch(item);

Clean

Removing duplicates from an array is easy as ever. This function will return an array without any duplicate objects. This function is automatically used in the add function.

var cleanedArray = repos.clean(array);