UNPKG

1.21 kBJavaScriptView Raw
1import { fetchFromRegistry } from '../utils/fetch-from-registry.esm.js';
2
3/**
4 * `getRegistryMetadata` returns the metadata describing the registry itself.
5 *
6 * @param registry - URL of the registry (default: npm registry)
7 * @param cached - accept cached responses (default: `true`)
8 *
9 * @example
10 * Get the metadata for the npm registry:
11 *
12 * ```typescript
13 * import { getRegistryMetadata } from 'query-registry';
14 *
15 * (async () => {
16 * const metadata = await getRegistryMetadata();
17 *
18 * // Output: 'registry'
19 * console.log(metadata.db_name);
20 * })();
21 * ```
22 *
23 * @example
24 * Get the metadata for a custom registry:
25 *
26 * ```typescript
27 * import { getRegistryMetadata } from 'query-registry';
28 *
29 * (async () => {
30 * const metadata = await getRegistryMetadata({ registry: 'https://example.com' });
31 * })();
32 * ```
33 *
34 * @see {@link RegistryMetadata}
35 * @see {@link npmRegistry}
36 */
37
38async function getRegistryMetadata({
39 registry,
40 cached
41} = {}) {
42 const endpoint = '/';
43 return fetchFromRegistry({
44 registry,
45 mirrors: [],
46 endpoint,
47 cached
48 });
49}
50
51export { getRegistryMetadata };
52//# sourceMappingURL=get-registry-metadata.esm.js.map