Skip to content

Commit 36cc6ee

Browse files
author
Andrei
committed
Merge pull request #129 from martinmr/documentation
Added basic documentation
2 parents 0c105a6 + cb71d3a commit 36cc6ee

1 file changed

Lines changed: 58 additions & 0 deletions

File tree

‎EXAMPLES.md‎

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
Examples
2+
========
3+
4+
ldnode binary
5+
-------------
6+
7+
ldnode can be started on its own by using the ldnode binary. Below are some examples with common configurations.
8+
9+
* Starting ldnode as an HTTP server.
10+
* ```
11+
$ ldnode --root /var/www
12+
```
13+
14+
* Starting ldnode as an HTTPS server with WebID+TLS authentication. This parameter requires that the user specifies the location of the key and the certificate used to start the HTTPS server with the help of the appropriate parameters.
15+
* ```
16+
$ ldnode --root /var/www --webid --cert ./cert.pem --key ./key.pem
17+
```
18+
19+
* Start HTTPS with custom error pages. ldnode will look for a file in the specified directory of the form <error-code>.html. If it's not found it will default to node's error page.
20+
* ```
21+
$ ldnode --root /var/www/ --webid --cert ./cert.pem --key ./key.pem --error-pages ./errors/
22+
```
23+
24+
* ldnode makes use of special files used for things such as access control, metadata management, subscription to changes, etc. These files are recognized by ldnode because of their suffix, which can be customized with the command line options that start with 'suffix'
25+
* ```
26+
$ ldnode --root /var/www/ --suffixMeta .altMeta --suffixAcl .altAcl
27+
```
28+
29+
Starting ldnode from a Node script
30+
-------------------------------------
31+
32+
ldnode can be started from an existing node application. There are two options available: creating the ldnode server on its own or creating a router that can be attached to an existing Express app.
33+
34+
For the first case, the createServer is a wrapper around the ldnode method which can be used as follows:
35+
36+
```
37+
var ldnode = require('ldnode');
38+
var options = {
39+
root: /var/www/
40+
} //an object specifying ldnode options (equivalent to the options provided by the command line interface).
41+
var server;
42+
var app = ldnode.createServer(options);
43+
app.listen(8080);
44+
```
45+
46+
In the second case, the ldnode method is used directly and the returned express app can be combined with an existing application.
47+
48+
```
49+
var existingApp; //Some existing Express app independent of ldnode.
50+
// ... Existing app initialization ...
51+
var app = ldnode(options);
52+
exisingApp.use('/mount-point', app);
53+
```
54+
55+
56+
57+
58+

0 commit comments

Comments
 (0)