├── LICENSE ├── README.md ├── index.js └── package.json /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License 2 | 3 | Copyright(c) 2016 PDXHub 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | A filesystem-based webdav server, a thin wrapper around [jsDAV](https://github.com/mikedeboer/jsDAV). 2 | 3 | Intended as a reference server for developing [WebDAV save/load](https://github.com/Jermolene/TiddlyWiki5/issues/738) capabilities in [TiddlyWiki](http://tiddlywiki.com/). 4 | 5 | ## Install 6 | 7 | ``` 8 | npm install -g dav-server 9 | ``` 10 | 11 | ## Usage 12 | 13 | ``` 14 | dav-server [--debug] [-i LISTEN_IP] [-p PORT] [--digest HTDIGEST_FILE --realm AUTH_REALM] rootDir 15 | ``` 16 | 17 | ## Authentication 18 | 19 | If your server will be internet-facing, you probably want authentication. 20 | 21 | Standard HTTP digest auth is built in: 22 | 23 | ``` 24 | dav-server --digest htaccess --realm wiki ./wiki/ 25 | ``` 26 | 27 | To [create an htaccess file](https://httpd.apache.org/docs/2.4/programs/htdigest.html) use Apache's `htaccess` command or similar: 28 | 29 | ``` 30 | % htaccess -c ./htaccess wiki bob 31 | 32 | % htaccess ./htaccess wiki jane 33 | 34 | % cat htdigest 35 | bob:wiki:e812d2badc815fe1cc4bd17bba6e505c 36 | jane:wiki:bc7d2f2f47116effdd94b64f21dcf32c 37 | ``` 38 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | /* 2 | * @package dav-server 3 | * @copyright Copyright(c) 2016 PDXHub 4 | * @author Eric Drechsel 5 | * @license http://github.com/edrex/dav-server/blob/master/LICENSE MIT License 6 | */ 7 | "use strict"; 8 | 9 | var args = require('minimist')(process.argv.slice(2), {boolean: ['debug','h'], string: ['i', 'p', 'digest', 'realm'], default: {i:'127.0.0.1', p:8000}}); 10 | var fs = require('fs'); 11 | var path = require('path'); 12 | var jsDAV = require("jsdav"); 13 | 14 | var usage = "dav-server [--debug] [-i LISTEN_IP] [-p PORT] [--digest HTDIGEST_FILE --realm AUTH_REALM] rootDir"; 15 | 16 | function exitMsg(msg, code){ 17 | console.log(msg); 18 | process.exit(code || 0); 19 | } 20 | 21 | if (args.h || args._.length !== 1) exitMsg(usage); 22 | if (args.debug) jsDAV.debugMode = true; 23 | 24 | var rootDir = path.join(args._.shift(), '/'); 25 | if (!fs.existsSync(rootDir)) exitMsg(rootDir+" does not exist.", 1); 26 | if (!fs.statSync(rootDir).isDirectory()) exitMsg(rootDir+": not a directory.", 1); 27 | 28 | var config = { 29 | node: rootDir, 30 | locksBackend: require("jsdav/lib/DAV/plugins/locks/fs").new(rootDir) 31 | } 32 | 33 | if (args.digest || args.realm) { 34 | if (!args.digest || !args.realm ) { 35 | exitMsg("--digest and --realm are corequisite.", 1); 36 | } 37 | config.authBackend = require("jsdav/lib/DAV/plugins/auth/file").new(args.digest); 38 | config.realm = args.realm; 39 | } 40 | 41 | jsDAV.createServer(config, args.p, args.i); 42 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "dav-server", 3 | "version": "0.1.2", 4 | "description": "A filesystem based DAV server command thinnly wrapping jsDAV", 5 | "main": "index.js", 6 | "bin": { 7 | "dav-server": "index.js" 8 | }, 9 | "scripts": { 10 | "test": "echo \"Error: no test specified\" && exit 1" 11 | }, 12 | "repository": { 13 | "type": "git", 14 | "url": "git+https://github.com/edrex/dav-server.git" 15 | }, 16 | "author": "Eric Drechsel", 17 | "license": "ISC", 18 | "bugs": { 19 | "url": "https://github.com/edrex/dav-server/issues" 20 | }, 21 | "homepage": "https://github.com/edrex/dav-server#readme", 22 | "dependencies": { 23 | "jsDAV": "^0.3.3", 24 | "minimist": "^1.2.0" 25 | } 26 | } 27 | --------------------------------------------------------------------------------