Skip to content

Commit

Permalink
i-api-requst now can set REST API host
Browse files Browse the repository at this point in the history
  • Loading branch information
Engeniy Filatov committed Mar 26, 2013
1 parent 8912d85 commit cfaaa7f
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 8 deletions.
24 changes: 22 additions & 2 deletions blocks/i-api-request/i-api-request.priv.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,15 @@

_apiHostConfigKey: 'api',

/**
* @abstruct
*/
_apiHost: undefined,

setHost: function (host) {
this._apiHost = host;
},

/**
* Define request headers
*/
Expand Down Expand Up @@ -78,10 +87,21 @@
* @return {Vow.Promise}
*/
_request: function (method, resource, data) {
var parse = url.parse(resource);
var path, parse;

if (resource.indexOf('http') !== 0) {
if (!this._apiHost) {
return Vow.reject(new Error('_apiHost is not specified; Use .setHost(<host>) or ._apiHost=<host> to set it'));
}
path = this._apiHost + resource;
} else {
path = resource;
}
console.log(path);
parse = url.parse(path);

return this._resolveApiParams(parse).then(function (apiParams) {
return this._requestApi(apiParams, method, resource, data);
return this._requestApi(apiParams, method, path, data);
}.bind(this));
},

Expand Down
11 changes: 5 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
var extend = require('bem/lib/util').extend,
cwd = process.cwd(),
var cwd = process.cwd(),
techFolder = __dirname + '/techs/';

// level.js
Expand All @@ -19,17 +18,17 @@ exports.getTechs = function() {
// level.js
exports.getConfig = function() {

return extend({}, this.__base() || {}, {
return {

bundleBuildLevels: this.resolvePaths([
bundleBuildLevels: [
__dirname + '/node_modules/bem-bl/blocks-common',
__dirname + '/node_modules/bem-bl/blocks-desktop',
__dirname + '/node_modules/bem-json',
__dirname + '/blocks',
cwd + '/blocks'
])
]

});
};

};

0 comments on commit cfaaa7f

Please sign in to comment.