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/core

v3.2.1

Published

Linked Data Fragments Server - Core

Downloads

29

Readme

Linked Data Fragments Server - Core

npm version

This package provides core classes with shared functionality for Linked Data Fragments servers.

This package should be used if you want to create your own LDF server configuration or LDF server module. If you just want to run a QPF server, you can make use of @ldf/server instead.

This package is a Linked Data Fragments Server module.

Usage in @ldf/server

This package exposes the the following context entries:

Controllers:

  • AssetsController: Responds to requests for assets. This is enabled by default in @ldf/server. Should be used as @type controller value.
  • DereferenceController: Responds to dereferencing requests. This is enabled by default in @ldf/server. Should be used as @type controller value.
  • NotFoundController: Responds to requests that cannot be resolved. This is enabled by default in @ldf/server. Should be used as @type controller value.
  • Controller: An abstract controller. Should be used as extends value when creating new controllers.
  • ControllerExtension: An abstract controller extension. Should be used as extends value when creating new controller extensions.
  • assetsDir: Path to a directory where assets can be found. Should be used as key in a Server config.
  • assetsPath: URL matching for assets. Should be used as key in a Server config.
  • dereference: A dereferencing entry for a datasource to a path. Should be used as key in a Server config.
  • dereferenceDatasource: The datasource of a dereferencing entry. Should be used as key in a dereferencing entry.
  • dereferencePath: The path of a dereferencing entry. Should be used as key in a dereferencing entry.

Datasources:

  • EmptyDatasource: An empty data source doesn't contain any quads. Should be used as @type datasource value.
  • IndexDatasource: A datasource that lists other data sources. This is enabled by default in @ldf/server. Should be used as @type datasource value.
  • MemoryDatasource: An abstract in-memory datasource. Should be used as extends value when creating new in-memory datasources.
  • Datasource: An abstract datasource. Should be used as extends value when creating new datasources.
  • datasourceTitle: The title of a datasource. Should be used as key in a datasource.
  • description: The description of a datasource. Should be used as key in a datasource.
  • datasourcePath: The relative path to the datasource from the baseURL. Should be used as key in a datasource.
  • enabled: If the datasource is enabled, by default true. Should be used as key in a datasource.
  • hide: If the datasource must be hide from the index, by default false. Should be used as key in a datasource.
  • graph: The default graph of the datasource. Should be used as key in a datasource.
  • license: The license of the datasource. Should be used as key in a datasource.
  • licenseUrl: A link to the license of the datasource. Should be used as key in a datasource.
  • copyright: The copyright statement of the datasource. Should be used as key in a datasource.
  • homepage: The homepage url of the datasource. Should be used as key in a datasource.
  • quads: If quad patterns are supported, otherwise only triple patterns are supported. Defaults to true. Should be used as key in a datasource.
  • file: The dataset file path. Should be used as key in a memory datasource.
  • datasourceUrl: The dataset file URL from the baseURL. Should be used as key in a memory datasource.

Routers:

  • DatasourceRouter: Routes URLs to data sources. This is enabled by default in @ldf/server. Should be used as @type router value.
  • PageRouter: Routes page numbers to offsets. This is enabled by default in @ldf/server. Should be used as @type router value.
  • Router: An abstract router. Should be used as extends value when creating new routers.
  • pageSize: The triple page size, which defaults to 100. Should be used as key in a page router.

Views:

  • ErrorHtmlView: Represents a 500 response in HTML. This is enabled by default in @ldf/server. Should be used as @type view value.
  • ForbiddenHtmlView: Represents a 401 response in HTML. This is enabled by default in @ldf/server. Should be used as @type view value.
  • NotFoundHtmlView: Represents a 404 response in HTML. This is enabled by default in @ldf/server. Should be used as @type view value.
  • ErrorRdfView: Represents a 500 response in RDF. This is enabled by default in @ldf/server. Should be used as @type view value.
  • NotFoundRdfView: Represents a 404 response in RDF. This is enabled by default in @ldf/server. Should be used as @type view value.
  • ViewCollection: Provides access to content-negotiated views by name. This is enabled by default in @ldf/server. Should be used as @type view value.
  • HtmlView: An abstract HTML view. Should be used as extends value when creating new HTML views.
  • RdfView: An abstract RDF view. Should be used as extends value when creating new RDF views.
  • View: An abstract view. Should be used as extends value when creating new views.
  • viewExtensions: A view extension. Should be used as key in a view.
  • viewCache: If views should be cached. Should be used as key in an HTML view.
  • viewHeader: The view header title. Should be used as key in an HTML view.

