From 4d5eb2f2caf399a4a01149922b0705fff5c826e4 Mon Sep 17 00:00:00 2001 From: HDegroote <75906619+HDegroote@users.noreply.github.com> Date: Mon, 2 Sep 2024 14:36:57 +0200 Subject: [PATCH] Add install and basic usage example --- README.md | 22 ++++++++++++++++++++++ package.json | 3 +++ 2 files changed, 25 insertions(+) diff --git a/README.md b/README.md index 848ef6a..e6cff60 100644 --- a/README.md +++ b/README.md @@ -2,3 +2,25 @@ Stats for Hypercores, with Prometheus support. +## Install + +``` +npm i hypercore-stats +``` + +## Usage + +``` +const Corestore = require('corestore') +const HypercoreStats = require('hypercore-stats') +const promClient = require('prom-client') + +const store = new Corestore('dummy-corestore') + +const hypercoreStats = HypercoreStats.fromCorestore(store) +hypercoreStats.registerPrometheusMetrics(promClient) + +// The Prometheus metrics are typically exposed to a metrics scraper +const metrics = await promClient.register.metrics() +console.log(metrics) +``` diff --git a/package.json b/package.json index 2495c25..f8cd551 100644 --- a/package.json +++ b/package.json @@ -22,6 +22,9 @@ "url": "https://github.com/holepunchto/hypercore-stats/issues" }, "homepage": "https://github.com/holepunchto/hypercore-stats#readme", + "files": [ + "index.js" + ], "devDependencies": { "brittle": "^3.6.1", "corestore": "^6.18.4",