fable 3.1.66 → 3.1.68
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fable",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.68",
|
|
4
4
|
"description": "A service dependency injection, configuration and logging library.",
|
|
5
5
|
"main": "source/Fable.js",
|
|
6
6
|
"scripts": {
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
},
|
|
52
52
|
"homepage": "https://github.com/stevenvelozo/fable",
|
|
53
53
|
"devDependencies": {
|
|
54
|
-
"quackage": "^1.0.
|
|
54
|
+
"quackage": "^1.0.68"
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
57
|
"async.eachlimit": "^0.5.2",
|
|
@@ -42,7 +42,8 @@ class FableServiceExpressionParser extends libFableServiceBase
|
|
|
42
42
|
this.log;
|
|
43
43
|
|
|
44
44
|
// The configuration for tokens that the solver recognizes, with precedence and friendly names.
|
|
45
|
-
|
|
45
|
+
// Clone the JSON so each instance gets its own tokenMap (require() caches and returns the same object reference).
|
|
46
|
+
this.tokenMap = JSON.parse(JSON.stringify(require('./Fable-Service-ExpressionParser/Fable-Service-ExpressionParser-TokenMap.json')));
|
|
46
47
|
|
|
47
48
|
// Keep track of maximum token precedence
|
|
48
49
|
this.tokenMaxPrecedence = 4;
|
|
@@ -86,7 +87,8 @@ class FableServiceExpressionParser extends libFableServiceBase
|
|
|
86
87
|
}
|
|
87
88
|
|
|
88
89
|
// The configuration for which functions are available to the solver.
|
|
89
|
-
|
|
90
|
+
// Clone the JSON so each instance gets its own functionMap (require() caches and returns the same object reference).
|
|
91
|
+
this.functionMap = JSON.parse(JSON.stringify(require('./Fable-Service-ExpressionParser/Fable-Service-ExpressionParser-FunctionMap.json')));
|
|
90
92
|
|
|
91
93
|
this.serviceType = 'ExpressionParser';
|
|
92
94
|
|
|
@@ -232,7 +232,17 @@ class FableServiceRestClient extends libFableServiceBase
|
|
|
232
232
|
let tmpCompletionTime = this.fable.log.getTimeStamp();
|
|
233
233
|
this.fable.log.debug(`==> JSON ${tmpOptions.method} completed - received in ${this.dataFormat.formatTimeDelta(tmpOptions.RequestStartTime, tmpCompletionTime)}ms`);
|
|
234
234
|
}
|
|
235
|
-
|
|
235
|
+
let tmpParsedJSON;
|
|
236
|
+
try
|
|
237
|
+
{
|
|
238
|
+
tmpParsedJSON = JSON.parse(tmpJSONData);
|
|
239
|
+
}
|
|
240
|
+
catch (pParseError)
|
|
241
|
+
{
|
|
242
|
+
let tmpStatusCode = pResponse ? pResponse.statusCode : 'unknown';
|
|
243
|
+
return fCallback(new Error(`JSON parse failed (HTTP ${tmpStatusCode}): ${tmpJSONData.substring(0, 200)}`), pResponse, null);
|
|
244
|
+
}
|
|
245
|
+
return fCallback(pError, pResponse, tmpParsedJSON);
|
|
236
246
|
});
|
|
237
247
|
});
|
|
238
248
|
}
|
package/test/RestClient_test.js
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
var libFable = require('../source/Fable.js');
|
|
10
|
+
var libHTTP = require('http');
|
|
10
11
|
|
|
11
12
|
var Chai = require("chai");
|
|
12
13
|
var Expect = Chai.expect;
|
|
@@ -144,5 +145,44 @@ suite
|
|
|
144
145
|
);
|
|
145
146
|
}
|
|
146
147
|
);
|
|
148
|
+
|
|
149
|
+
suite
|
|
150
|
+
(
|
|
151
|
+
'Error Handling',
|
|
152
|
+
function ()
|
|
153
|
+
{
|
|
154
|
+
test
|
|
155
|
+
(
|
|
156
|
+
'Handle a non-JSON response without crashing.',
|
|
157
|
+
function (fTestComplete)
|
|
158
|
+
{
|
|
159
|
+
// Spin up a tiny HTTP server that returns plain text with a 414 status
|
|
160
|
+
var tmpServer = libHTTP.createServer(function (pReq, pRes)
|
|
161
|
+
{
|
|
162
|
+
pRes.writeHead(414, { 'Content-Type': 'text/plain' });
|
|
163
|
+
pRes.end('URI too long\n');
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
tmpServer.listen(0, function ()
|
|
167
|
+
{
|
|
168
|
+
var tmpPort = tmpServer.address().port;
|
|
169
|
+
var testFable = new libFable();
|
|
170
|
+
var tmpRestClient = testFable.instantiateServiceProvider('RestClient', {}, 'RestClient-ErrorTest');
|
|
171
|
+
|
|
172
|
+
tmpRestClient.getJSON('http://localhost:' + tmpPort + '/anything',
|
|
173
|
+
function (pError, pResponse, pBody)
|
|
174
|
+
{
|
|
175
|
+
Expect(pError).to.be.an.instanceof(Error);
|
|
176
|
+
Expect(pError.message).to.contain('414');
|
|
177
|
+
Expect(pError.message).to.contain('URI too long');
|
|
178
|
+
Expect(pBody).to.equal(null);
|
|
179
|
+
tmpServer.close();
|
|
180
|
+
fTestComplete();
|
|
181
|
+
});
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
);
|
|
185
|
+
}
|
|
186
|
+
);
|
|
147
187
|
}
|
|
148
188
|
);
|