LDP means Linked Data Platform. It is a W3C Recommendation that defines a set of rules for HTTP operations on web resources to provide an architecture for read-write Linked Data on the web.
An LDP server is therefore useful for making HTTP requests to a semantic database (in which the Linked Data is stored) without operating directly on the database.
In this guide, you will :
- Create a semapps instance from a template using moleculer;
- Create a Jena Fuseki instance to store some data;
- Add data to your semantic data base using your LDP server.
You need to have NodeJS installed on your computer (use NodeJS version 12).
Moleculer is a back-end framework that facilitates the development of microservices that run by messages (and on different servers). It uses Node.js.
The moleculer-cli tool is a command line tool that allows you to initialize new projects from templates for instance.
First, you need to install the moleculer-cli tool globally. To do so, open a terminal and runs the following command:
Then, initialize a new project based on a semapps template with this command:
yes to all questions (except maybe for webACL)
You can now go to the newly-created directory:
Jena Fuseki is a semantic triple store. It is where your app's data will be stored.
In the "my-project" directory, runs the following command :
If you get this error message:
Run the following command (taken from here):
Jena Fuseki is now available at the URL http://localhost:3030.
Please login - By default the login is
admin and the password is also
Please start by create a new dataset and name it
localData (case sensitive), and choose a persistant storage.
Your triples will be stored there.
You should get something like this:
Now that your semantic data base is ready, you can launch you LDP server, which has been created when you've initialized your semapps instance.
To do so, open an other terminal and run the following command in your my-project directory:
If you have selected the
webAcl option above, then you will need to configure the OIDC provider by entering these variables in the file
.env.local at the root folder of your project.
Your instance of SemApps is available at http://localhost:3000.
You should get something like this:
Now, it is time to test your LDP server, which means that you will try to update your data base by using this LDP server and not by using Jena Fuseki.
By default, the LDP service will create a LDP container in the
/users path. Indeed, if you go to http://localhost:3000/users, you should see this LDP container:
/users LDP container:
You should get this result:
If you had selected the
webAcl option earlier when creating your project, then you will get instead
403 Forbidden error.
This is normal because your dataset is protected and you must log-in before your can edit or add any data.
For that, you will have to configure an OIDC provider, add your user webId to the list of superAdmins (in
services/webacl.service.js), and modify the ACLs of the users container. But this is out of scope of this tutorial.
For a shortcut, you can manually add a permission to the
users container, so that
anonymous users can add new users to it.
In order to achieve that, you have to connect to the web interface of fuseki a http://localhost:3030 and run this query on the
/localData/update endpoint :
You will then be allowed to run the
POST /users query stated above.
Please note that you just opened a security hole in your instance by allowing any anonymous user with write access to the
users container. After you performed your first test, you should remove the triple you just created in the webacl graph (use the snippet below), and configure properly your OIDC provider and superAdmins list.
To test if our LDP server is really working, you should check if the data has been added to our Jena Fuseki instance.
Go to http://localhost:3030/dataset.html and make a SPARQL query to get all of your data. You should get the following result:
Guillaume Cousin has been added to the database : the LDP server works!