Merge pull request #74 from strongloop/drop-node-4
Drop node 4, update dependencies and status on maintenance
This commit is contained in:
commit
a431cf54fa
|
@ -1,6 +1,6 @@
|
||||||
sudo: false
|
sudo: false
|
||||||
language: node_js
|
language: node_js
|
||||||
node_js:
|
node_js:
|
||||||
- "4"
|
|
||||||
- "6"
|
- "6"
|
||||||
- "7"
|
- "8"
|
||||||
|
- "10"
|
||||||
|
|
|
@ -12,6 +12,14 @@ In production mode, `strong-error-handler` omits details from error responses to
|
||||||
|
|
||||||
In debug mode, `strong-error-handler` returns full error stack traces and internal details of any error objects to the client in the HTTP responses.
|
In debug mode, `strong-error-handler` returns full error stack traces and internal details of any error objects to the client in the HTTP responses.
|
||||||
|
|
||||||
|
## Supported versions
|
||||||
|
|
||||||
|
Current|Long Term Support|Maintenance
|
||||||
|
:-:|:-:|:-:
|
||||||
|
3.x|2.x|1.x
|
||||||
|
|
||||||
|
Learn more about our LTS plan in [docs](http://loopback.io/doc/en/contrib/Long-term-support.html).
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
|
|
@ -64,7 +64,7 @@ function negotiateContentProducer(req, logWarning, options) {
|
||||||
} else {
|
} else {
|
||||||
debug('contentType: `%s` is not supported, ' +
|
debug('contentType: `%s` is not supported, ' +
|
||||||
'falling back to contentType: `%s`',
|
'falling back to contentType: `%s`',
|
||||||
options.defaultType, contentType);
|
options.defaultType, contentType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
22
package.json
22
package.json
|
@ -4,7 +4,7 @@
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"version": "2.3.2",
|
"version": "2.3.2",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=4"
|
"node": ">=6"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
|
@ -18,19 +18,19 @@
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"accepts": "^1.3.3",
|
"accepts": "^1.3.3",
|
||||||
"debug": "^2.2.0",
|
"debug": "^3.1.0",
|
||||||
"ejs": "^2.5.7",
|
"ejs": "^2.6.1",
|
||||||
"http-status": "^1.0.0",
|
"http-status": "^1.1.2",
|
||||||
"js2xmlparser": "^3.0.0",
|
"js2xmlparser": "^3.0.0",
|
||||||
"strong-globalize": "^3.1.0"
|
"strong-globalize": "^4.1.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"chai": "^3.5.0",
|
"chai": "^4.1.2",
|
||||||
"eslint": "^3.14.1",
|
"eslint": "^4.19.1",
|
||||||
"eslint-config-loopback": "^8.0.0",
|
"eslint-config-loopback": "^10.0.0",
|
||||||
"express": "^4.13.4",
|
"express": "^4.16.3",
|
||||||
"mocha": "^3.2.0",
|
"mocha": "^5.2.0",
|
||||||
"supertest": "^3.0.0"
|
"supertest": "^3.1.0"
|
||||||
},
|
},
|
||||||
"browser": {
|
"browser": {
|
||||||
"strong-error-handler": false
|
"strong-error-handler": false
|
||||||
|
|
|
@ -16,6 +16,7 @@ var util = require('util');
|
||||||
describe('strong-error-handler', function() {
|
describe('strong-error-handler', function() {
|
||||||
before(setupHttpServerAndClient);
|
before(setupHttpServerAndClient);
|
||||||
beforeEach(resetRequestHandler);
|
beforeEach(resetRequestHandler);
|
||||||
|
after(stopHttpServerAndClient);
|
||||||
|
|
||||||
it('sets nosniff header', function(done) {
|
it('sets nosniff header', function(done) {
|
||||||
givenErrorHandlerForError();
|
givenErrorHandlerForError();
|
||||||
|
@ -218,50 +219,50 @@ describe('strong-error-handler', function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('includes code property for 4xx status codes when debug=false',
|
it('includes code property for 4xx status codes when debug=false',
|
||||||
function(done) {
|
function(done) {
|
||||||
var error = new ErrorWithProps({
|
var error = new ErrorWithProps({
|
||||||
statusCode: 400,
|
|
||||||
message: 'error with code',
|
|
||||||
name: 'ErrorWithCode',
|
|
||||||
code: 'MACHINE_READABLE_CODE',
|
|
||||||
});
|
|
||||||
givenErrorHandlerForError(error, {debug: false});
|
|
||||||
|
|
||||||
requestJson().end(function(err, res) {
|
|
||||||
if (err) return done(err);
|
|
||||||
|
|
||||||
var expectedData = {
|
|
||||||
statusCode: 400,
|
statusCode: 400,
|
||||||
message: 'error with code',
|
message: 'error with code',
|
||||||
name: 'ErrorWithCode',
|
name: 'ErrorWithCode',
|
||||||
code: 'MACHINE_READABLE_CODE',
|
code: 'MACHINE_READABLE_CODE',
|
||||||
};
|
});
|
||||||
expect(res.body).to.have.property('error');
|
givenErrorHandlerForError(error, {debug: false});
|
||||||
expect(res.body.error).to.eql(expectedData);
|
|
||||||
done();
|
requestJson().end(function(err, res) {
|
||||||
|
if (err) return done(err);
|
||||||
|
|
||||||
|
var expectedData = {
|
||||||
|
statusCode: 400,
|
||||||
|
message: 'error with code',
|
||||||
|
name: 'ErrorWithCode',
|
||||||
|
code: 'MACHINE_READABLE_CODE',
|
||||||
|
};
|
||||||
|
expect(res.body).to.have.property('error');
|
||||||
|
expect(res.body.error).to.eql(expectedData);
|
||||||
|
done();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
it('excludes code property for 5xx status codes when debug=false',
|
it('excludes code property for 5xx status codes when debug=false',
|
||||||
function(done) {
|
function(done) {
|
||||||
var error = new ErrorWithProps({
|
var error = new ErrorWithProps({
|
||||||
statusCode: 500,
|
|
||||||
code: 'MACHINE_READABLE_CODE',
|
|
||||||
});
|
|
||||||
givenErrorHandlerForError(error, {debug: false});
|
|
||||||
|
|
||||||
requestJson().end(function(err, res) {
|
|
||||||
if (err) return done(err);
|
|
||||||
|
|
||||||
var expectedData = {
|
|
||||||
statusCode: 500,
|
statusCode: 500,
|
||||||
message: 'Internal Server Error',
|
code: 'MACHINE_READABLE_CODE',
|
||||||
};
|
});
|
||||||
expect(res.body).to.have.property('error');
|
givenErrorHandlerForError(error, {debug: false});
|
||||||
expect(res.body.error).to.eql(expectedData);
|
|
||||||
done();
|
requestJson().end(function(err, res) {
|
||||||
|
if (err) return done(err);
|
||||||
|
|
||||||
|
var expectedData = {
|
||||||
|
statusCode: 500,
|
||||||
|
message: 'Internal Server Error',
|
||||||
|
};
|
||||||
|
expect(res.body).to.have.property('error');
|
||||||
|
expect(res.body.error).to.eql(expectedData);
|
||||||
|
done();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
it('contains non-enumerable Error properties when debug=true',
|
it('contains non-enumerable Error properties when debug=true',
|
||||||
function(done) {
|
function(done) {
|
||||||
|
@ -786,7 +787,7 @@ describe('strong-error-handler', function() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
var app, _requestHandler, request;
|
var app, _requestHandler, request, server;
|
||||||
function resetRequestHandler() {
|
function resetRequestHandler() {
|
||||||
_requestHandler = null;
|
_requestHandler = null;
|
||||||
}
|
}
|
||||||
|
@ -834,16 +835,20 @@ function setupHttpServerAndClient(done) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
app.listen(0, function() {
|
server = app.listen(0, function() {
|
||||||
var url = 'http://127.0.0.1:' + this.address().port;
|
var url = 'http://127.0.0.1:' + this.address().port;
|
||||||
debug('Test server listening on %s', url);
|
debug('Test server listening on %s', url);
|
||||||
request = supertest(app);
|
request = supertest(app);
|
||||||
done();
|
done();
|
||||||
})
|
})
|
||||||
.once('error', function(err) {
|
.once('error', function(err) {
|
||||||
debug('Cannot setup HTTP server: %s', err.stack);
|
debug('Cannot setup HTTP server: %s', err.stack);
|
||||||
done(err);
|
done(err);
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function stopHttpServerAndClient() {
|
||||||
|
server.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
function ErrorWithProps(props) {
|
function ErrorWithProps(props) {
|
||||||
|
|
Loading…
Reference in New Issue