From 5f7727f4d1587a32e2ec0013b9af731e00f7c2bb Mon Sep 17 00:00:00 2001 From: Rafael Hernandez Date: Mon, 28 Aug 2017 12:20:32 -0400 Subject: [PATCH 1/4] added npm-debug.log to gitignore. Updated NPM package dependencies to latest build versions. Ensured all code passed Standard Linting. Ensured all tests passed with updated modules --- .gitignore | 1 + package.json | 12 ++++++------ scsb_rest_client.js | 14 +++++++------- test/scsb_rest_client.test.js | 2 +- 4 files changed, 15 insertions(+), 14 deletions(-) diff --git a/.gitignore b/.gitignore index 3c3629e..181e72d 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ node_modules +.npm-debug.log diff --git a/package.json b/package.json index 0be2bca..e63f23e 100644 --- a/package.json +++ b/package.json @@ -1,16 +1,16 @@ { "name": "@nypl/scsb-rest-client", - "version": "1.0.2", + "version": "1.0.3", "description": "A light wrapper around SCSB's RESTful interface", "main": "scsb_rest_client.js", "dependencies": { - "request": "2.53.0" + "request": "2.81.0" }, "devDependencies": { - "chai": "4.0.2", - "chai-as-promised": "7.0.0", - "mocha": "3.2.0", - "standard": "6.0.8" + "chai": "4.1.1", + "chai-as-promised": "7.1.1", + "mocha": "3.5.0", + "standard": "10.0.3" }, "standard": { "env": { diff --git a/scsb_rest_client.js b/scsb_rest_client.js index d728231..da52844 100644 --- a/scsb_rest_client.js +++ b/scsb_rest_client.js @@ -1,8 +1,7 @@ -var request = require('request') +const request = require('request') // myClient = new SCSBRestClient({url: "foo", apiKey: "bar"}) class SCSBRestClient { - constructor ({url = null, apiKey = null}) { this.url = url this.apiKey = apiKey @@ -29,7 +28,7 @@ class SCSBRestClient { } else if (response && response.statusCode === 200) { resolve(JSON.parse(body)) } else { - reject(`Error hitting SCSB API ${response.statusCode}: ${response.body}`) + reject(new Error(`Error hitting SCSB API ${response.statusCode}: ${response.body}`)) } }) }) @@ -52,7 +51,7 @@ class SCSBRestClient { } else if (response && response.statusCode === 200) { resolve(JSON.parse(body)) } else { - reject(`Error hitting SCSB API ${response.statusCode}: ${response.body}`) + reject(new Error(`Error hitting SCSB API ${response.statusCode}: ${response.body}`)) } }) }) @@ -74,7 +73,7 @@ class SCSBRestClient { } else if (response && response.statusCode === 200) { resolve(JSON.parse(body)) } else { - reject(`Error hitting SCSB API ${response.statusCode}: ${response.body}`) + reject(new Error(`Error hitting SCSB API ${response.statusCode}: ${response.body}`)) } }) }) @@ -82,7 +81,9 @@ class SCSBRestClient { addRequestItem (data) { if (!data || !Object.keys(data).length) { - return Promise.reject('the data parameter is empty or undefined; could not initialize POST request') + return Promise.reject( + new Error('the data parameter is empty or undefined; could not initialize POST request') + ) } return new Promise((resolve, reject) => { @@ -127,7 +128,6 @@ class SCSBRestClient { 'Content-Type': 'application/json' } } - } module.exports = SCSBRestClient diff --git a/test/scsb_rest_client.test.js b/test/scsb_rest_client.test.js index 8aabfae..b6596a9 100644 --- a/test/scsb_rest_client.test.js +++ b/test/scsb_rest_client.test.js @@ -1,4 +1,4 @@ -/* eslint no-new:0*/ +/* eslint no-new:0 */ const chai = require('chai') const expect = chai.expect const chaiAsPromised = require('chai-as-promised') From ed1499796df21d28e1398c4283e9d1db17574a28 Mon Sep 17 00:00:00 2001 From: Rafael Hernandez Date: Mon, 28 Aug 2017 12:26:54 -0400 Subject: [PATCH 2/4] Updated README docs and package.json version --- README.md | 5 +++++ package.json | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index e743a45..213d41c 100644 --- a/README.md +++ b/README.md @@ -75,3 +75,8 @@ When you _accept_ a PR - you should: #### Deprecated - `.searchByParam()` + +### v1.0.4 + +#### Updated +- Updated NPM packages to address npm request module bug [#1595](https://github.com/request/request/issues/1595) diff --git a/package.json b/package.json index e63f23e..7177662 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@nypl/scsb-rest-client", - "version": "1.0.3", + "version": "1.0.4", "description": "A light wrapper around SCSB's RESTful interface", "main": "scsb_rest_client.js", "dependencies": { From 65de042d8c07a9e0204e47ce8f3e47b0797b0286 Mon Sep 17 00:00:00 2001 From: Rafael Hernandez Date: Mon, 28 Aug 2017 12:36:00 -0400 Subject: [PATCH 3/4] Updated version number in README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 213d41c..8c085db 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ This is a light wrapper around SCSB's [RESTful interace](https://uat-recap.htcinc.com:9093/swagger-ui.html). ## Version -> 1.0.2 +> 1.0.4 ## Install From b7d58754f9026238f98ffc690aff0469608d5d5e Mon Sep 17 00:00:00 2001 From: Rafael Hernandez Date: Mon, 28 Aug 2017 12:38:59 -0400 Subject: [PATCH 4/4] Updated SCSB Swagger URL to use production --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8c085db..41e518b 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # SCSBRestClient -This is a light wrapper around SCSB's [RESTful interace](https://uat-recap.htcinc.com:9093/swagger-ui.html). +This is a light wrapper around SCSB's [RESTful interace](https://scsb.recaplib.org:9093/swagger-ui.html). ## Version > 1.0.4