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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@ldf/server

v3.3.0

Published

Quad Pattern Fragments Linked Data Fragments Server

Downloads

27

Readme

Linked Data Fragments Server - Quad Pattern Fragments

npm version Docker Pulls

A Linked Data Fragments server with Quad Pattern Fragments (a.k.a. Triple Pattern Fragments) support.

This package has been renamed from ldf-server to @ldf/server. Find more information about migrating from ldf-server 2.x.x on our wiki.

This package is a Linked Data Fragments Server module.

Motivation

On today's Web, Linked Data is published in different ways, which include data dumps, subject pages, and results of SPARQL queries. We call each such part a Linked Data Fragment.

The issue with the current Linked Data Fragments is that they are either so powerful that their servers suffer from low availability rates (as is the case with SPARQL), or either don't allow efficient querying.

Instead, this server offers Quad Pattern Fragments (a.k.a. Triple Pattern Fragments). Each Quad Pattern Fragment offers:

  • data that corresponds to a quad/triple pattern (example).
  • metadata that consists of the (approximate) total triple count (example).
  • controls that lead to all other fragments of the same dataset (example).

An example server is available at data.linkeddatafragments.org.

Install the server

This server requires Node.js 10.0 or higher and is tested on OSX and Linux. To install, execute:

$ [sudo] npm install -g @ldf/server

Use the server

Configure the data sources

First, create a configuration file config.json similar to config/config-example.json, in which you detail your data sources. For example, this configuration uses an HDT file and a SPARQL endpoint as sources:

{
  "@context": "https://linkedsoftwaredependencies.org/bundles/npm/@ldf/server/^3.0.0/components/context.jsonld",
  "@id": "urn:ldf-server:my",
  "import": "preset-qpf:config-defaults.json",

  "title": "My Linked Data Fragments server",

  "datasources": [
    {
      "@id": "urn:ldf-server:myHdtDatasource",
      "@type": "HdtDatasource",
      "datasourceTitle": "DBpedia 2014",
      "description": "DBpedia 2014 with an HDT back-end",
      "datasourcePath": "dbpedia",
      "hdtFile": "data/dbpedia2014.hdt"
    },
    {
      "@id": "urn:ldf-server:mySparqlDatasource",
      "@type": "SparqlDatasource",
      "datasourceTitle": "DBpedia (Virtuoso)",
      "description": "DBpedia with a Virtuoso back-end",
      "datasourcePath": "dbpedia-sparql",
      "sparqlEndpoint": "https://dbpedia.org/sparql"
    }
  ]
}

The following sources are supported out of the box:

Support for new sources is possible by creating a new module implementing the Datasource interface.

Start the server

After creating a configuration file, execute

$ ldf-server config.json 5000 4

Here, 5000 is the HTTP port on which the server will listen, and 4 the number of worker processes.

Now visit http://localhost:5000/ in your browser.

Reload running server

You can reload the server without any downtime in order to load a new configuration or version. In order to do this, you need the process ID of the server master process. One possibility to obtain this are the server logs:

$ bin/ldf-server config.json
Master 28106 running.
Worker 28107 running on http://localhost:3000/.

If you send the server a SIGHUP signal:

$ kill -s SIGHUP 28106

it will reload by replacing its workers.

Note that crashed or killed workers are always replaced automatically.

(Optional) Set up a reverse proxy

A typical Linked Data Fragments server will be exposed on a public domain or subdomain along with other applications. Therefore, you need to configure the server to run behind an HTTP reverse proxy. To set this up, configure the server's public URL in your server's config.json:

{
  "title": "My Linked Data Fragments server",
  "baseURL": "http://data.example.org/",
  "datasources": { … }
}

Then configure your reverse proxy to pass requests to your server. Here's an example for nginx:

server {
  server_name data.example.org;

  location / {
    proxy_pass http://127.0.0.1:3000$request_uri;
    proxy_set_header Host $http_host;
    proxy_pass_header Server;
  }
}

Change the value 3000 into the port on which your Linked Data Fragments server runs.

If you would like to proxy the data in a subfolder such as http://example.org/my/data, modify the baseURL in your config.json to "http://example.org/my/data" and change location from / to /my/data (excluding a trailing slash).

(Optional) Running under HTTPS

HTTPS can be enabled in two ways: natively by the server, or through a proxy (explained above).

With native HTTPS, the server will establish the SSL layer. Set the following values in your config file to enable this:

 {
   "protocol": "https",
   "ssl": {
     "keys" : {
       "key": "./private-key-server.key.pem",
       "ca": ["./root-ca.crt.pem"],
       "cert": "./server-certificate.crt.pem"
    }
  }
}  

If protocolis not specified, it will derive the protocol from the baseURL. Hence, HTTPS can also be enabled as such:

 {
   "baseURL": "https://data.example.org/",
   "ssl": {
     "keys" : {
       "key": "./private-key-server.key.pem",
       "ca": ["./root-ca.crt.pem"],
       "cert": "./server-certificate.crt.pem"
    }
  }
}  

If you decide to let a proxy handle HTTPS, use this configuration to run the server as http, but construct links as https (so clients don't break):

 {
   "protocol": "http",
   "baseURL": "https://data.example.org/",
 }  

(Optional) Running in a Docker container

If you want to rapidly deploy the server as a microservice, you can build a Docker container as follows:

$ docker build -t ldf-server .

After that, you can run your newly created container:

$ docker run -p 3000:3000 -t -i --rm -v $(pwd)/config.json:/tmp/config.json ldf-server /tmp/config.json

(Optional) Host historical version of datasets

You can enable the Memento protocol to offer different versions of an evolving dataset.

Relation to other modules

This package should be used if you want to use an LDF server with the QPF feature. If you want to extend this server with additional modules, you can make use of @ldf/preset-qpf instead.

Concretely, it configures the following packages:

License

The Linked Data Fragments server is written by Ruben Verborgh, Miel Vander Sande, Ruben Taelman and colleagues.

This code is copyrighted by Ghent University – imec and released under the MIT license.