dav
dav copied to clipboard
Simplify lower-level WebDAV api
Right now using the WebDAV bits looks like
var dav = require('dav');
var client = new dav.Client(
new dav.transport.Basic(
new dav.Credentials({
username: 'xxx',
password: 'xxx'
})
),
{
baseUrl: 'https://mail.mozilla.com'
}
);
var req = dav.request.basic({
method: 'PUT',
data: 'BEGIN:VCALENDAR\nEND:VCALENDAR',
etag: '12345'
});
// req instanceof dav.Request
client.send(req, { url: '/calendars/123.ics' })
.then(function(response) {
// response instanceof XMLHttpRequest
});
This is quite verbose and I think there's room for some cleanup.
if you remove the unnecessary constructors it gets a little bit simpler:
var dav = require('dav');
// use `dav.transport.Basic` by default if single argument & no `send()` method
var client = new dav.Client({
baseUrl: 'https://mail.mozilla.com',
credentials: {
username: 'xxx',
password: 'xxx'
}
});
var req = {
method: 'PUT',
data: 'BEGIN:VCALENDAR\nEND:VCALENDAR',
etag: '12345'
};
client.send(req, '/calendars/123.ics').then(response => {
// response instanceof XMLHttpRequest
});
see: #70, #71