Other:

  • Server: An HTTP server that provides access to Linked Data Fragments. This is enabled by default in @ldf/server. Should be used as @type value.
  • title: The server name. Should be used as key in a Server config.
  • baseURL: The base URL path for the server. Should be used as key in a Server config.
  • port: The port the server will bind with. Should be used as key in a Server config.
  • workers: The number of server instances that will be started. Should be used as key in a Server config.
  • protocol: Explicitly set the protocol, default will be the protocol derived from the baseURL. Should be used as key in a Server config.
  • datasource or datasources: One or more datasources for the server. Should be used as key in a Server config.
  • prefixes: A collection of default URI prefixes. Should be used as key in a Server config.
  • prefix: The prefix label of a prefix entry. Should be used as key in a prefix entry.
  • uri: The prefix URI of a prefix entry. Should be used as key in a prefix entry.
  • responseHeaders: Default headers that should be set in responses. Should be used as key in a prefix entry.
  • headerName: The header name in a response header entry. Should be used as key in a response header entry.
  • headerValue: The header value in a response header entry. Should be used as key in a response header entry.
  • sslKey: Path to an SSL key. Should be used as key in a Server config.
  • sslCert: Path to an SSL certificate. Should be used as key in a Server config.
  • sslCa: Path to an SSL certificate authority. Should be used as key in a Server config.
  • logging: If the server should perform logging, defaults to false. Should be used as key in a Server config.
  • loggingFile: Path to a log file. Should be used as key in a Server config.
  • routers: Routers for the server. This is configured by default in @ldf/server. Should be used as key in a Server config.
  • controllers: Controllers for the server. This is configured by default in @ldf/server. Should be used as key in a Server config.
  • viewCollection: Override the default view collection. This is configured by default in @ldf/server. Should be used as key in a Server config.
  • views: Views for the server. This is configured by default in @ldf/server. Should be used as key in a Server config.
  • UrlData: A data object class for preset URL information. This is enabled by default in @ldf/server. Should be used as @type value.
  • urlData: The UrlData helper object. This is enabled by default in @ldf/server. Should be used as key in a Server config.
  • dataFactory: A factory object to construct RDFJS terms. @ldf/server uses the N3 DataFactory by default. Should be used as key in a Server config.

@ldf/server and @ldf/preset-qpf provide default instantiations of all core classes, which means that you don't have to define them in your config file yourself. The only thing you still need to do is defining different optional parameters, as shown below.

Example:

{
  "@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",
  "baseURL": "https://example.org/",
  "port": 3000,
  "workers": 2,
  "protocol": "http",

  "datasources": [
    {
      "@id": "urn:ldf-server:myDatasourceVersion1",
      "@type": "SparqlDatasource",
      "datasourceTitle": "My SPARQL source",
      "description": "My datasource with a SPARQL-endpoint back-end",
      "datasourcePath": "mysparql",
      "sparqlEndpoint": "https://dbpedia.org/sparql",
      "enabled": true,
      "hide": false,
      "license": "MIT",
      "licenseUrl": "http://example.org/my-license",
      "copyright": "This datasource is owned by Alice",
      "homepage": "http://example.org/alice"
    },
    {
      "@id": "urn:ldf-server:myDatasourceVersion2",
      "@type": "TurtleDatasource",
      "datasourceTitle": "My Turtle file",
      "description": "My dataset with a Turtle back-end",
      "datasourcePath": "myttl",
      "file": "path/to/file.ttl",
      "graph": "http://example.org/default-graph"
    }
  ],

  "prefixes": [
    { "prefix": "rdf",         "uri": "http://www.w3.org/1999/02/22-rdf-syntax-ns#" },
    { "prefix": "rdfs",        "uri": "http://www.w3.org/2000/01/rdf-schema#" },
    { "prefix": "owl",         "uri": "http://www.w3.org/2002/07/owl#" },
    { "prefix": "xsd",         "uri": "http://www.w3.org/2001/XMLSchema#" },
    { "prefix": "hydra",       "uri": "http://www.w3.org/ns/hydra/core#" },
    { "prefix": "void",        "uri": "http://rdfs.org/ns/void#" },
    { "prefix": "skos",        "uri": "http://www.w3.org/2004/02/skos/core#" },
    { "prefix": "dcterms",     "uri": "http://purl.org/dc/terms/" },
    { "prefix": "dc11",        "uri": "http://purl.org/dc/elements/1.1/" },
    { "prefix": "foaf",        "uri": "http://xmlns.com/foaf/0.1/" },
    { "prefix": "geo",         "uri": "http://www.w3.org/2003/01/geo/wgs84_pos#" },
    { "prefix": "dbpedia",     "uri": "http://dbpedia.org/resource/" },
    { "prefix": "dbpedia-owl", "uri": "http://dbpedia.org/ontology/" },
    { "prefix": "dbpprop",     "uri": "http://dbpedia.org/property/" }
  ],

  "logging": true,
  "loggingFile": "access.log",

  "dereference": [
    {
      "dereferenceDatasource": "urn:ldf-server:myDatasourceVersion2",
      "dereferencePath": "/resource/"
    }
  ],

  "responseHeaders": [
    { "headerName": "Access-Control-Allow-Origin",   "headerValue": "*" },
    { "headerName": "Access-Control-Allow-Headers",  "headerValue": "Accept-Datetime" },
    { "headerName": "Access-Control-Expose-Headers", "headerValue": "Content-Location,Link,Memento-Datetime" }
  ],

  "sslKey": "../core/config/certs/localhost-server.key",
  "sslCert": "../core/config/certs/localhost-server.crt",
  "sslCa": "../core/config/certs/localhost-ca.crt",

  "router": [
    {
      "@id": "preset-qpf:sets/routers.json#myPageRouter",
      "pageSize": 50
    }
  ]
}

