diff --git a/reste.js b/reste.js index 46b4a1d..7426f09 100644 --- a/reste.js +++ b/reste.js @@ -2,7 +2,7 @@ var main = function () { var reste = this; var config = {}, - requestHeaders = []; + requestHeaders = []; function log(message) { if (config.debug && message) { @@ -78,7 +78,7 @@ var main = function () { var formEncode = false; - http.setTimeout(config.timeout || 10000); + http.timeout = config.timeout || 10000; if (_.has(config, "validatesSecureCertificate")) { http.setValidatesSecureCertificate(config.validatesSecureCertificate); @@ -199,8 +199,8 @@ var main = function () { for (var header in headers) { requestHeaders.push({ name: header, - value: headers[header] - }); + value: headers[header] }); + } }; @@ -216,8 +216,8 @@ var main = function () { if (!changed) { requestHeaders.push({ name: Object.keys(header)[0], - value: header[Object.keys(header)[0]] - }); + value: header[Object.keys(header)[0]] }); + } }; @@ -236,9 +236,9 @@ var main = function () { reste[args.name] = function (params, onLoad, onError) { var body, - method = "GET", - url, - deferred; + method = "GET", + url, + deferred; if (args.post) method = "POST"; if (args.get) method = "GET"; @@ -298,12 +298,12 @@ var main = function () { params: body, headers: args.requestHeaders || args.headers, beforePost: args.beforePost, - beforeSend: args.beforeSend - }, onLoad, onError); + beforeSend: args.beforeSend }, + onLoad, onError); } else { var m, - missing = [], - re = /(\<\w*\>)/g; + missing = [], + re = /(\<\w*\>)/g; if (config.autoValidateParams) { while ((m = re.exec(url)) !== null) { @@ -324,8 +324,8 @@ var main = function () { params: body, headers: args.requestHeaders || args.headers, beforePost: args.beforePost, - beforeSend: args.beforeSend - }, onLoad, onError); + beforeSend: args.beforeSend }, + onLoad, onError); } } @@ -396,8 +396,8 @@ var main = function () { this.__transform = this.toJSON(); } return this.__transform; - } - }); + } }); + if (args.collections) { args.collections.forEach(function (collection) { @@ -417,8 +417,8 @@ var main = function () { if (model instanceof Backbone.Collection && modelConfig && modelConfig.collections) { var collectionConfig = _.where(modelConfig.collections, { - name: model._name - })[0]; + name: model._name })[ + 0]; var methodCall = reste[collectionConfig.read]; @@ -533,8 +533,8 @@ var main = function () { } : onError = null; reste[modelConfig.create]({ - body: body - }, function (e) { + body: body }, + function (e) { if (e.code > 200) { onError(e);