@pusher/push-notifications-server
Advanced tools
Comparing version 0.10.3 to 0.10.4
{ | ||
"name": "@pusher/push-notifications-server", | ||
"version": "0.10.3", | ||
"version": "0.10.4", | ||
"description": "NodeJS Server SDK for Pusher Push Notifications", | ||
@@ -21,3 +21,9 @@ "main": "push-notifications.js", | ||
"test": "mocha tests.js" | ||
} | ||
}, | ||
"keywords": [ | ||
"push notifications", | ||
"notifications", | ||
"pusher", | ||
"realtime" | ||
] | ||
} |
@@ -108,3 +108,10 @@ const https = require('https'); | ||
response.on('end', function() { | ||
const responseBody = JSON.parse(responseString); | ||
let responseBody; | ||
try { | ||
responseBody = JSON.parse(responseString); | ||
} catch (_) { | ||
reject( | ||
new Error('Unknown error - invalid server response') | ||
); | ||
} | ||
if (wasSuccessful) { | ||
@@ -111,0 +118,0 @@ resolve(responseBody); |
@@ -10,3 +10,3 @@ [![Build Status](https://travis-ci.org/pusher/push-notifications-node.svg?branch=master)](https://travis-ci.org/pusher/push-notifications-node) | ||
```bash | ||
$ npm install pusher-push-notifications-node --save | ||
$ npm install @pusher/push-notifications-server --save | ||
``` | ||
@@ -16,3 +16,3 @@ | ||
```bash | ||
$ yarn add pusher-push-notifications-node | ||
$ yarn add @pusher/push-notifications-server | ||
``` | ||
@@ -24,3 +24,3 @@ | ||
```javascript | ||
const PushNotifications = require('pusher-push-notifications-node'); | ||
const PushNotifications = require('@pusher/push-notifications-server'); | ||
@@ -27,0 +27,0 @@ let pushNotifications = new PushNotifications({ |
31
tests.js
@@ -196,3 +196,3 @@ const expect = require('chai').expect; | ||
pn.publish(['donuts'], {}).catch(e => { | ||
return pn.publish(['donuts'], {}).catch(e => { | ||
expect(e).to.exist; | ||
@@ -211,7 +211,28 @@ expect(e.message).to.contain('Not allow net connect'); | ||
pn.publish(['donuts'], {}).catch(e => { | ||
expect(e).to.exist; | ||
expect(e.message).to.contain('A fake error.'); | ||
}); | ||
return pn | ||
.publish(['donuts'], {}) | ||
.then(() => { | ||
throw new Error('This should not succeed'); | ||
}) | ||
.catch(e => { | ||
expect(e).to.exist; | ||
expect(e.message).to.contain('A fake error.'); | ||
}); | ||
}); | ||
it('should reject the returned promise if response is not JSON', () => { | ||
nock(new RegExp('/.*/')) | ||
.post(new RegExp('/.*/')) | ||
.reply(200, 'thisisnotjson{{{{{'); | ||
return pn | ||
.publish(['donuts'], {}) | ||
.then(() => { | ||
throw new Error('This should not succeed'); | ||
}) | ||
.catch(e => { | ||
expect(e).to.exist; | ||
expect(e.message).to.contain('Unknown error'); | ||
}); | ||
}); | ||
}); | ||
@@ -218,0 +239,0 @@ }); |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
49394
384
2