http

Download and add registry items from an arbitrary HTTP endpoint.

SourceOfficialDefault

The http provider is the simplest provider by far. To add registry items simply provide the base url of the registry.json file:

jsrepo add https://example.com/registry

jsrepo will then find the registry.json file from https://example.com/registry/registry.json.

Deploying a registry to your own website

When deploying a registry to your own website you will want to use the distributed output type:

jsrepo.config.ts
import { defineConfig } from "jsrepo";
import { distributed } from "jsrepo/outputs"; 

export default defineConfig({
	// `dir` is the directory to output the files to
	outputs: [distributed({ dir: "./public/r" })], 
});

This will output your registry to the public/r directory which might look something like this:

registry.json
button.json
utils.json

Users will then be able to add registry items to their project by running:

jsrepo add https://your-website.com/r

Authentication

To authenticate with the http provider you can run the following command:

jsrepo auth http

You will then be prompted to select or enter the name of a registry to authenticate to.

Once authenticated that token will continue to be used for that registry until you logout.

You can logout of your account by running:

jsrepo auth http --logout

Options

When using the http provider you can provide a custom base url to override the authorization header for a specific site. This can be useful if a website is using an authorization method different than the default Bearer token.

jsrepo.config.ts
import { defineConfig } from "jsrepo";
import { http } from "jsrepo/providers";

export default defineConfig({
	providers: [
		http({
			// url to your registry
			baseUrl: "https://your-website.com/r",
			// custom auth header
			authHeader: (token) => ({ token: `${token}` }),
		}),
	],
});

Now when you use https://your-website.com/r it will use the custom auth header you provided.