orator 2.0.8 → 2.0.10

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": "orator",
3
- "version": "2.0.8",
3
+ "version": "2.0.10",
4
4
  "description": "Restful web API server. Using restify 6.",
5
5
  "main": "source/Orator.js",
6
6
  "scripts": {
@@ -28,6 +28,24 @@
28
28
  "bugs": {
29
29
  "url": "https://github.com/stevenvelozo/orator/issues"
30
30
  },
31
+ "mocha": {
32
+ "diff": true,
33
+ "extension": [
34
+ "js"
35
+ ],
36
+ "package": "./package.json",
37
+ "reporter": "spec",
38
+ "slow": "75",
39
+ "timeout": "5000",
40
+ "ui": "tdd",
41
+ "watch-files": [
42
+ "source/**/*.js",
43
+ "test/**/*.js"
44
+ ],
45
+ "watch-ignore": [
46
+ "lib/vendor"
47
+ ]
48
+ },
31
49
  "homepage": "https://github.com/stevenvelozo/orator",
32
50
  "devDependencies": {
33
51
  "async": "2.6.1",
package/source/Orator.js CHANGED
@@ -610,9 +610,9 @@ var Orator = function()
610
610
  var handleError = function(req, res, err, callback)
611
611
  {
612
612
  // allow application to customize this error handling
613
- if (typeof userUnhandledErrorHandler == 'function' && !userUnhandledErrorHandler(req, res, err))
613
+ if (typeof userUnhandledErrorHandler == 'function' && !userUnhandledErrorHandler(req, res, err, callback))
614
614
  {
615
- return callback();
615
+ return;
616
616
  }
617
617
  //the default for a string error is 'Route not found', though it isn't accurate
618
618
  err.message = err.message.replace('Route not found: ', '');
@@ -146,13 +146,13 @@ suite
146
146
  function(fDone)
147
147
  {
148
148
  libSuperTest('http://localhost:' + _MockSettings.APIServerPort + '/')
149
- .get('google/search?q=laser+shark')
149
+ .get('google/a')
150
150
  .end(
151
151
  function (pError, pResponse)
152
152
  {
153
153
  //check for google search result
154
154
  Expect(pResponse.text)
155
- .to.contain('laser shark');
155
+ .to.contain('google');
156
156
  return fDone();
157
157
  }
158
158
  );
@@ -29,17 +29,19 @@ suite
29
29
  let capturedReq = null;
30
30
  let capturedRes = null;
31
31
  let capturedErr = null;
32
+ let capturedCallback = null;
32
33
 
33
34
  setup
34
35
  (
35
36
  function()
36
37
  {
37
38
  _Orator = require('../source/Orator.js').new(_MockSettings);
38
- _Orator.registerUnhandledErrorHandler((req, res, err) =>
39
+ _Orator.registerUnhandledErrorHandler((req, res, err, callback) =>
39
40
  {
40
41
  capturedReq = req;
41
42
  capturedRes = res;
42
43
  capturedErr = err;
44
+ capturedCallback = callback;
43
45
  return err.statusCode > 0;
44
46
  });
45
47
  _Orator.registerErrorTransformer((err) =>
@@ -265,7 +267,7 @@ suite
265
267
  Expect(capturedReq).to.exist; // shows we called the custom error handler
266
268
  Expect(capturedReq.RequestUUID).to.be.a('string'); // so we can log this from the handler
267
269
  Expect(capturedRes).to.exist; // shows we called the custom error handler
268
- Expect(capturedErr.message).to.contain('Cannot read property \'dog\'');
270
+ Expect(capturedErr.message).to.contain('Cannot read properties of null (reading \'dog\')');
269
271
  Expect(pResponse.text).to.contain('Cannot read property \'dog\'');
270
272
 
271
273
  return fDone();
@@ -291,6 +293,7 @@ suite
291
293
  Expect(capturedReq).to.exist; // shows we called the custom error handler
292
294
  Expect(capturedReq.RequestUUID).to.be.a('string'); // so we can log this from the handler
293
295
  Expect(capturedRes).to.exist; // shows we called the custom error handler
296
+ Expect(capturedCallback).to.be.a('function');
294
297
  Expect(capturedErr.message).to.contain('Cannot read property \'dog\'');
295
298
  Expect(pResponse.text).to.contain('Cannot read property \'dog\'');
296
299