Skip to content

Commit 80cff20

Browse files
committed
fix: add public hasClient method and fix TypeScript errors in tests
- Added public hasClient method to NostrWSServer - Fixed TypeScript error in server.test.ts by using public method - Updated package.json homepage URL - All tests passing
1 parent bc5b44e commit 80cff20

36 files changed

+1289
-248
lines changed

README.md

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# @humanjavaenterprises/nostr-websocket-utils
1+
# nostr-websocket-utils
22

33
[![npm version](https://img.shields.io/npm/v/@humanjavaenterprises/nostr-websocket-utils.svg)](https://www.npmjs.com/package/@humanjavaenterprises/nostr-websocket-utils)
44
[![License](https://img.shields.io/npm/l/@humanjavaenterprises/nostr-websocket-utils.svg)](https://github.com/HumanjavaEnterprises/nostr-websocket-utils/blob/main/LICENSE)
@@ -22,15 +22,15 @@ A TypeScript library for building Nostr protocol WebSocket clients and servers.
2222
## Installation
2323

2424
```bash
25-
npm install @humanjavaenterprises/nostr-websocket-utils
25+
npm install nostr-websocket-utils
2626
```
2727

2828
## Quick Start
2929

3030
### Creating a Nostr WebSocket Client
3131

3232
```typescript
33-
import { NostrWSClient } from '@humanjavaenterprises/nostr-websocket-utils';
33+
import { NostrWSClient } from 'nostr-websocket-utils';
3434

3535
const client = new NostrWSClient('wss://relay.example.com', {
3636
logger: console,
@@ -64,20 +64,26 @@ const server = await createNostrServer(8080, {
6464

6565
## Documentation
6666

67-
Full API documentation is available in the [docs](./docs) directory. The documentation includes:
67+
Comprehensive API documentation is available in our [documentation site](https://humanjavaenterprises.github.io/nostr-websocket-utils/). Here's what you'll find:
6868

69-
- Detailed API reference
70-
- Type definitions
71-
- Examples and usage patterns
72-
- Best practices
69+
### Core Components
70+
- [NostrWSClient](docs/classes/NostrWSClient.md) - WebSocket client implementation
71+
- [NostrWSServer](docs/classes/NostrWSServer.md) - WebSocket server implementation
72+
- [NostrServer](docs/classes/NostrServer.md) - High-level Nostr server
7373

74-
To generate the documentation locally:
74+
### Types and Interfaces
75+
- [NostrWSMessage](docs/interfaces/NostrWSMessage.md) - Message structure
76+
- [NostrWSOptions](docs/interfaces/NostrWSOptions.md) - Configuration options
77+
- [NostrWSSubscription](docs/interfaces/NostrWSSubscription.md) - Subscription interface
78+
- [ExtendedWebSocket](docs/interfaces/ExtendedWebSocket.md) - Enhanced WebSocket interface
7579

76-
```bash
77-
npm run docs
78-
```
80+
### Utility Functions
81+
- [createServer](docs/functions/createServer.md) - Server creation helper
82+
- [getLogger](docs/functions/getLogger.md) - Logging utility
7983

80-
This will create a `docs` directory with the full API documentation.
84+
### Type Definitions
85+
- [MessageType](docs/enumerations/NostrWSMessageType.md) - Message type enumeration
86+
- [Global Types](docs/globals.md) - Global type definitions
8187

8288
## Examples
8389

@@ -96,7 +102,7 @@ client.subscribe('my-channel', {
96102

97103
```typescript
98104
server.broadcast({
99-
type: 'EVENT',
105+
type: 'event',
100106
data: {
101107
content: 'Hello everyone!',
102108
kind: 1
@@ -121,6 +127,6 @@ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file
121127

122128
If you have any questions or need help, please:
123129

124-
1. Check the [documentation](./docs)
130+
1. Check the [documentation](https://humanjavaenterprises.github.io/nostr-websocket-utils/)
125131
2. Open an [issue](https://github.com/HumanjavaEnterprises/nostr-websocket-utils/issues)
126132
3. Join our [Discord community](https://discord.gg/your-discord)

docs/README.md

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
1-
**nostr-websocket-utils v0.2.4**
1+
**nostr-websocket-utils v0.2.5**
22

33
***
44

5-
# @humanjavaenterprises/nostr-websocket-utils
5+
# nostr-websocket-utils
6+
7+
[![npm version](https://img.shields.io/npm/v/@humanjavaenterprises/nostr-websocket-utils.svg)](https://www.npmjs.com/package/@humanjavaenterprises/nostr-websocket-utils)
8+
[![License](https://img.shields.io/npm/l/@humanjavaenterprises/nostr-websocket-utils.svg)](https://github.com/HumanjavaEnterprises/nostr-websocket-utils/blob/main/LICENSE)
9+
[![Build Status](https://github.com/HumanjavaEnterprises/nostr-websocket-utils/workflows/CI/badge.svg)](https://github.com/HumanjavaEnterprises/nostr-websocket-utils/actions)
10+
[![Documentation](https://github.com/HumanjavaEnterprises/nostr-websocket-utils/workflows/Documentation/badge.svg)](https://humanjavaenterprises.github.io/nostr-websocket-utils/)
11+
[![TypeScript](https://img.shields.io/badge/TypeScript-Ready-blue.svg)](https://www.typescriptlang.org)
12+
[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg)](https://github.com/prettier/prettier)
613

714
A TypeScript library for building Nostr protocol WebSocket clients and servers.
815

@@ -61,20 +68,26 @@ const server = await createNostrServer(8080, {
6168

6269
## Documentation
6370

64-
Full API documentation is available in the [docs](./docs) directory. The documentation includes:
71+
Comprehensive API documentation is available in our [documentation site](https://humanjavaenterprises.github.io/nostr-websocket-utils/). Here's what you'll find:
6572

66-
- Detailed API reference
67-
- Type definitions
68-
- Examples and usage patterns
69-
- Best practices
73+
### Core Components
74+
- [NostrWSClient](_media/NostrWSClient.md) - WebSocket client implementation
75+
- [NostrWSServer](_media/NostrWSServer.md) - WebSocket server implementation
76+
- [NostrServer](_media/NostrServer.md) - High-level Nostr server
7077

71-
To generate the documentation locally:
78+
### Types and Interfaces
79+
- [NostrWSMessage](_media/NostrWSMessage.md) - Message structure
80+
- [NostrWSOptions](_media/NostrWSOptions.md) - Configuration options
81+
- [NostrWSSubscription](_media/NostrWSSubscription.md) - Subscription interface
82+
- [ExtendedWebSocket](_media/ExtendedWebSocket.md) - Enhanced WebSocket interface
7283

73-
```bash
74-
npm run docs
75-
```
84+
### Utility Functions
85+
- [createServer](_media/createServer.md) - Server creation helper
86+
- [getLogger](_media/getLogger.md) - Logging utility
7687

77-
This will create a `docs` directory with the full API documentation.
88+
### Type Definitions
89+
- [MessageType](_media/NostrWSMessageType.md) - Message type enumeration
90+
- [Global Types](_media/globals.md) - Global type definitions
7891

7992
## Examples
8093

@@ -93,7 +106,7 @@ client.subscribe('my-channel', {
93106

94107
```typescript
95108
server.broadcast({
96-
type: 'EVENT',
109+
type: 'event',
97110
data: {
98111
content: 'Hello everyone!',
99112
kind: 1
@@ -118,6 +131,6 @@ This project is licensed under the MIT License - see the [LICENSE](_media/LICENS
118131

119132
If you have any questions or need help, please:
120133

121-
1. Check the [documentation](./docs)
134+
1. Check the [documentation](https://humanjavaenterprises.github.io/nostr-websocket-utils/)
122135
2. Open an [issue](https://github.com/HumanjavaEnterprises/nostr-websocket-utils/issues)
123136
3. Join our [Discord community](https://discord.gg/your-discord)

docs/_media/ExtendedWebSocket.md

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
[**nostr-websocket-utils v0.2.5**](../README.md)
2+
3+
***
4+
5+
[nostr-websocket-utils](../globals.md) / ExtendedWebSocket
6+
7+
# Interface: ExtendedWebSocket
8+
9+
Extended WebSocket interface with additional properties
10+
ExtendedWebSocket
11+
12+
## Extends
13+
14+
- `WebSocket`
15+
16+
## Extended by
17+
18+
- [`NostrSocket`](NostrSocket.md)
19+
20+
## Properties
21+
22+
### isAlive?
23+
24+
> `optional` **isAlive**: `boolean`
25+
26+
Whether the WebSocket connection is alive
27+
28+
#### Defined in
29+
30+
[types/index.ts:180](https://github.com/HumanjavaEnterprises/nostr-websocket-utils/blob/main/src/types/index.ts#L180)
31+
32+
***
33+
34+
### subscriptions?
35+
36+
> `optional` **subscriptions**: `Set`\<`string`\>
37+
38+
Set of subscription channels
39+
40+
#### Defined in
41+
42+
[types/index.ts:185](https://github.com/HumanjavaEnterprises/nostr-websocket-utils/blob/main/src/types/index.ts#L185)
43+
44+
***
45+
46+
### clientId?
47+
48+
> `optional` **clientId**: `string`
49+
50+
Unique client identifier
51+
52+
#### Defined in
53+
54+
[types/index.ts:190](https://github.com/HumanjavaEnterprises/nostr-websocket-utils/blob/main/src/types/index.ts#L190)
55+
56+
***
57+
58+
### messageQueue?
59+
60+
> `optional` **messageQueue**: [`NostrWSMessage`](NostrWSMessage.md)[]
61+
62+
Queue of messages to be sent
63+
64+
#### Defined in
65+
66+
[types/index.ts:195](https://github.com/HumanjavaEnterprises/nostr-websocket-utils/blob/main/src/types/index.ts#L195)
67+
68+
***
69+
70+
### lastPing?
71+
72+
> `optional` **lastPing**: `number`
73+
74+
Timestamp of the last ping message
75+
76+
#### Defined in
77+
78+
[types/index.ts:200](https://github.com/HumanjavaEnterprises/nostr-websocket-utils/blob/main/src/types/index.ts#L200)
79+
80+
***
81+
82+
### reconnectAttempts?
83+
84+
> `optional` **reconnectAttempts**: `number`
85+
86+
Number of reconnect attempts
87+
88+
#### Defined in
89+
90+
[types/index.ts:205](https://github.com/HumanjavaEnterprises/nostr-websocket-utils/blob/main/src/types/index.ts#L205)

docs/_media/NostrServer.md

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
[**nostr-websocket-utils v0.2.5**](../README.md)
2+
3+
***
4+
5+
[nostr-websocket-utils](../globals.md) / NostrServer
6+
7+
# Class: NostrServer
8+
9+
Represents a Nostr WebSocket server
10+
11+
## Constructors
12+
13+
### new NostrServer()
14+
15+
> **new NostrServer**(`options`): [`NostrServer`](NostrServer.md)
16+
17+
Creates a new Nostr WebSocket server instance
18+
19+
#### Parameters
20+
21+
##### options
22+
23+
[`NostrWSServerOptions`](../interfaces/NostrWSServerOptions.md)
24+
25+
Server configuration options
26+
27+
#### Returns
28+
29+
[`NostrServer`](NostrServer.md)
30+
31+
#### Defined in
32+
33+
[nostr-server.ts:24](https://github.com/HumanjavaEnterprises/nostr-websocket-utils/blob/main/src/nostr-server.ts#L24)
34+
35+
## Properties
36+
37+
### server
38+
39+
> `private` **server**: `Server`\<*typeof* `WebSocket`, *typeof* `IncomingMessage`\>
40+
41+
The underlying WebSocket server instance
42+
43+
#### Defined in
44+
45+
[nostr-server.ts:12](https://github.com/HumanjavaEnterprises/nostr-websocket-utils/blob/main/src/nostr-server.ts#L12)
46+
47+
***
48+
49+
### logger
50+
51+
> `private` **logger**: `Logger`
52+
53+
Logger instance for this server
54+
55+
#### Defined in
56+
57+
[nostr-server.ts:17](https://github.com/HumanjavaEnterprises/nostr-websocket-utils/blob/main/src/nostr-server.ts#L17)
58+
59+
## Methods
60+
61+
### close()
62+
63+
> **close**(): `void`
64+
65+
Closes the WebSocket server
66+
67+
#### Returns
68+
69+
`void`
70+
71+
#### Defined in
72+
73+
[nostr-server.ts:112](https://github.com/HumanjavaEnterprises/nostr-websocket-utils/blob/main/src/nostr-server.ts#L112)

0 commit comments

Comments
 (0)