UNPKG

2.21 kBJavaScriptView Raw
1var YouBase, exports,
2 __slice = [].slice;
3
4YouBase = (function() {
5 function YouBase(custodian, apiKey) {
6 this.custodian = custodian != null ? custodian : 'http://api.youbase.io';
7 this.apiKey = apiKey;
8 if (!(this instanceof YouBase)) {
9 return new YouBase(this.custodian, this.apiKey);
10 }
11 if (typeof this.custodian === 'string') {
12 this.custodian = YouBase.Custodian({
13 storage: 'rest',
14 url: this.custodian,
15 api_key: this.apiKey
16 });
17 }
18 }
19
20 YouBase.prototype.wallet = function() {
21 return (function(func, args, ctor) {
22 ctor.prototype = func.prototype;
23 var child = new ctor, result = func.apply(child, args);
24 return Object(result) === result ? result : child;
25 })(YouBase.Wallet, [this.custodian].concat(__slice.call(arguments)), function(){});
26 };
27
28 YouBase.prototype.document = function() {
29 return (function(func, args, ctor) {
30 ctor.prototype = func.prototype;
31 var child = new ctor, result = func.apply(child, args);
32 return Object(result) === result ? result : child;
33 })(YouBase.Document, [this.custodian].concat(__slice.call(arguments)), function(){});
34 };
35
36 YouBase.prototype.definition = function() {
37 return (function(func, args, ctor) {
38 ctor.prototype = func.prototype;
39 var child = new ctor, result = func.apply(child, args);
40 return Object(result) === result ? result : child;
41 })(YouBase.Definition, [this.custodian].concat(__slice.call(arguments)), function(){});
42 };
43
44 YouBase.prototype.collection = function() {
45 return (function(func, args, ctor) {
46 ctor.prototype = func.prototype;
47 var child = new ctor, result = func.apply(child, args);
48 return Object(result) === result ? result : child;
49 })(YouBase.Collection, [this.custodian, YouBase.Document].concat(__slice.call(arguments)), function(){});
50 };
51
52 return YouBase;
53
54})();
55
56YouBase.Custodian = require('./custodian');
57
58YouBase.Definition = require('./definition');
59
60YouBase.Wallet = require('./wallet');
61
62YouBase.Document = require('./document');
63
64YouBase.Collection = require('./collection');
65
66YouBase.Envelope = require('ecc-envelope');
67
68exports = module.exports = YouBase;