JSPM

  • Created
  • Published
  • Downloads 1
  • Score
    100M100P100Q40088F
  • License MIT

Linked Data Platform

Package Exports

  • ldnode

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (ldnode) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

ldnode

Build Status NPM Version Gitter chat

Ldnode implements the Linked Data Platform and Solid in NodeJS. This is all you need to run distributed Linked Data apps on top of the file system.

You can run ldnode as a command-line tool or as a library for your Express app.

Features

  • Linked Data Platform compliant HEAD, OPTIONS, GET, PUT, POST, PATCH, DELETE
  • Proxy for cross-site data access
  • Access control using Web Access Control
  • WebID+TLS Authentication
  • Real-time live updates (using WebSockets)
  • Identity provider for WebID+TLS

Command line tool

npm install -g ldnode

The command line tool has the following options

Usage: ldnode [options]

Options:
   -v, --verbose               Print the logs to console
   --version                   Print current ldnode version
   -m, --mount                 Where to mount Linked Data Platform (default: '/')
   -r, --root                  Root location on the filesystem to serve resources
   -p, --port                  Port to use
   -K, --key                   Path to the ssl key
   -C, --cert                  Path to the ssl cert
   --webid                     Enable WebID+TLS authentication
   -s, --secret                HTTP Session secret key (e.g. "your secret phrase")
   -fU, --force-user           Force a WebID to always be logged in (usefull when offline)
   -P, --proxy                 Use a proxy on example.tld/proxyPath
   --no-live                   Disable live support through WebSockets
   -sA, --suffix-acl           Suffix for acl files (default: '.acl')
   -sM, --suffix-meta          Suffix for metadata files (default: '.meta')
   -sE, --suffix-sse           Suffix for SSE files (default: '.events')
   --no-error-pages            Disable custom error pages (use Node.js default pages instead)
   --error-pages               Folder from which to look for custom error pages files (files must be named <error-code>.html -- eg. 500.html)
   --skin                      URI to a skin to load (default: https://linkeddata.github.io/warp/#/list/)

Run your server

To start your Linked Data Platform server:

$ ldnode --port 80

To start your Solid server:

$ ldnode --webid --port 443 --cert /path/to/cert --key /path/to/key

Note: In order to support WebID+TLS authentication you will need --webid but also the flags --cert and --key to specify the keypair of your SSL certificate, since WebID+TLS will only work over HTTPS.

Library

Install

npm install

Usage

The library provides two APIs:

  • ldnode.createServer(settings): starts a ready to use Express app.
  • lnode(settings): creates an Express that you can mount in your existing express app.

In case the settings is not passed, then it will start with the following default settings.

{
  cache: 0, // Set cache time (in seconds), 0 for no cache
  live: true, // Enable live support through WebSockets
  root: './', // Root location on the filesystem to serve resources
  secret: 'node-ldp', // Express Session secret key
  cert: false, // Path to the ssl cert
  key: false, // Path to the ssl key
  mount: '/', // Where to mount Linked Data Platform
  webid: false, // Enable WebID+TLS authentication
  suffixAcl: '.acl', // Suffix for acl files
  suffixSSE: '.events', // Suffix for SSE files
  proxy: false, // Where to mount the proxy
  errorHandler: false, // function(err, req, res, next) to have a custom error handler
  errorPages: false // specify a path where the error pages are
}

Have a look at the following examples or in the examples/ folder for more complex ones

Simple

You can create an ldnode server ready to use using ldnode.createServer(opts)

var ldnode = require('ldnode')
var ldp = ldnode.createServer({
    key: '/path/to/sslKey.pem',
    cert: '/path/to/sslCert.pem',
    webid: true
})
ldp.listen(3000, function() {
  // Started Linked Data Platform
})
Advanced

You can integrate ldnode in your existing Express app, by mounting the ldnode app on a specific path using lnode(opts).

var ldnode = require('ldnode')
var app = require('express')()
app.use('/test', ldnode(yourSettings))
app.listen(3000, function() {
  // Started Express app with ldp on '/test'
})
...
Logs

Run your app with the DEBUG variable set:

$ DEBUG="ldnode:*" node app.js

Tests

$ npm test
# running the tests with logs
$ DEBUG="ldnode:*" npm test

In order to test a single component, you can run

npm run test-(acl|formats|params|patch)

Contributing

ldnode is only possible due to the excellent work of the following contributors:

Tim Berners-Lee GitHub/timbl Twitter/@timberners_lee webid
Nicola Greco GitHub/nicola Twitter/@nicolagreco webid
Martin Martinez Rivera GitHub/martinmr
Andrei Sambra GitHub/deiu Twitter/@deiu webid

Do you want to contribute?

Have a look at CONTRIBUTING.md.

License

MIT