-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Combine everything in one bundle for now
- Loading branch information
1 parent
16925dc
commit 4a70664
Showing
6 changed files
with
64 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module.exports = LightblueClient; | ||
|
||
function LightblueClient(dataClient, metadataClient) { | ||
this.data = dataClient; | ||
this.metadata = metadataClient; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,59 @@ | ||
var DataClient = require("./data.js"); | ||
var MetadataClient = require("./metadata.js"); | ||
var query = require("./query.js"); | ||
var DataClient = require("./data.js"); | ||
var MetadataClient = require("./metadata.js"); | ||
var LightblueClient = require("./client.js"); | ||
var query = require("./query.js"); | ||
var NodeHttpClient = require("./nodehttp.js"); | ||
|
||
// TODO: reorganize modules | ||
// Install angular module if angular is present | ||
require("./nglightblue.js"); | ||
|
||
var resolve = require("./clientutil.js").resolve; | ||
|
||
// TODO: Refactor exports and modules usage | ||
exports.getDataClient = getDataClient; | ||
exports.getMetadataClient = getMetadataClient; | ||
exports.getClient = getClient; | ||
exports.field = query.field; | ||
|
||
function LightblueClient(dataClient, metadataClient) { | ||
this.data = dataClient; | ||
this.metadata = metadataClient; | ||
} | ||
|
||
/** | ||
* Returns a LightblueDataClient. | ||
* @param {String} dataHost The full path for the base Lightblue data REST | ||
* context. | ||
* @return {LightblueDataClient} | ||
*/ | ||
function getDataClient(httpClient, dataHost) { | ||
return new DataClient(httpClient, dataHost); | ||
function getDataClient(dataHost, options) { | ||
return new DataClient(getHttpClient(options), dataHost); | ||
} | ||
|
||
function getMetadataClient(httpClient, metadataHost) { | ||
return new MetadataClient(httpClient, metadataHost); | ||
function getMetadataClient(metadataHost, options) { | ||
return new MetadataClient(getHttpClient(options), metadataHost); | ||
} | ||
|
||
/** | ||
* Returns a LightblueClient. | ||
* @param {String} dataHost The full path for the base Lightblue data service. | ||
* @param {String} metadataHost The full path for the base Lightblue metadata | ||
* @param {String=} metadataHost The full path for the base Lightblue metadata | ||
* service. | ||
* @param {Object=} options Configuration for http client. | ||
* @param {HttpClient} http An http client. | ||
*/ | ||
function getClient(httpClient, dataHost, metadataHost) { | ||
if (typeof metadataHost === "undefined") { | ||
function getClient(dataHost, metadataHost, options) { | ||
// metadataHost and options are optional | ||
if (typeof metadataHost != "string") { | ||
if (typeof metadataHost == "object") { | ||
options = metadataHost; | ||
} | ||
|
||
dataHost = resolve(dataHost, "data"); | ||
metadataHost = resolve(dataHost, "metadata"); | ||
} | ||
|
||
var dataClient = getDataClient(httpClient, dataHost); | ||
var metadataClient = getMetadataClient(httpClient, metadataHost); | ||
var dataClient = getDataClient(dataHost, options); | ||
var metadataClient = getMetadataClient(metadataHost, options); | ||
|
||
return new LightblueClient(dataClient, metadataClient); | ||
} | ||
|
||
function getHttpClient(options) { | ||
return new NodeHttpClient(options); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters