Merge pull request #74 from strongloop/drop-node-4

Drop node 4, update dependencies and status on maintenance
This commit is contained in:
Kyusung Shim 2018-06-08 14:59:58 -04:00 committed by GitHub
commit a431cf54fa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 68 additions and 55 deletions

View File

@ -1,6 +1,6 @@
sudo: false
language: node_js
node_js:
- "4"
- "6"
- "7"
- "8"
- "10"

View File

@ -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.
## 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
```bash

View File

@ -64,7 +64,7 @@ function negotiateContentProducer(req, logWarning, options) {
} else {
debug('contentType: `%s` is not supported, ' +
'falling back to contentType: `%s`',
options.defaultType, contentType);
options.defaultType, contentType);
}
}

View File

@ -4,7 +4,7 @@
"license": "MIT",
"version": "2.3.2",
"engines": {
"node": ">=4"
"node": ">=6"
},
"repository": {
"type": "git",
@ -18,19 +18,19 @@
},
"dependencies": {
"accepts": "^1.3.3",
"debug": "^2.2.0",
"ejs": "^2.5.7",
"http-status": "^1.0.0",
"debug": "^3.1.0",
"ejs": "^2.6.1",
"http-status": "^1.1.2",
"js2xmlparser": "^3.0.0",
"strong-globalize": "^3.1.0"
"strong-globalize": "^4.1.0"
},
"devDependencies": {
"chai": "^3.5.0",
"eslint": "^3.14.1",
"eslint-config-loopback": "^8.0.0",
"express": "^4.13.4",
"mocha": "^3.2.0",
"supertest": "^3.0.0"
"chai": "^4.1.2",
"eslint": "^4.19.1",
"eslint-config-loopback": "^10.0.0",
"express": "^4.16.3",
"mocha": "^5.2.0",
"supertest": "^3.1.0"
},
"browser": {
"strong-error-handler": false

View File

@ -16,6 +16,7 @@ var util = require('util');
describe('strong-error-handler', function() {
before(setupHttpServerAndClient);
beforeEach(resetRequestHandler);
after(stopHttpServerAndClient);
it('sets nosniff header', function(done) {
givenErrorHandlerForError();
@ -218,50 +219,50 @@ describe('strong-error-handler', function() {
});
it('includes code property for 4xx status codes when debug=false',
function(done) {
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 = {
function(done) {
var error = new ErrorWithProps({
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();
});
givenErrorHandlerForError(error, {debug: false});
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',
function(done) {
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 = {
function(done) {
var error = new ErrorWithProps({
statusCode: 500,
message: 'Internal Server Error',
};
expect(res.body).to.have.property('error');
expect(res.body.error).to.eql(expectedData);
done();
code: 'MACHINE_READABLE_CODE',
});
givenErrorHandlerForError(error, {debug: false});
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',
function(done) {
@ -786,7 +787,7 @@ describe('strong-error-handler', function() {
});
});
var app, _requestHandler, request;
var app, _requestHandler, request, server;
function resetRequestHandler() {
_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;
debug('Test server listening on %s', url);
request = supertest(app);
done();
})
.once('error', function(err) {
debug('Cannot setup HTTP server: %s', err.stack);
done(err);
});
.once('error', function(err) {
debug('Cannot setup HTTP server: %s', err.stack);
done(err);
});
}
function stopHttpServerAndClient() {
server.close();
}
function ErrorWithProps(props) {