query-registry
This package exports a class, Registry
, which provides methods to query the npm registry or a custom npm-like registry.
Features
- Provides methods for common use cases:
- Registry metadata
- Packuments (package documents)
- Package manifests
- Download counts
- Searching packages
- Typed response data
- Supports mirrors and custom npm-like registries
- Supports caching network requests
- Well documented and tested
Package Contents
View package contents on unpkg.
View repository on GitHub.
Install
Using npm
:
npm i query-registry
Using yarn
:
yarn add query-registry
Usage
Create the default registry backed by npm:
import { Registry } from 'query-registry';
const registry = new Registry();
console.log(registry.registry);
Create a custom registry:
import { Registry } from 'query-registry';
const registry = new Registry({
registry: 'https://registry.example.com',
mirrors: ['https://mirror.example.com'],
api: 'https://api.example.com',
suggestionsAPI: 'https://suggestions.example.com',
cache: new Map(),
});
console.log(registry.registry);
Get the package manifest for query-registry
's latest version:
import { Registry } from 'query-registry';
(async () => {
const registry = new Registry();
const manifest = await registry.getPackageManifest('query-registry');
console.log(manifest.name);
})();
Debug
Debug messages are available when the DEBUG
environment variable is set to query-registry
:
DEBUG="query-registry"
Test debug messages are available when the DEBUG
environment variable is set to query-registry-test
.
For more information, see the debug package.
License
MIT License
Copyright (c) 2020 Edoardo Scibona
See LICENSE file.