Usage in other packages

When this module is used in a package other than @ldf/server, then the JSON-LD context https://linkedsoftwaredependencies.org/contexts/@ldf/core.jsonld must be imported.

For example:

{
  "@context": [
    "https://linkedsoftwaredependencies.org/bundles/npm/@ldf/core/^3.0.0/components/context.jsonld",
    "https://linkedsoftwaredependencies.org/bundles/npm/@ldf/preset-qpf/^3.0.0/components/context.jsonld",
    "https://linkedsoftwaredependencies.org/bundles/npm/@ldf/core/^3.0.0/components/context.jsonld"
  ],
  "@id": "urn:ldf-server:my",

  "controllers": [
    {
      "@id": "urn:ldf-server:myAssetsController",
      "@type": "AssetsController"
    },
    {
      "@id": "urn:ldf-server:myDereferenceController",
      "@type": "DereferenceController"
    },
    {
      "@id": "urn:ldf-server:myNotFoundController",
      "@type": "NotFoundController"
    }
  ],

  "datasources": [
    {
      "@id": "urn:ldf-server:myIndexDatasource",
      "@type": "IndexDatasource",
      "datasourceTitle": "dataset index",
      "datasourcePath": "/",
      "hide": true
    }
  ],

  "prefixes": [
    { "prefix": "rdf",         "uri": "http://www.w3.org/1999/02/22-rdf-syntax-ns#" },
    { "prefix": "rdfs",        "uri": "http://www.w3.org/2000/01/rdf-schema#" },
    { "prefix": "owl",         "uri": "http://www.w3.org/2002/07/owl#" },
    { "prefix": "xsd",         "uri": "http://www.w3.org/2001/XMLSchema#" },
    { "prefix": "hydra",       "uri": "http://www.w3.org/ns/hydra/core#" },
    { "prefix": "void",        "uri": "http://rdfs.org/ns/void#" }
  ],

  "routers": [
    {
      "@id": "urn:ldf-server:myDatasourceRouter",
      "@type": "DatasourceRouter"
    },
    {
      "@id": "urn:ldf-server:myPageRouter",
      "@type": "PageRouter"
    }
  ],

  "views": [
    {
      "@id": "urn:ldf-server:myErrorHtmlView",
      "@type": "ErrorHtmlView"
    },
    {
      "@id": "urn:ldf-server:myErrorRdfView",
      "@type": "ErrorRdfView"
    },
    {
      "@id": "urn:ldf-server:myForbiddenHtmlView",
      "@type": "ForbiddenHtmlView"
    },
    {
      "@id": "urn:ldf-server:myNotFoundHtmlView",
      "@type": "NotFoundHtmlView"
    },
    {
      "@id": "urn:ldf-server:myNotFoundRdfView",
      "@type": "NotFoundRdfView"
    }
  ]

  // Same as above...
}

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.