Skip to content

Commit daa6dc6

Browse files
committed
Merge branch 'develop'
2 parents 1896935 + 819f394 commit daa6dc6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+250337
-2410
lines changed

.jshintrc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"node": true,
3+
"curly": true,
4+
"eqeqeq": true,
5+
"noarg": true,
6+
"nonew": true,
7+
"undef": true,
8+
"unused": true
9+
}

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ from Node.js applications.
1414

1515
## Status
1616

17-
Release 1.0.2 of the MarkLogic Node.js API
17+
Release 1.0.3 of the MarkLogic Node.js API
1818

1919
## Sample
2020

etc/test-lib.js

Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,18 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16+
'use strict';
1617
var valcheck = require('core-util-is');
1718

18-
var mlrest = require('../lib/mlrest.js');
1919
var mlutil = require('../lib/mlutil.js');
20+
var Operation = require('../lib/operation.js');
21+
var requester = require('../lib/requester.js');
2022

2123
//CAUTION: the functions in this module are not part of the supported API and
2224
//may change or may be removed at any time.
2325

2426
function responseOutputTransform(headers, data) {
27+
/*jshint validthis:true */
2528
var operation = this;
2629

2730
var response = {
@@ -34,8 +37,16 @@ function responseOutputTransform(headers, data) {
3437

3538
return response;
3639
}
40+
41+
function Manager(adminClient) {
42+
if (!(this instanceof Manager)) {
43+
return new Manager(adminClient);
44+
}
45+
this.client = adminClient;
46+
}
47+
3748
// TODO: configure acceptable errors
38-
function manageGet(paramsObj) {
49+
Manager.prototype.get = function manageGet(paramsObj) {
3950
var endpoint = paramsObj.endpoint;
4051
var params = paramsObj.params;
4152
var headers = paramsObj.headers;
@@ -50,16 +61,16 @@ function manageGet(paramsObj) {
5061
} : headers;
5162
requestOptions.path = path;
5263

53-
var operation = mlrest.createOperation(
64+
var operation = new Operation(
5465
'GET '+path, this.client, requestOptions, 'empty',
5566
((hasResponse === 'false') ? 'empty' : 'single')
5667
);
5768
operation.validStatusCodes = [200, 201, 204, 404];
5869
operation.outputTransform = responseOutputTransform;
5970

60-
return mlrest.startRequest(operation);
61-
}
62-
function managePost(paramsObj) {
71+
return requester.startRequest(operation);
72+
};
73+
Manager.prototype.post = function managePost(paramsObj) {
6374
var endpoint = paramsObj.endpoint;
6475
var params = paramsObj.params;
6576
var headers = paramsObj.headers;
@@ -78,7 +89,7 @@ function managePost(paramsObj) {
7889

7990
var hasBody = !valcheck.isNullOrUndefined(body);
8091

81-
var operation = mlrest.createOperation(
92+
var operation = new Operation(
8293
'POST '+path,
8394
this.client,
8495
requestOptions,
@@ -90,9 +101,9 @@ function managePost(paramsObj) {
90101
operation.requestBody = body;
91102
}
92103

93-
return mlrest.startRequest(operation);
94-
}
95-
function managePut(paramsObj) {
104+
return requester.startRequest(operation);
105+
};
106+
Manager.prototype.put = function managePut(paramsObj) {
96107
var endpoint = paramsObj.endpoint;
97108
var params = paramsObj.params;
98109
var headers = paramsObj.headers;
@@ -110,7 +121,7 @@ function managePut(paramsObj) {
110121

111122
var hasBody = !valcheck.isNullOrUndefined(body);
112123

113-
var operation = mlrest.createOperation(
124+
var operation = new Operation(
114125
'PUT '+path,
115126
this.client,
116127
requestOptions,
@@ -122,9 +133,9 @@ function managePut(paramsObj) {
122133
operation.requestBody = body;
123134
}
124135

125-
return mlrest.startRequest(operation);
126-
}
127-
function manageRemove(paramsObj) {
136+
return requester.startRequest(operation);
137+
};
138+
Manager.prototype.remove = function manageRemove(paramsObj) {
128139
var endpoint = paramsObj.endpoint;
129140
var params = paramsObj.params;
130141
var headers = paramsObj.headers;
@@ -139,7 +150,7 @@ function manageRemove(paramsObj) {
139150
} : headers;
140151
requestOptions.path = path;
141152

142-
var operation = mlrest.createOperation(
153+
var operation = new Operation(
143154
'DELETE '+path,
144155
this.client,
145156
requestOptions,
@@ -148,8 +159,9 @@ function manageRemove(paramsObj) {
148159
);
149160
operation.outputTransform = responseOutputTransform;
150161

151-
return mlrest.startRequest(operation);
152-
}
162+
return requester.startRequest(operation);
163+
};
164+
153165
function makePath(endpoint, params) {
154166
var path = encodeURI(endpoint);
155167
if (!valcheck.isNullOrUndefined(params)) {
@@ -177,14 +189,6 @@ function makePath(endpoint, params) {
177189
return path;
178190
}
179191

180-
function Manager(adminClient) {
181-
this.client = adminClient;
182-
}
183-
Manager.prototype.get = manageGet;
184-
Manager.prototype.post = managePost;
185-
Manager.prototype.put = managePut;
186-
Manager.prototype.remove = manageRemove;
187-
188192
function createManager(adminClient) {
189193
return new Manager(adminClient);
190194
};

gulpfile.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ var jsdoc = require('gulp-jsdoc');
2020

2121
gulp.task('lint', function() {
2222
gulp.src('lib/*')
23-
.pipe(jshint())
23+
.pipe(jshint({lookup:true}))
2424
.pipe(jshint.reporter('default'));
2525
});
2626

lib/bluebird-plus.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16+
'use strict';
1617
var bluebirdPlus = require('bluebird/js/main/promise')();
1718

1819
// when the last callback in a chain throws an error in the callback code,

0 commit comments

Comments
 (0)