node-webpush 1.0.1 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -7
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -55,10 +55,8 @@ that can be sent with Node’s built-in `fetch()`.
|
|
|
55
55
|
|
|
56
56
|
## Installation
|
|
57
57
|
|
|
58
|
-
> (Adjust package name once published)
|
|
59
|
-
|
|
60
58
|
```bash
|
|
61
|
-
npm install
|
|
59
|
+
npm install node-webpush
|
|
62
60
|
````
|
|
63
61
|
|
|
64
62
|
TypeScript is supported out of the box (the package emits `.d.ts`).
|
|
@@ -70,7 +68,7 @@ TypeScript is supported out of the box (the package emits `.d.ts`).
|
|
|
70
68
|
### 1) Create a `WebPush` instance
|
|
71
69
|
|
|
72
70
|
```ts
|
|
73
|
-
import {WebPush} from "
|
|
71
|
+
import {WebPush} from "node-webpush";
|
|
74
72
|
|
|
75
73
|
const webpush = new WebPush({
|
|
76
74
|
vapid: {
|
|
@@ -106,7 +104,7 @@ console.log("Status:", res.status);
|
|
|
106
104
|
## Generate VAPID keys
|
|
107
105
|
|
|
108
106
|
```ts
|
|
109
|
-
import {VAPID} from "
|
|
107
|
+
import {VAPID} from "node-webpush";
|
|
110
108
|
|
|
111
109
|
const keys = VAPID.GenerateKeys();
|
|
112
110
|
console.log(keys.publicKey);
|
|
@@ -235,7 +233,7 @@ await webpush.sendNotification(subscription, "hello", {
|
|
|
235
233
|
## Minimal example with manual fetch
|
|
236
234
|
|
|
237
235
|
```ts
|
|
238
|
-
import {WebPush} from "
|
|
236
|
+
import {WebPush} from "node-webpush";
|
|
239
237
|
|
|
240
238
|
const webpush = new WebPush({
|
|
241
239
|
vapid: {
|
|
@@ -261,7 +259,7 @@ console.log(res.status);
|
|
|
261
259
|
## Error handling
|
|
262
260
|
|
|
263
261
|
```ts
|
|
264
|
-
import {WebPush, WebPushError} from "
|
|
262
|
+
import {WebPush, WebPushError} from "node-webpush";
|
|
265
263
|
|
|
266
264
|
try {
|
|
267
265
|
await webpush.sendNotification(subscription, "hello");
|