diff --git a/examples/loadPhysicalFolder/README.md b/examples/loadPhysicalFolder/README.md new file mode 100644 index 00000000..e7ba3f78 --- /dev/null +++ b/examples/loadPhysicalFolder/README.md @@ -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 +``` diff --git a/examples/loadPhysicalFolder/data/a.txt b/examples/loadPhysicalFolder/data/a.txt new file mode 100644 index 00000000..af2986f5 --- /dev/null +++ b/examples/loadPhysicalFolder/data/a.txt @@ -0,0 +1,3 @@ +Hello friends! + +Is it ok? diff --git a/examples/loadPhysicalFolder/data/b/c.txt b/examples/loadPhysicalFolder/data/b/c.txt new file mode 100644 index 00000000..e69de29b diff --git a/examples/loadPhysicalFolder/data/b/e.txt b/examples/loadPhysicalFolder/data/b/e.txt new file mode 100644 index 00000000..e69de29b diff --git a/examples/loadPhysicalFolder/data/b/x/d.txt b/examples/loadPhysicalFolder/data/b/x/d.txt new file mode 100644 index 00000000..e69de29b diff --git a/examples/loadPhysicalFolder/index.js b/examples/loadPhysicalFolder/index.js new file mode 100644 index 00000000..bb00cb54 --- /dev/null +++ b/examples/loadPhysicalFolder/index.js @@ -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 + '.'); + }); + }); +}); diff --git a/examples/loadPhysicalFolder/index.ts b/examples/loadPhysicalFolder/index.ts new file mode 100644 index 00000000..3e52965b --- /dev/null +++ b/examples/loadPhysicalFolder/index.ts @@ -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 + '.'); + }); + }); +}); diff --git a/examples/loadPhysicalFolder/package.json b/examples/loadPhysicalFolder/package.json new file mode 100644 index 00000000..ecb2d1cd --- /dev/null +++ b/examples/loadPhysicalFolder/package.json @@ -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 ", + "license": "Unlicense", + "dependencies": { + "webdav-server": "^1.8.2" + } +}