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

hydra-box

v0.6.6

Published

Hydra Box middleware

Readme

hydra-box

Hydra is a machine readable description for APIs. Hydra Box extends the API description with links to the actual code, which provides the API. Hydra Box will use such an API description to create an express middleware which provides the API and dynamically loads the required code for it.

Usage

Application

Hydra-Box uses an object that implements the RDF/JS Store interface to read resources and find types of resources to identify matching operations. The resource is read using the IRI as named graph filter.

Here an example for a store on the local file system using rdf-store-fs:

const FlatMultiFileStore = require('rdf-store-fs/FlatMultiFileStore')

const store = new FlatMultiFileStore({
  baseIRI: 'http://localhost:9000/',
  path: 'store'
})

An Api object contains the dataset of the API documentation, where to find it and where to find the code. The static method .fromFile reads the dataset from the given file and creates an Api object with the given options.

const api = await Api.fromFile('api.ttl', {
  path: '/api',
  codePath: __dirname
})

Once both objects are created, the middleware can be used:

const app = express()
app.use(hydraBox(api, store))
app.listen(9000)

Operation

The operations must implement a Express routing handler interface ((req, res, next) => {}). Hydra-Box adds the @rdfjs/express-handler to handle incoming and outgoing RDF data. For GET requests with a matching IRI Template, the .dataset() and .quadStream() as defined by express-handler are also available to read the given variables. Additionally there is a hydra property assigned to req that contains more data about the request:

  req.hydra = {
    // Api object given as argument to the middleware
    api,
 
    // RDF/JS Store object given as argument to the middleware
    store,
 
    // requested URL as RDF/JS NamedNode
    term,
    
    // the selected hydra:Operation as Graph Pointer
    operation,

    // resource this request is about
    // This can be the requested URL for the case that a class operation is called.
    // For the case that a property operation is called, this is the subject of the triple used to link to the property.
    resource: {

      // IRI of the resource as RDF/JS NamedNode
      term,

      // content of the resource read from the store as RDF/JS Dataset 
      dataset,

      // rdf:types of the resource as @rdfjs/term-set
      types
    }
  }