Skip to main content

LDP

This package allows you to setup LDP direct containers in which LDP resources can be manipulated.

Features#

  • Handles triples, turtle and JSON-LD format
  • Automatic creation of containers on server start
  • Full container management: create, attach resources, detach, clear, delete...

Dependencies#

Sub-services#

Install#

$ npm install @semapps/ldp --save

Usage#

const { LdpService } = require('@semapps/ldp');
module.exports = {
mixins: [LdpService],
settings: {
baseUrl: 'http://localhost:3000/',
ontologies : [
{
prefix: 'rdf',
url: 'http://www.w3.org/1999/02/22-rdf-syntax-ns#'
},
{
prefix: 'ldp',
url: 'http://www.w3.org/ns/ldp#',
},
...
],
containers: [
{
path: '/resources'
}
],
defaultContainerOptions: {
// See below
}
}
};

Settings#

PropertyTypeDefaultDescription
baseUrlStringrequiredBase URL of the LDP server
ontologies[Object]requiredList of ontology used (see example above)
containers[Object]requiredList of containers to set up, with their options
defaultContainerOptions[Object]Default options for all containers (see below)

Container options#

PropertyTypeDefaultDescription
acceptStringtext/turtleType to return (application/ld+json, text/turtle or application/n-triples)
jsonContext[Any]JSON context to use to format results
dereference[Array][]Properties to dereference, prefixed with their ontology. You can define sub-predicates separated by /
queryDepthInteger0Depth of blank nodes to dereference

API routes#

These routes are automatically added to the ApiGateway service.

RouteAction called
GET /<container>ldp.container.get
POST /<container>ldp.resource.post
GET /<container>/<resource>ldp.resource.get
PATCH /<container>/<resource>ldp.resource.patch
PUT /<container>/<resource>ldp.resource.put
DELETE /<container>/<resource>ldp.resource.delete