Skip to content

Commit

Permalink
Added the 'loadPhysicalFolder' example
Browse files Browse the repository at this point in the history
  • Loading branch information
AdrienCastex committed Jun 16, 2017
1 parent 595bcf1 commit 7ed6c7a
Show file tree
Hide file tree
Showing 8 changed files with 62 additions and 0 deletions.
11 changes: 11 additions & 0 deletions examples/loadPhysicalFolder/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Custom Web Resource

This is an example to show how to load a physical folder.

## Usage

### Execute

```bash
node index.js
```
3 changes: 3 additions & 0 deletions examples/loadPhysicalFolder/data/a.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Hello friends!

Is it ok?
Empty file.
Empty file.
Empty file.
17 changes: 17 additions & 0 deletions examples/loadPhysicalFolder/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
const webdav = require('webdav-server');

webdav.PhysicalFolder.loadFromPath('./data', (e, folder) => {
if(e) throw e;

const server = new webdav.WebDAVServer({
port: 1900
});

server.addResourceTree(folder, (e) => {
if(e) throw e;

server.start((s) => {
console.log('Server started on port ' + s.address().port + '.');
});
});
});
17 changes: 17 additions & 0 deletions examples/loadPhysicalFolder/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { PhysicalFolder, WebDAVServer } from 'webdav-server'

PhysicalFolder.loadFromPath('./data', (e, folder) => {
if(e) throw e;

const server = new WebDAVServer({
port: 1900
});

server.addResourceTree(folder, (e) => {
if(e) throw e;

server.start((s) => {
console.log('Server started on port ' + s.address().port + '.');
});
});
});
14 changes: 14 additions & 0 deletions examples/loadPhysicalFolder/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "loadphysicalfolder",
"version": "1.0.0",
"description": "Example to show how to load a physical folder.",
"main": "index.js",
"scripts": {
"test": "node test.js"
},
"author": "Adrien Castex <[email protected]>",
"license": "Unlicense",
"dependencies": {
"webdav-server": "^1.8.2"
}
}

0 comments on commit 7ed6c7a

Please sign in to comment.