jsdav-ext
Version:
jsDAV allows you to easily add WebDAV support to a NodeJS application. jsDAV is meant to cover the entire standard, and attempts to allow integration using an easy to understand API.
34 lines (28 loc) • 958 B
JavaScript
/*
* @package jsDAV
* @subpackage shared
* @copyright Copyright(c) 2013 Mike de Boer. <info AT mikedeboer DOT nl>
* @author Daniel Laxar
* @license http://github.com/mikedeboer/jsDAV/blob/master/LICENSE MIT License
*/
;
var getConnectionString = exports.getConnectionString = function (options) {
var auth = "";
if (options.username)
auth = options.username + ":" + (options.password || "") + "@";
return "postgres://" + auth +
(options.host || "localhost") +
(options.port ? ':' + options.port : "") +
"/" + (options.db || "jsdav");
}
exports.getConnection = function (options, callback) {
options = options || {};
var pg = require("pg");
var con = getConnectionString(options);
var client = new pg.Client(con);
client.connect(function(err) {
if (err)
return callback(err);
callback(null, client);
});
};