Skip to content

Commit 92b2f28

Browse files
authored
Add proxy CLI variable (#710)
1 parent 55c9b09 commit 92b2f28

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

README.md

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,37 @@ Then you can run the following commands:
7373

7474
Usage:
7575

76-
web-push send-notification --endpoint=<url> [--key=<browser key>] [--auth=<auth secret>] [--payload=<message>] [--encoding=<aesgcm | aes128gcm>] [--ttl=<seconds>] [--vapid-subject=<vapid subject>] [--vapid-pubkey=<public key url base64>] [--vapid-pvtkey=<private key url base64>] [--gcm-api-key=<api key>]
76+
web-push send-notification --endpoint=<url> [--key=<browser key>] [--auth=<auth secret>] [--payload=<message>] [--encoding=<aesgcm | aes128gcm>] [--ttl=<seconds>] [--vapid-subject=<vapid subject>] [--vapid-pubkey=<public key url base64>] [--vapid-pvtkey=<private key url base64>] [--proxy=<http proxy uri>] [--gcm-api-key=<api key>]
7777

7878
web-push generate-vapid-keys [--json]
7979

80+
Example of send notification:
81+
```shell
82+
> web-push generate-vapid-keys --json
83+
> {"publicKey":"BGtkbcjrO12YMoDuq2sCQeHlu47uPx3SHTgFKZFYiBW8Qr0D9vgyZSZPdw6_4ZFEI9Snk1VEAj2qTYI1I1YxBXE","privateKey":"I0_d0vnesxbBSUmlDdOKibGo6vEXRO-Vu88QlSlm5j0"}
84+
```
85+
The subscription value:
86+
```javascript
87+
{
88+
"endpoint": "https://fcm.googleapis.com/fcm/send/d61c5u920dw:APA91bEmnw8utjDYCqSRplFMVCzQMg9e5XxpYajvh37mv2QIlISdasBFLbFca9ZZ4Uqcya0ck-SP84YJUEnWsVr3mwYfaDB7vGtsDQuEpfDdcIqOX_wrCRkBW2NDWRZ9qUz9hSgtI3sY",
89+
"expirationTime": null,
90+
"keys": {
91+
"p256dh": "BL7ELU24fJTAlH5Kyl8N6BDCac8u8li_U5PIwG963MOvdYs9s7LSzj8x_7v7RFdLZ9Eap50PiiyF5K0TDAis7t0",
92+
"auth": "juarI8x__VnHvsOgfeAPHg"
93+
}
94+
}
95+
```
96+
The command example:
97+
```shell
98+
web-push send-notification \
99+
--endpoint=https://fcm.googleapis.com/fcm/send/d61c5u920dw:APA91bEmnw8utjDYCqSRplFMVCzQMg9e5XxpYajvh37mv2QIlISdasBFLbFca9ZZ4Uqcya0ck-SP84YJUEnWsVr3mwYfaDB7vGtsDQuEpfDdcIqOX_wrCRkBW2NDWRZ9qUz9hSgtI3sY \
100+
--key=BL7ELU24fJTAlH5Kyl8N6BDCac8u8li_U5PIwG963MOvdYs9s7LSzj8x_7v7RFdLZ9Eap50PiiyF5K0TDAis7t0 \
101+
--auth=juarI8x__VnHvsOgfeAPHg \
102+
--vapid-subject=mailto:[email protected] \
103+
--vapid-pubkey=BGtkbcjrO12YMoDuq2sCQeHlu47uPx3SHTgFKZFYiBW8Qr0D9vgyZSZPdw6_4ZFEI9Snk1VEAj2qTYI1I1YxBXE \
104+
--vapid-pvtkey=I0_d0vnesxbBSUmlDdOKibGo6vEXRO-Vu88QlSlm5j0 \
105+
--payload=Hello
106+
```
80107

81108
# API Reference
82109

src/cli.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ const printUsageDetails = () => {
1919
'[--vapid-subject=<vapid subject>]',
2020
'[--vapid-pubkey=<public key url base64>]',
2121
'[--vapid-pvtkey=<private key url base64>]',
22+
'[--proxy=<http proxy uri, e.g: http://127.0.0.1:8889>]',
2223
'[--gcm-api-key=<api key>]'
2324
]
2425
}, {
@@ -87,6 +88,10 @@ const sendNotification = args => {
8788
};
8889
}
8990

91+
if (args.proxy) {
92+
options.proxy = args.proxy;
93+
}
94+
9095
if (args['gcm-api-key']) {
9196
options.gcmAPIKey = args['gcm-api-key'];
9297
}

0 commit comments

Comments
 (0)