@ayush0x44/notifystack 1.0.2 → 1.0.4

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.
Files changed (3) hide show
  1. package/README.md +78 -47
  2. package/index.js +2 -2
  3. package/package.json +2 -2
package/README.md CHANGED
@@ -1,67 +1,98 @@
1
- # NotifyStack Node.js SDK
1
+ # 📦 @ayush0x44/notifystack
2
2
 
3
- [![npm version](https://img.shields.io/npm/v/@ayush0x44/notifystack.svg)](https://www.npmjs.com/package/@ayush0x44/notifystack)
4
- [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
3
+ The official Node.js SDK for **NotifyStack** — a scalable, production-grade notification SaaS platform.
5
4
 
6
- The official Node.js SDK for **NotifyStack** — a high-performance, distributed notification SaaS platform. Send Emails, SMS, Push, and In-App notifications with a single unified API.
5
+ [![NPM Version](https://img.shields.io/npm/v/@ayush0x44/notifystack?color=blue&style=flat-square)](https://www.npmjs.com/package/@ayush0x44/notifystack)
6
+ [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg?style=flat-square)](https://opensource.org/licenses/MIT)
7
7
 
8
- ## 🚀 Features
9
-
10
- - **Zero Dependencies**: Lightweight and fast (uses native `fetch`).
11
- - **Unified API**: One interface for all channels (Email, SMS, Push, In-App).
12
- - **Auto-Retry**: Built-in exponential backoff for network flakes.
13
- - **Idempotency**: Safe retries without duplicate notifications.
14
- - **Batching**: Send up to 100 notifications in a single call.
15
-
16
- ## 📦 Installation
8
+ ## 🚀 Installation
17
9
 
18
10
  ```bash
19
11
  npm install @ayush0x44/notifystack
20
12
  ```
21
13
 
22
- ## 🛠️ Quick Start
14
+ ---
15
+
16
+ ## 🔥 Features
17
+ - **Zero-Config:** Automatically points to the production `api.notifystack.shop` domain.
18
+ - **Smart Retries:** Automatic exponential backoff for failed requests.
19
+ - **Idempotency:** Native support for `x-idempotency-key` to prevent duplicate sends.
20
+ - **Multi-Channel:** Full support for Email, SMS, and Push notifications from a single client.
21
+ - **Health Checks:** Built-in methods to verify API connectivity.
22
+
23
+ ---
23
24
 
25
+ ## 🛠️ Usage
26
+
27
+ ### ⚙️ 1. Initialization
24
28
  ```javascript
25
29
  const { NotifySDK } = require("@ayush0x44/notifystack");
26
30
 
27
- // Initialize the client
28
- const notify = new NotifySDK("ntf_live_your_api_key", {
29
- baseUrl: "https://notificationsaas.onrender.com" // Point to your cloud API
31
+ // Create your client (Zero-Config: no baseUrl required!)
32
+ const sdk = new NotifySDK("ntf_live_xxxx_your_api_key");
33
+ ```
34
+
35
+ ### 🎯 2. Event-Based Notification (Recommended)
36
+ Map your backend events to visual templates created in the NotifyStack Dashboard.
37
+
38
+ ```javascript
39
+ await sdk.track("USER_WELCOME", {
40
+ email: "user@example.com",
41
+ name: "Ayush",
42
+ plan: "Pro"
30
43
  });
44
+ ```
31
45
 
32
- async function main() {
33
- // 1. Send an Event-based notification (uses templates)
34
- await notify.track("ORDER_PLACED", {
35
- email: "customer@example.com",
36
- orderId: "ORD-123"
37
- });
38
-
39
- // 2. Send a direct Email
40
- await notify.send({
41
- to: "hello@world.com",
42
- subject: "Welcome!",
43
- body: "Thanks for joining our platform."
44
- });
45
-
46
- // 3. Send an SMS
47
- await notify.sendSms({
48
- to: "+1234567890",
49
- body: "Your verification code is 1234"
50
- });
51
- }
46
+ ### ✉️ 3. Direct Email
47
+ Send raw email content without a template.
52
48
 
53
- main().catch(console.error);
49
+ ```javascript
50
+ await sdk.send({
51
+ to: "user@example.com",
52
+ subject: "Security Alert",
53
+ body: "Wait! Was this you logging in?"
54
+ });
54
55
  ```
55
56
 
56
- ## ⚙️ Configuration
57
+ ### 📱 4. Direct SMS
58
+ Send SMS via Twilio (requires configuration in your NotifyStack dashboard).
59
+
60
+ ```javascript
61
+ await sdk.sendSms({
62
+ to: "+1234567890",
63
+ body: "Your verification code is: 123456"
64
+ });
65
+ ```
66
+
67
+ ### 🏥 5. Health Check
68
+ Verify your connection to the NotifyStack cloud.
69
+
70
+ ```javascript
71
+ const status = await sdk.health();
72
+ console.log(status.ok); // true
73
+ ```
74
+
75
+ ---
76
+
77
+ ## 🛡️ Error Handling
78
+ NotifyStack uses a custom error class for precise debugging.
79
+
80
+ ```javascript
81
+ const { NotifyError } = require("@ayush0x44/notifystack");
82
+
83
+ try {
84
+ await sdk.send({ ... });
85
+ } catch (e) {
86
+ if (e instanceof NotifyError) {
87
+ console.error(`Status ${e.status}:`, e.message);
88
+ }
89
+ }
90
+ ```
57
91
 
58
- | Option | Type | Default | Description |
59
- | :--- | :--- | :--- | :--- |
60
- | `baseUrl` | `string` | `http://localhost:3000` | The URL of your NotifyStack API |
61
- | `maxRetries` | `number` | `3` | Max attempts for failed requests |
62
- | `timeoutMs` | `number` | `10000` | Request timeout duration |
63
- | `debug` | `boolean` | `false` | Enable verbose logging |
92
+ ---
64
93
 
65
- ## 📖 License
94
+ ## 🔗 Resources
95
+ - **Live Dashboard:** [notifystack.shop](https://notifystack.shop)
96
+ - **API Documentation:** [notifystack.shop/docs](https://notifystack.shop/docs)
66
97
 
67
- MIT © [Ayush](https://github.com/ayush462)
98
+ MIT © **Ayush**
package/index.js CHANGED
@@ -15,7 +15,7 @@ class NotifySDK {
15
15
  /**
16
16
  * @param {string} apiKey - Your NotifyStack API key (ntf_live_xxx)
17
17
  * @param {object} [options]
18
- * @param {string} [options.baseUrl="http://localhost:3000"] - API base URL
18
+ * @param {string} [options.baseUrl="https://api.notifystack.shop"] - API base URL
19
19
  * @param {number} [options.maxRetries=3] - Max retry attempts
20
20
  * @param {number} [options.timeoutMs=10000] - Request timeout in ms
21
21
  * @param {boolean} [options.debug=false] - Enable verbose logging
@@ -25,7 +25,7 @@ class NotifySDK {
25
25
  throw new Error("Invalid API key. Must start with 'ntf_live_'");
26
26
  }
27
27
  this.apiKey = apiKey;
28
- this.baseUrl = (options.baseUrl || "http://localhost:3000").replace(/\/$/, "");
28
+ this.baseUrl = (options.baseUrl || "https://api.notifystack.shop").replace(/\/$/, "");
29
29
  this.maxRetries = options.maxRetries ?? 3;
30
30
  this.timeoutMs = options.timeoutMs ?? 30000;
31
31
  this.debug = options.debug || false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ayush0x44/notifystack",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "description": "The official Node.js SDK for NotifyStack — a scalable, production-ready notification SaaS platform.",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -28,4 +28,4 @@
28
28
  "engines": {
29
29
  "node": ">=18.0.0"
30
30
  }
31
- }
31
+ }