1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 | "use strict";
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 | var DB_DRIVER = "redis";
|
22 |
|
23 | var jsDAV = require("./../lib/jsdav");
|
24 | jsDAV.debugMode = true;
|
25 | var jsDAV_Auth_Backend = require("./../lib/DAV/plugins/auth/" + DB_DRIVER);
|
26 | var jsDAVACL_PrincipalBackend = require("./../lib/DAVACL/backends/" + DB_DRIVER);
|
27 | var jsCardDAV_Backend = require("./../lib/CardDAV/backends/" + DB_DRIVER);
|
28 |
|
29 | var jsDAVACL_PrincipalCollection = require("./../lib/DAVACL/principalCollection");
|
30 | var jsCardDAV_AddressBookRoot = require("./../lib/CardDAV/addressBookRoot");
|
31 |
|
32 | var jsDAV_Auth_Plugin = require("./../lib/DAV/plugins/auth");
|
33 | var jsDAV_Browser_Plugin = require("./../lib/DAV/plugins/browser");
|
34 | var jsCardDAV_Plugin = require("./../lib/CardDAV/plugin");
|
35 | var jsDAVACL_Plugin = require("./../lib/DAVACL/plugin");
|
36 |
|
37 | var Db = require("./../lib/shared/backends/" + DB_DRIVER);
|
38 | var DB_INIT = require("./data/addressbook/" + DB_DRIVER);
|
39 |
|
40 |
|
41 |
|
42 | var baseUri = "/";
|
43 |
|
44 |
|
45 | var DB_ARGS = {};
|
46 |
|
47 |
|
48 |
|
49 |
|
50 |
|
51 |
|
52 |
|
53 |
|
54 |
|
55 |
|
56 | Db.getConnection(DB_ARGS, function(err, db) {
|
57 | if (err)
|
58 | throw err;
|
59 |
|
60 | DB_INIT.init(db, false, function(err) {
|
61 | if (err)
|
62 | throw err;
|
63 |
|
64 | var authBackend = jsDAV_Auth_Backend.new(db);
|
65 | var principalBackend = jsDAVACL_PrincipalBackend.new(db);
|
66 | var carddavBackend = jsCardDAV_Backend.new(db);
|
67 |
|
68 |
|
69 | var nodes = [
|
70 | jsDAVACL_PrincipalCollection.new(principalBackend),
|
71 | jsCardDAV_AddressBookRoot.new(principalBackend, carddavBackend)
|
72 | ];
|
73 |
|
74 | jsDAV.createServer({
|
75 | node: nodes,
|
76 | baseUri: baseUri,
|
77 | authBackend: authBackend,
|
78 | realm: "jsDAV",
|
79 | plugins: [jsDAV_Auth_Plugin, jsDAV_Browser_Plugin, jsCardDAV_Plugin, jsDAVACL_Plugin]
|
80 | }, 8000);
|
81 |
|
82 | });
|
83 | });
|