Skip to content

Commit ccdfed6

Browse files
vveerrggclaude
andcommitted
docs: polish README, CHANGELOG, and package metadata
Fix scoped badge URLs and imports, add missing CHANGELOG entries, add examples to files array, and create example files. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 659cfc1 commit ccdfed6

5 files changed

Lines changed: 95 additions & 4 deletions

File tree

CHANGELOG.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10-
## [0.3.14] - 2025-01-13
10+
## [0.3.14] - 2025-02-19
11+
12+
### Changed
13+
- Updated dependencies and fixed broken validateResponse import
14+
- Fixed import from nostr-crypto-utils
15+
16+
## [0.3.13] - 2025-01-13
1117

1218
### Added
1319
- Browser support via webpack bundle
@@ -20,10 +26,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2026
- Updated package.json to include browser field
2127
- Enhanced build process to support browser environments
2228

29+
## [0.3.11] - 2025-01-05
30+
31+
### Added
32+
- CommonJS support and included dist/ in package
33+
2334
## [0.3.10] - 2025-01-02
2435

2536
### Changed
2637
- Updated nostr-crypto-utils dependency to ^0.4.10 for better ESM compatibility
38+
- Updated to use npm-published nostr-crypto-utils package
2739

2840
## [0.3.9] - 2025-01-02
2941

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# nostr-websocket-utils
22

3-
[![npm version](https://img.shields.io/npm/v/@humanjavaenterprises/nostr-websocket-utils.svg)](https://www.npmjs.com/package/@humanjavaenterprises/nostr-websocket-utils)
4-
[![License](https://img.shields.io/npm/l/@humanjavaenterprises/nostr-websocket-utils.svg)](https://github.com/HumanjavaEnterprises/nostr-websocket-utils/blob/main/LICENSE)
3+
[![npm version](https://img.shields.io/npm/v/nostr-websocket-utils.svg)](https://www.npmjs.com/package/nostr-websocket-utils)
4+
[![License](https://img.shields.io/npm/l/nostr-websocket-utils.svg)](https://github.com/HumanjavaEnterprises/nostr-websocket-utils/blob/main/LICENSE)
55
[![Build Status](https://github.com/HumanjavaEnterprises/nostr-websocket-utils/workflows/CI/badge.svg)](https://github.com/HumanjavaEnterprises/nostr-websocket-utils/actions)
66
[![Documentation](https://github.com/HumanjavaEnterprises/nostr-websocket-utils/workflows/Documentation/badge.svg)](https://humanjavaenterprises.github.io/nostr-websocket-utils/)
77
[![TypeScript](https://img.shields.io/badge/TypeScript-Ready-blue.svg)](https://www.typescriptlang.org)
@@ -103,7 +103,7 @@ await client.connect();
103103
### Creating a Nostr WebSocket Server
104104

105105
```typescript
106-
import { createNostrServer } from '@humanjavaenterprises/nostr-websocket-utils';
106+
import { createNostrServer } from 'nostr-websocket-utils';
107107

108108
const server = await createNostrServer(8080, {
109109
logger: console,

examples/basic-client.ts

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/**
2+
* Basic Client Example — nostr-websocket-utils
3+
*
4+
* Demonstrates connecting to a relay and subscribing to events.
5+
*/
6+
import { NostrWSClient } from 'nostr-websocket-utils';
7+
8+
async function main() {
9+
// Create a WebSocket client connected to a relay
10+
const client = new NostrWSClient('wss://relay.damus.io', {
11+
heartbeatInterval: 30000,
12+
handlers: {
13+
message: async (msg) => {
14+
console.log('Received message:', JSON.stringify(msg, null, 2));
15+
},
16+
error: (err) => {
17+
console.error('Connection error:', err);
18+
},
19+
close: () => {
20+
console.log('Connection closed');
21+
},
22+
},
23+
});
24+
25+
// Connect to the relay
26+
await client.connect();
27+
console.log('Connected to relay');
28+
29+
// Subscribe to text note events (kind 1) from specific authors
30+
client.subscribe('my-subscription', {
31+
filter: {
32+
kinds: [1],
33+
limit: 10,
34+
},
35+
});
36+
37+
console.log('Subscribed to text notes. Listening for events...');
38+
}
39+
40+
main().catch(console.error);

examples/server.ts

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/**
2+
* Server Example — nostr-websocket-utils
3+
*
4+
* Demonstrates creating a basic Nostr WebSocket server.
5+
*/
6+
import { createNostrServer } from 'nostr-websocket-utils';
7+
8+
async function main() {
9+
const port = 8080;
10+
11+
const server = await createNostrServer(port, {
12+
heartbeatInterval: 30000,
13+
handlers: {
14+
message: async (ws, msg) => {
15+
console.log('Received message from client:', JSON.stringify(msg, null, 2));
16+
17+
// Echo the message type back
18+
if (msg.type === 'EVENT') {
19+
console.log('Event received:', msg.data);
20+
} else if (msg.type === 'REQ') {
21+
console.log('Subscription request:', msg.data);
22+
} else if (msg.type === 'CLOSE') {
23+
console.log('Subscription closed:', msg.data);
24+
}
25+
},
26+
},
27+
});
28+
29+
console.log(`Nostr WebSocket server listening on port ${port}`);
30+
31+
// Broadcast a message to all connected clients
32+
server.broadcast({
33+
type: 'NOTICE',
34+
data: 'Welcome to the Nostr relay!',
35+
});
36+
}
37+
38+
main().catch(console.error);

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@
8383
},
8484
"files": [
8585
"dist",
86+
"examples/**/*",
8687
"README.md",
8788
"LICENSE"
8889
],

0 commit comments

Comments
 (0)