npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@lde/sparql-monitor

v0.4.0

Published

Monitor SPARQL endpoints with periodic checks

Readme

SPARQL Monitor

Monitor SPARQL endpoints with periodic checks, storing observations in PostgreSQL.

Installation

npm install @lde/sparql-monitor

CLI Usage

The easiest way to use the monitor is via the CLI with a configuration file.

Quick Start

  1. Create a configuration file (TypeScript, JavaScript, JSON, or YAML)
  2. Run the monitor
# Start continuous monitoring
npx sparql-monitor start

# Run a one-off check
npx sparql-monitor check

# Check a specific monitor
npx sparql-monitor check dbpedia

# Use a custom config path
npx sparql-monitor start --config ./configs/production.config.ts

TypeScript Config (sparql-monitor.config.ts)

import { defineConfig } from '@lde/sparql-monitor';

export default defineConfig({
  databaseUrl: process.env.DATABASE_URL,
  intervalSeconds: 300,
  monitors: [
    {
      identifier: 'dbpedia',
      endpointUrl: new URL('https://dbpedia.org/sparql'),
      query: 'ASK { ?s ?p ?o }',
    },
    {
      identifier: 'wikidata',
      endpointUrl: new URL('https://query.wikidata.org/sparql'),
      query: 'SELECT * WHERE { ?s ?p ?o } LIMIT 1',
    },
  ],
});

YAML Config (sparql-monitor.config.yaml)

databaseUrl: ${DATABASE_URL}
intervalSeconds: 300
monitors:
  - identifier: dbpedia
    endpointUrl: https://dbpedia.org/sparql
    query: ASK { ?s ?p ?o }
  - identifier: wikidata
    endpointUrl: https://query.wikidata.org/sparql
    query: SELECT * WHERE { ?s ?p ?o } LIMIT 1

Environment Variables

Create a .env file for sensitive configuration:

DATABASE_URL=postgres://user:pass@localhost:5432/monitoring

The CLI automatically loads .env files.

Config Auto-Discovery

The CLI searches for configuration in this order:

  1. sparql-monitor.config.{ts,mts,js,mjs,json,yaml,yml}
  2. .sparql-monitorrc
  3. package.json"sparql-monitor" key

Programmatic Usage

import {
  MonitorService,
  PostgresObservationStore,
  type MonitorConfig,
} from '@lde/sparql-monitor';

// Define monitors
const monitors: MonitorConfig[] = [
  {
    identifier: 'dbpedia',
    endpointUrl: new URL('https://dbpedia.org/sparql'),
    query: 'ASK { ?s ?p ?o }',
  },
  {
    identifier: 'wikidata',
    endpointUrl: new URL('https://query.wikidata.org/sparql'),
    query: 'SELECT * WHERE { ?s ?p ?o } LIMIT 1',
  },
];

// Create store (initializes database schema automatically)
const store = await PostgresObservationStore.create(
  'postgres://user:pass@localhost:5432/db'
);

// Create service with polling interval
const service = new MonitorService({
  store,
  monitors,
  intervalSeconds: 300, // Check all endpoints every 5 minutes
});

// Start periodic monitoring
service.start();

// Or perform immediate checks
await service.checkAll();
await service.checkNow('dbpedia');

// Get latest observations
const observations = await store.getLatest();
for (const [identifier, observation] of observations) {
  console.log(
    `${identifier}: ${observation.success ? 'OK' : 'FAIL'} (${
      observation.responseTimeMs
    }ms)`
  );
}

// Stop monitoring and close the store
service.stop();
await store.close();

Database Initialisation

PostgresObservationStore.create() automatically initializes the database schema:

  • observations table for storing check results
  • latest_observations materialized view for efficient queries
  • Required indexes

This is idempotent and safe to call on every startup.

Query Types

The monitor supports ASK, SELECT, and CONSTRUCT queries. The check is considered successful if the query executes without error.