Create your first LDP server
Purpose
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.
Prerequisites
You need to have NodeJS installed on your computer (use NodeJS version 12).
You also need docker and docker-compose installed on your machine.
Setup a new Moleculer project
Moleculer
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:
Choose yes
to all questions
You can now go to the newly-created directory:
Launch your local Jena Fuseki instance
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 :
Jena Fuseki is now available at the URL http://localhost:3030.
Please login - By default the login is admin
and the password is also admin
.
Please start by create a new dataset and name it localData
(case sensitive).
Your triples will be stored there.
You should get something like this:
Run Moleculer in dev mode
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:
Your instance of SemApps is available at http://localhost:3000.
You should get something like this:
Testing your LDP server
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 /persons
path. Indeed, if you go to http://localhost:3000/persons, you should see this LDP container:
Add data with the LDP server
Now, let's try to add a person to our database. Post an ActivityStreams Note to this LDP container with a tool like Insomnia, Postman or the RESTClient add-on for Firefox.
Retrieve the /persons
LDP container:
You should get this result:
You should also see the result on http://localhost:3000/persons:
Changes on Jena Fuseki
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!