-
Notifications
You must be signed in to change notification settings - Fork 3
ldp service Home
As part of the LDP standardization process, Steve Speicher and Sam Padgett created LDP.js: a JavaScript implementation of a W3C Linked Data Platform compliant server that uses MongoDB for storage services, and Monitoring and Analytics services. This was implemented to create a second LDP implementation (required by W3C, and to demonstrate an implementation in another language. Access the application at this route: ldpjs.mybluemix.net.
LDP.js is a Node.js Express app that:
- implements the LDP server using MongoDB for persistence
- provides a simple Web app that can create, read, update and delete LDP resources, and visualize them in a graph
This project leverages this work by refactoring LDP.js into two separate modules: ldp-app and ldp-service. This project refactor LDP.js into ldp-service to create a Node.js Express middleware module that supports LDP. This Express middleware can be easily reused in any app that requires an LDP server.
Project ldp-app uses the ldp-service middleware, provides additional middleware that supports graph visualization, and implements the Web application to do CRUD operations on LDP resources.
Configuration information is provided by the app using the ldp-service. Configuring the middleware requires an environment argument with the following fields:
- scheme: http or https
- host: the host name of the HTTP server
- port: the port of the HTTP server
- context: the path name of the root LDPC, e.g., /r/
- appBase: e.g., http://localhost:3000/
- ldpBase: e.g., http://localhost:3000/r/
- mongoURL: The MongoDB database URL, e.g., mongodb://localhost:27017/ldp
These properties are usually provided by a config.json file in the app, and may be overridden by things in the user's environment, or the VCAP Bluemix environment for a Bluemix app.
LDP uses URIs as identifiers while the express middleware req.originalUrl does not include the schema, host or port. ldp-service adds middleware method fullURL to capture the full URI for use in object identifiers.
ldp-services provide another middleware function, rawBody, to create a UTF8 encoded copy of the original request body for use in JSON and n3 parsers.
File service.js initializes the MongoDB database and sets the above, and other routes for handling LDP requests. It does this by using express() to create a subApp routed to the environment context (defaults to /r/) + '*'. /r represents the root LDPC for the LDP resources, allowing / and /public to be used by the app using the ldp-service.