From 56d26b377e2fe061c4e8a0b719eaa1298375cd2b Mon Sep 17 00:00:00 2001 From: shimks Date: Thu, 7 Jun 2018 12:26:52 -0400 Subject: [PATCH 1/2] drop node 4 from travis and update dependencies --- .travis.yml | 4 ++-- README.md | 8 ++++++++ package.json | 22 +++++++++++----------- test/handler.test.js | 9 +++++++-- 4 files changed, 28 insertions(+), 15 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5d970a2..c60f507 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,6 @@ sudo: false language: node_js node_js: - - "4" - "6" - - "7" + - "8" + - "10" diff --git a/README.md b/README.md index d614498..da92ab0 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/package.json b/package.json index 541ccbe..21c88c3 100644 --- a/package.json +++ b/package.json @@ -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 diff --git a/test/handler.test.js b/test/handler.test.js index c8b9ffd..e8d0448 100644 --- a/test/handler.test.js +++ b/test/handler.test.js @@ -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(); @@ -786,7 +787,7 @@ describe('strong-error-handler', function() { }); }); -var app, _requestHandler, request; +var app, _requestHandler, request, server; function resetRequestHandler() { _requestHandler = null; } @@ -834,7 +835,7 @@ 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); @@ -846,6 +847,10 @@ function setupHttpServerAndClient(done) { }); } +function stopHttpServerAndClient() { + server.close(); +} + function ErrorWithProps(props) { this.name = props.name || 'ErrorWithProps'; for (var p in props) { From b7b3961ff2ec7554ee8a07eb11c8809ffc104014 Mon Sep 17 00:00:00 2001 From: shimks Date: Thu, 7 Jun 2018 12:30:38 -0400 Subject: [PATCH 2/2] run lint --- lib/content-negotiation.js | 2 +- test/handler.test.js | 78 +++++++++++++++++++------------------- 2 files changed, 40 insertions(+), 40 deletions(-) diff --git a/lib/content-negotiation.js b/lib/content-negotiation.js index 2246874..35de407 100644 --- a/lib/content-negotiation.js +++ b/lib/content-negotiation.js @@ -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); } } diff --git a/test/handler.test.js b/test/handler.test.js index e8d0448..e89e775 100644 --- a/test/handler.test.js +++ b/test/handler.test.js @@ -219,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) { @@ -841,10 +841,10 @@ function setupHttpServerAndClient(done) { 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() {