@mingzey/typedrpc 1.1.4 → 1.1.6
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 +243 -243
- package/README.zh-CN.md +243 -243
- package/dist/connections/socketio.d.ts.map +1 -1
- package/dist/connections/socketio.js +1 -0
- package/dist/connections/socketio.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,243 +1,243 @@
|
|
|
1
|
-
[English](./README.md) / [中文](./README.zh-CN.md)
|
|
2
|
-
# TypedRPC
|
|
3
|
-
|
|
4
|
-
TypeScript-based RPC framework with support for multiple connection types including HTTP, Socket, and SocketIO.
|
|
5
|
-
|
|
6
|
-
## Repository
|
|
7
|
-
|
|
8
|
-
[Github](https://github.com/MingZeY/TypedRPC)
|
|
9
|
-
|
|
10
|
-
## Features
|
|
11
|
-
|
|
12
|
-
- 🛡️ **Type-Safe RPC calls** - Leverage TypeScript's type system for end-to-end type safety
|
|
13
|
-
- 🔌 **Multiple connection types** - Support for HTTP, Socket, and SocketIO connections, or custom connection providers
|
|
14
|
-
- 🔄 **Middleware support** - Extensible middleware system for request/response handling
|
|
15
|
-
- 📝 **Context-aware** - Built-in context system for passing data between handlers
|
|
16
|
-
- 🔁 **Bidirectional communication** - Support for two-way RPC calls between client and server, capability depends on connection type
|
|
17
|
-
- 📦 **Easy to use** - Simple API for defining services and methods
|
|
18
|
-
- 🚀 **Zero dependencies** - No external library dependencies, only depends on TypeScript standard library
|
|
19
|
-
- 🌐 **Frontend and backend compatible** - Can be used in Node.js backend and browser frontend
|
|
20
|
-
- 📈 **High extensibility** - Can be easily integrated into frameworks like Electron, Express as an RPC solution
|
|
21
|
-
|
|
22
|
-
## Installation
|
|
23
|
-
|
|
24
|
-
```bash
|
|
25
|
-
npm install @mingzey/typedrpc
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
## Basic Usage
|
|
29
|
-
|
|
30
|
-
### Server Setup
|
|
31
|
-
|
|
32
|
-
```typescript
|
|
33
|
-
import { TypedRPCServer, TypedRPCAPIDefine } from '@mingzey/typedrpc';
|
|
34
|
-
|
|
35
|
-
// Define your API interface
|
|
36
|
-
const ServerAPIDefine = new TypedRPCAPIDefine<{
|
|
37
|
-
// Service layer - Define your services here or use interface inheritance
|
|
38
|
-
math:{
|
|
39
|
-
// Method layer - Define your methods here
|
|
40
|
-
add(a:number,b:number):number,
|
|
41
|
-
},
|
|
42
|
-
}>({
|
|
43
|
-
timeout:10 * 1000
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
// Create server instance
|
|
47
|
-
const server = new TypedRPCServer({
|
|
48
|
-
// let typescript infer the type from ServerAPIDefine
|
|
49
|
-
local:ServerAPIDefine,
|
|
50
|
-
// Connection layer - use your connection provider here
|
|
51
|
-
// connection:{
|
|
52
|
-
// provider:new TypedRPCConnectionProviderHTTP(),
|
|
53
|
-
// }
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
// Hook service methods
|
|
57
|
-
server.hook('math','add',{
|
|
58
|
-
handler: (a,b) => a+b,
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
// Start listening
|
|
62
|
-
server.listen({
|
|
63
|
-
port:3698,
|
|
64
|
-
})
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
### Client Setup
|
|
68
|
-
|
|
69
|
-
```typescript
|
|
70
|
-
import { TypedRPCClient, TypedRPCAPIDefine } from '@mingzey/typedrpc';
|
|
71
|
-
// Reuse or import the same API definition
|
|
72
|
-
const ServerAPIDefine = new TypedRPCAPIDefine<{
|
|
73
|
-
math:{
|
|
74
|
-
add(a:number,b:number):number,
|
|
75
|
-
},
|
|
76
|
-
}>();
|
|
77
|
-
|
|
78
|
-
// Create client instance
|
|
79
|
-
const client = new TypedRPCClient({
|
|
80
|
-
// let typescript infer the type from ServerAPIDefine
|
|
81
|
-
remote:ServerAPIDefine,
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
// Connect to server
|
|
85
|
-
const connection = await client.connect("localhost:3698");
|
|
86
|
-
|
|
87
|
-
// Get API instance
|
|
88
|
-
const api = client.getAPI(connection);
|
|
89
|
-
|
|
90
|
-
// Make RPC calls
|
|
91
|
-
const result = await api.math.add.call(1,2); // Returns 3
|
|
92
|
-
```
|
|
93
|
-
|
|
94
|
-
## Connection Types
|
|
95
|
-
|
|
96
|
-
TypedRPC supports multiple connection types:
|
|
97
|
-
|
|
98
|
-
1. **HTTP** - RESTful HTTP API
|
|
99
|
-
2. **Socket** - Raw socket connections
|
|
100
|
-
3. **SocketIO** - Socket.IO connections
|
|
101
|
-
4. **Custom** - User-defined connection providers, see abstract class `TypedRPCConnectionProvider`
|
|
102
|
-
|
|
103
|
-
```typescript
|
|
104
|
-
new TypedRPCServer({
|
|
105
|
-
local:ServerAPIDefine,
|
|
106
|
-
connection:{
|
|
107
|
-
provider:new TypedRPCConnectionProviderHTTP(),
|
|
108
|
-
// or use socket connection
|
|
109
|
-
// provider:new TypedRPCConnectionProviderSocket(),
|
|
110
|
-
// or use socketio connection
|
|
111
|
-
// provider:new TypedRPCConnectionProviderSocketIO(),
|
|
112
|
-
// or implaement your own connection provider
|
|
113
|
-
}
|
|
114
|
-
})
|
|
115
|
-
```
|
|
116
|
-
|
|
117
|
-
## API Documentation
|
|
118
|
-
|
|
119
|
-
### Server API
|
|
120
|
-
|
|
121
|
-
- `new TypedRPCServer(config)` - Create a new server instance
|
|
122
|
-
- `server.hook(serviceName, methodName, config)` - Hook a single method
|
|
123
|
-
- `server.hookService(serviceName, instance)` - Hook an entire service
|
|
124
|
-
- `server.use(middleware)` - Add middleware
|
|
125
|
-
- `server.listen()` - Start listening for connections
|
|
126
|
-
- `server.close()` - Close the server
|
|
127
|
-
|
|
128
|
-
### Client API
|
|
129
|
-
|
|
130
|
-
- `new TypedRPCClient(config)` - Create a new client instance
|
|
131
|
-
- `client.connect()` - Connect to the server
|
|
132
|
-
- `client.getAPI(connection)` - Get API instance for a connection
|
|
133
|
-
- `client.use(middleware)` - Add middleware
|
|
134
|
-
|
|
135
|
-
## Middleware Usage
|
|
136
|
-
|
|
137
|
-
TypedRPC supports middleware for both servers and clients:
|
|
138
|
-
|
|
139
|
-
```typescript
|
|
140
|
-
class MyMiddleware extends TypedRPCMiddleware{
|
|
141
|
-
|
|
142
|
-
async inbound(context: TypedRPCContext): Promise<TypedRPCContext> {
|
|
143
|
-
// Do something when inbound packet
|
|
144
|
-
return context;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
async outbound(context: TypedRPCContext): Promise<TypedRPCContext> {
|
|
148
|
-
// Do something when outbound packet
|
|
149
|
-
return context;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
}
|
|
153
|
-
```
|
|
154
|
-
|
|
155
|
-
## Context Usage
|
|
156
|
-
|
|
157
|
-
TypedRPC provides a built-in context system that allows you to access request context in your service methods. This is particularly useful for accessing connection information, authentication data, or other request-specific data.
|
|
158
|
-
|
|
159
|
-
### Example: Using Context in Services
|
|
160
|
-
|
|
161
|
-
```typescript
|
|
162
|
-
// Server-side code
|
|
163
|
-
import { TypedRPCServer, TypedRPCAPIDefine, TypedRPCContextSymbol, type TypedRPCContext, type TypedRPCContextAware } from '@mingzey/typedrpc';
|
|
164
|
-
|
|
165
|
-
// Define service interface
|
|
166
|
-
interface MathServiceInterface {
|
|
167
|
-
add(a: number, b: number):number;
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
// Create API definition
|
|
171
|
-
const serverAPIDefine = new TypedRPCAPIDefine<{
|
|
172
|
-
math: MathServiceInterface,
|
|
173
|
-
}>();
|
|
174
|
-
|
|
175
|
-
// Create server instance
|
|
176
|
-
const server = new TypedRPCServer({
|
|
177
|
-
local: serverAPIDefine,
|
|
178
|
-
});
|
|
179
|
-
|
|
180
|
-
// Implement service with context awareness
|
|
181
|
-
class MathService implements MathServiceInterface, TypedRPCContextAware {
|
|
182
|
-
// Inject context using TypedRPCContextSymbol
|
|
183
|
-
[TypedRPCContextSymbol]: TypedRPCContext | null = null;
|
|
184
|
-
|
|
185
|
-
/**
|
|
186
|
-
* For safety, must use @TypedRPCAPIDefine.method() to mark method as RPC method in service usage
|
|
187
|
-
* You need set experimentalDecorators:true in tsconfig.json
|
|
188
|
-
*/
|
|
189
|
-
@TypedRPCAPIDefine.method()
|
|
190
|
-
add(a: number, b: number): number {
|
|
191
|
-
// Access context
|
|
192
|
-
const context = this[TypedRPCContextSymbol];
|
|
193
|
-
if (!context) {
|
|
194
|
-
throw new Error('Context is not available');
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
// Use context information (e.g., connection details, authentication)
|
|
198
|
-
console.log('Request received from:', context.connection);
|
|
199
|
-
|
|
200
|
-
return a + b;
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
// Hook service to server, only methods marked with @TypedRPCAPIDefine.method() will be hooked
|
|
205
|
-
server.hookService('math', new MathService());
|
|
206
|
-
|
|
207
|
-
// Start server
|
|
208
|
-
server.listen({
|
|
209
|
-
port: 3698,
|
|
210
|
-
});
|
|
211
|
-
```
|
|
212
|
-
|
|
213
|
-
```typescript
|
|
214
|
-
// Client-side code
|
|
215
|
-
import { TypedRPCClient, TypedRPCAPIDefine } from 'typedrpc';
|
|
216
|
-
|
|
217
|
-
// Reuse API definition
|
|
218
|
-
const serverAPIDefine = new TypedRPCAPIDefine<{
|
|
219
|
-
math: MathServiceInterface,
|
|
220
|
-
}>();
|
|
221
|
-
|
|
222
|
-
// Create client
|
|
223
|
-
const client = new TypedRPCClient({
|
|
224
|
-
remote: serverAPIDefine,
|
|
225
|
-
});
|
|
226
|
-
|
|
227
|
-
// Connect and make RPC call
|
|
228
|
-
const connection = await client.connect("localhost:3698");
|
|
229
|
-
const api = client.getAPI(connection);
|
|
230
|
-
const result = await api.math.add.call(1, 2); // Returns 3
|
|
231
|
-
```
|
|
232
|
-
|
|
233
|
-
## More Usage
|
|
234
|
-
|
|
235
|
-
see `./test/*.ts` for more usage.
|
|
236
|
-
|
|
237
|
-
## Contributing
|
|
238
|
-
|
|
239
|
-
Contributions are welcome! Please feel free to submit a Pull Request.
|
|
240
|
-
|
|
241
|
-
## License
|
|
242
|
-
|
|
243
|
-
MIT License - see the [LICENSE](https://github.com/MingZeY/TypedRPC/blob/master/LICENSE) file for details.
|
|
1
|
+
[English](./README.md) / [中文](./README.zh-CN.md)
|
|
2
|
+
# TypedRPC
|
|
3
|
+
|
|
4
|
+
TypeScript-based RPC framework with support for multiple connection types including HTTP, Socket, and SocketIO.
|
|
5
|
+
|
|
6
|
+
## Repository
|
|
7
|
+
|
|
8
|
+
[Github](https://github.com/MingZeY/TypedRPC)
|
|
9
|
+
|
|
10
|
+
## Features
|
|
11
|
+
|
|
12
|
+
- 🛡️ **Type-Safe RPC calls** - Leverage TypeScript's type system for end-to-end type safety
|
|
13
|
+
- 🔌 **Multiple connection types** - Support for HTTP, Socket, and SocketIO connections, or custom connection providers
|
|
14
|
+
- 🔄 **Middleware support** - Extensible middleware system for request/response handling
|
|
15
|
+
- 📝 **Context-aware** - Built-in context system for passing data between handlers
|
|
16
|
+
- 🔁 **Bidirectional communication** - Support for two-way RPC calls between client and server, capability depends on connection type
|
|
17
|
+
- 📦 **Easy to use** - Simple API for defining services and methods
|
|
18
|
+
- 🚀 **Zero dependencies** - No external library dependencies, only depends on TypeScript standard library
|
|
19
|
+
- 🌐 **Frontend and backend compatible** - Can be used in Node.js backend and browser frontend
|
|
20
|
+
- 📈 **High extensibility** - Can be easily integrated into frameworks like Electron, Express as an RPC solution
|
|
21
|
+
|
|
22
|
+
## Installation
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
npm install @mingzey/typedrpc
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Basic Usage
|
|
29
|
+
|
|
30
|
+
### Server Setup
|
|
31
|
+
|
|
32
|
+
```typescript
|
|
33
|
+
import { TypedRPCServer, TypedRPCAPIDefine } from '@mingzey/typedrpc';
|
|
34
|
+
|
|
35
|
+
// Define your API interface
|
|
36
|
+
const ServerAPIDefine = new TypedRPCAPIDefine<{
|
|
37
|
+
// Service layer - Define your services here or use interface inheritance
|
|
38
|
+
math:{
|
|
39
|
+
// Method layer - Define your methods here
|
|
40
|
+
add(a:number,b:number):number,
|
|
41
|
+
},
|
|
42
|
+
}>({
|
|
43
|
+
timeout:10 * 1000
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
// Create server instance
|
|
47
|
+
const server = new TypedRPCServer({
|
|
48
|
+
// let typescript infer the type from ServerAPIDefine
|
|
49
|
+
local:ServerAPIDefine,
|
|
50
|
+
// Connection layer - use your connection provider here
|
|
51
|
+
// connection:{
|
|
52
|
+
// provider:new TypedRPCConnectionProviderHTTP(),
|
|
53
|
+
// }
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
// Hook service methods
|
|
57
|
+
server.hook('math','add',{
|
|
58
|
+
handler: (a,b) => a+b,
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
// Start listening
|
|
62
|
+
server.listen({
|
|
63
|
+
port:3698,
|
|
64
|
+
})
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### Client Setup
|
|
68
|
+
|
|
69
|
+
```typescript
|
|
70
|
+
import { TypedRPCClient, TypedRPCAPIDefine } from '@mingzey/typedrpc';
|
|
71
|
+
// Reuse or import the same API definition
|
|
72
|
+
const ServerAPIDefine = new TypedRPCAPIDefine<{
|
|
73
|
+
math:{
|
|
74
|
+
add(a:number,b:number):number,
|
|
75
|
+
},
|
|
76
|
+
}>();
|
|
77
|
+
|
|
78
|
+
// Create client instance
|
|
79
|
+
const client = new TypedRPCClient({
|
|
80
|
+
// let typescript infer the type from ServerAPIDefine
|
|
81
|
+
remote:ServerAPIDefine,
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
// Connect to server
|
|
85
|
+
const connection = await client.connect("localhost:3698");
|
|
86
|
+
|
|
87
|
+
// Get API instance
|
|
88
|
+
const api = client.getAPI(connection);
|
|
89
|
+
|
|
90
|
+
// Make RPC calls
|
|
91
|
+
const result = await api.math.add.call(1,2); // Returns 3
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## Connection Types
|
|
95
|
+
|
|
96
|
+
TypedRPC supports multiple connection types:
|
|
97
|
+
|
|
98
|
+
1. **HTTP** - RESTful HTTP API
|
|
99
|
+
2. **Socket** - Raw socket connections
|
|
100
|
+
3. **SocketIO** - Socket.IO connections
|
|
101
|
+
4. **Custom** - User-defined connection providers, see abstract class `TypedRPCConnectionProvider`
|
|
102
|
+
|
|
103
|
+
```typescript
|
|
104
|
+
new TypedRPCServer({
|
|
105
|
+
local:ServerAPIDefine,
|
|
106
|
+
connection:{
|
|
107
|
+
provider:new TypedRPCConnectionProviderHTTP(),
|
|
108
|
+
// or use socket connection
|
|
109
|
+
// provider:new TypedRPCConnectionProviderSocket(),
|
|
110
|
+
// or use socketio connection
|
|
111
|
+
// provider:new TypedRPCConnectionProviderSocketIO(),
|
|
112
|
+
// or implaement your own connection provider
|
|
113
|
+
}
|
|
114
|
+
})
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
## API Documentation
|
|
118
|
+
|
|
119
|
+
### Server API
|
|
120
|
+
|
|
121
|
+
- `new TypedRPCServer(config)` - Create a new server instance
|
|
122
|
+
- `server.hook(serviceName, methodName, config)` - Hook a single method
|
|
123
|
+
- `server.hookService(serviceName, instance)` - Hook an entire service
|
|
124
|
+
- `server.use(middleware)` - Add middleware
|
|
125
|
+
- `server.listen()` - Start listening for connections
|
|
126
|
+
- `server.close()` - Close the server
|
|
127
|
+
|
|
128
|
+
### Client API
|
|
129
|
+
|
|
130
|
+
- `new TypedRPCClient(config)` - Create a new client instance
|
|
131
|
+
- `client.connect()` - Connect to the server
|
|
132
|
+
- `client.getAPI(connection)` - Get API instance for a connection
|
|
133
|
+
- `client.use(middleware)` - Add middleware
|
|
134
|
+
|
|
135
|
+
## Middleware Usage
|
|
136
|
+
|
|
137
|
+
TypedRPC supports middleware for both servers and clients:
|
|
138
|
+
|
|
139
|
+
```typescript
|
|
140
|
+
class MyMiddleware extends TypedRPCMiddleware{
|
|
141
|
+
|
|
142
|
+
async inbound(context: TypedRPCContext): Promise<TypedRPCContext> {
|
|
143
|
+
// Do something when inbound packet
|
|
144
|
+
return context;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
async outbound(context: TypedRPCContext): Promise<TypedRPCContext> {
|
|
148
|
+
// Do something when outbound packet
|
|
149
|
+
return context;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
}
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
## Context Usage
|
|
156
|
+
|
|
157
|
+
TypedRPC provides a built-in context system that allows you to access request context in your service methods. This is particularly useful for accessing connection information, authentication data, or other request-specific data.
|
|
158
|
+
|
|
159
|
+
### Example: Using Context in Services
|
|
160
|
+
|
|
161
|
+
```typescript
|
|
162
|
+
// Server-side code
|
|
163
|
+
import { TypedRPCServer, TypedRPCAPIDefine, TypedRPCContextSymbol, type TypedRPCContext, type TypedRPCContextAware } from '@mingzey/typedrpc';
|
|
164
|
+
|
|
165
|
+
// Define service interface
|
|
166
|
+
interface MathServiceInterface {
|
|
167
|
+
add(a: number, b: number):number;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
// Create API definition
|
|
171
|
+
const serverAPIDefine = new TypedRPCAPIDefine<{
|
|
172
|
+
math: MathServiceInterface,
|
|
173
|
+
}>();
|
|
174
|
+
|
|
175
|
+
// Create server instance
|
|
176
|
+
const server = new TypedRPCServer({
|
|
177
|
+
local: serverAPIDefine,
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
// Implement service with context awareness
|
|
181
|
+
class MathService implements MathServiceInterface, TypedRPCContextAware {
|
|
182
|
+
// Inject context using TypedRPCContextSymbol
|
|
183
|
+
[TypedRPCContextSymbol]: TypedRPCContext | null = null;
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* For safety, must use @TypedRPCAPIDefine.method() to mark method as RPC method in service usage
|
|
187
|
+
* You need set experimentalDecorators:true in tsconfig.json
|
|
188
|
+
*/
|
|
189
|
+
@TypedRPCAPIDefine.method()
|
|
190
|
+
add(a: number, b: number): number {
|
|
191
|
+
// Access context
|
|
192
|
+
const context = this[TypedRPCContextSymbol];
|
|
193
|
+
if (!context) {
|
|
194
|
+
throw new Error('Context is not available');
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
// Use context information (e.g., connection details, authentication)
|
|
198
|
+
console.log('Request received from:', context.connection);
|
|
199
|
+
|
|
200
|
+
return a + b;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
// Hook service to server, only methods marked with @TypedRPCAPIDefine.method() will be hooked
|
|
205
|
+
server.hookService('math', new MathService());
|
|
206
|
+
|
|
207
|
+
// Start server
|
|
208
|
+
server.listen({
|
|
209
|
+
port: 3698,
|
|
210
|
+
});
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
```typescript
|
|
214
|
+
// Client-side code
|
|
215
|
+
import { TypedRPCClient, TypedRPCAPIDefine } from 'typedrpc';
|
|
216
|
+
|
|
217
|
+
// Reuse API definition
|
|
218
|
+
const serverAPIDefine = new TypedRPCAPIDefine<{
|
|
219
|
+
math: MathServiceInterface,
|
|
220
|
+
}>();
|
|
221
|
+
|
|
222
|
+
// Create client
|
|
223
|
+
const client = new TypedRPCClient({
|
|
224
|
+
remote: serverAPIDefine,
|
|
225
|
+
});
|
|
226
|
+
|
|
227
|
+
// Connect and make RPC call
|
|
228
|
+
const connection = await client.connect("localhost:3698");
|
|
229
|
+
const api = client.getAPI(connection);
|
|
230
|
+
const result = await api.math.add.call(1, 2); // Returns 3
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
## More Usage
|
|
234
|
+
|
|
235
|
+
see `./test/*.ts` for more usage.
|
|
236
|
+
|
|
237
|
+
## Contributing
|
|
238
|
+
|
|
239
|
+
Contributions are welcome! Please feel free to submit a Pull Request.
|
|
240
|
+
|
|
241
|
+
## License
|
|
242
|
+
|
|
243
|
+
MIT License - see the [LICENSE](https://github.com/MingZeY/TypedRPC/blob/master/LICENSE) file for details.
|
package/README.zh-CN.md
CHANGED
|
@@ -1,244 +1,244 @@
|
|
|
1
|
-
[English](./README.md) / [中文](./README.zh-CN.md)
|
|
2
|
-
|
|
3
|
-
# TypedRPC
|
|
4
|
-
|
|
5
|
-
基于 TypeScript 的 RPC 框架,支持多种连接类型,包括 HTTP、Socket 和 SocketIO。
|
|
6
|
-
|
|
7
|
-
## 仓库
|
|
8
|
-
|
|
9
|
-
[Github](https://github.com/MingZeY/TypedRPC)
|
|
10
|
-
|
|
11
|
-
## 特性
|
|
12
|
-
|
|
13
|
-
- 🛡️ **类型安全的 RPC 调用** - 利用 TypeScript 的类型系统实现端到端的类型安全
|
|
14
|
-
- 🔌 **多种连接类型** - 支持 HTTP、Socket 和 SocketIO 连接,或自定义`TypedRPCConnectionProvider`
|
|
15
|
-
- 🔄 **中间件支持** - 可扩展的中间件系统,用于请求/响应处理
|
|
16
|
-
- 📝 **上下文感知** - 内置上下文系统,用于在处理程序之间传递数据
|
|
17
|
-
- 🔁 **双向通信** - 支持客户端和服务器之间的双向 RPC 调用,能力取决于连接类型
|
|
18
|
-
- 📦 **易于使用** - 用于定义服务和方法的简单 API
|
|
19
|
-
- 🚀 **零依赖** - 不依赖任何外部库,仅依赖 TypeScript 标准库
|
|
20
|
-
- 🌐 **前后端通用** - 可在 Node.js 后端和浏览器前端使用
|
|
21
|
-
- 📈 **高拓展性** - 可轻松集成入 Electron、Express 等框架作为 RPC 调用方案
|
|
22
|
-
|
|
23
|
-
## 安装
|
|
24
|
-
|
|
25
|
-
```bash
|
|
26
|
-
npm install @mingzey/typedrpc
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
## 基本使用
|
|
30
|
-
|
|
31
|
-
### 服务器设置
|
|
32
|
-
|
|
33
|
-
```typescript
|
|
34
|
-
import { TypedRPCServer, TypedRPCAPIDefine } from '@mingzey/typedrpc';
|
|
35
|
-
|
|
36
|
-
// 定义 API 接口
|
|
37
|
-
const ServerAPIDefine = new TypedRPCAPIDefine<{
|
|
38
|
-
// 服务层 - 在此处定义服务或使用接口继承
|
|
39
|
-
math:{
|
|
40
|
-
// 方法层 - 在此处定义方法
|
|
41
|
-
add(a:number,b:number):number,
|
|
42
|
-
},
|
|
43
|
-
}>({
|
|
44
|
-
timeout:10 * 1000
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
// 创建服务器实例
|
|
48
|
-
const server = new TypedRPCServer({
|
|
49
|
-
// 让 TypeScript 从 ServerAPIDefine 推断类型
|
|
50
|
-
local:ServerAPIDefine,
|
|
51
|
-
// 连接层 - 在此处使用连接提供者
|
|
52
|
-
// connection:{
|
|
53
|
-
// provider:new TypedRPCConnectionProviderHTTP(),
|
|
54
|
-
// }
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
// 挂钩服务方法
|
|
58
|
-
server.hook('math','add',{
|
|
59
|
-
handler: (a,b) => a+b,
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
// 开始监听
|
|
63
|
-
server.listen({
|
|
64
|
-
port:3698,
|
|
65
|
-
})
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
### 客户端设置
|
|
69
|
-
|
|
70
|
-
```typescript
|
|
71
|
-
import { TypedRPCClient, TypedRPCAPIDefine } from '@mingzey/typedrpc';
|
|
72
|
-
// 重用或导入相同的 API 定义
|
|
73
|
-
const ServerAPIDefine = new TypedRPCAPIDefine<{
|
|
74
|
-
math:{
|
|
75
|
-
add(a:number,b:number):number,
|
|
76
|
-
},
|
|
77
|
-
}>();
|
|
78
|
-
|
|
79
|
-
// 创建客户端实例
|
|
80
|
-
const client = new TypedRPCClient({
|
|
81
|
-
// 让 TypeScript 从 ServerAPIDefine 推断类型
|
|
82
|
-
remote:ServerAPIDefine,
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
// 连接到服务器
|
|
86
|
-
const connection = await client.connect("localhost:3698");
|
|
87
|
-
|
|
88
|
-
// 获取 API 实例
|
|
89
|
-
const api = client.getAPI(connection);
|
|
90
|
-
|
|
91
|
-
// 进行 RPC 调用
|
|
92
|
-
const result = await api.math.add.call(1,2); // 返回 3
|
|
93
|
-
```
|
|
94
|
-
|
|
95
|
-
## 连接类型
|
|
96
|
-
|
|
97
|
-
TypedRPC 支持多种连接类型:
|
|
98
|
-
|
|
99
|
-
1. **HTTP** - RESTful HTTP API
|
|
100
|
-
2. **Socket** - 原始套接字连接
|
|
101
|
-
3. **SocketIO** - Socket.IO 连接
|
|
102
|
-
4. **自定义** - 用户定义的连接提供者,参见抽象类 `TypedRPCConnectionProvider`
|
|
103
|
-
|
|
104
|
-
```typescript
|
|
105
|
-
new TypedRPCServer({
|
|
106
|
-
local:ServerAPIDefine,
|
|
107
|
-
connection:{
|
|
108
|
-
provider:new TypedRPCConnectionProviderHTTP(),
|
|
109
|
-
// or use socket connection
|
|
110
|
-
// provider:new TypedRPCConnectionProviderSocket(),
|
|
111
|
-
// or use socketio connection
|
|
112
|
-
// provider:new TypedRPCConnectionProviderSocketIO(),
|
|
113
|
-
// or implaement your own connection provider
|
|
114
|
-
}
|
|
115
|
-
})
|
|
116
|
-
```
|
|
117
|
-
|
|
118
|
-
## API 文档
|
|
119
|
-
|
|
120
|
-
### 服务器 API
|
|
121
|
-
|
|
122
|
-
- `new TypedRPCServer(config)` - 创建新的服务器实例
|
|
123
|
-
- `server.hook(serviceName, methodName, config)` - 挂钩单个方法
|
|
124
|
-
- `server.hookService(serviceName, instance)` - 挂钩整个服务
|
|
125
|
-
- `server.use(middleware)` - 添加中间件
|
|
126
|
-
- `server.listen()` - 开始监听连接
|
|
127
|
-
- `server.close()` - 关闭服务器
|
|
128
|
-
|
|
129
|
-
### 客户端 API
|
|
130
|
-
|
|
131
|
-
- `new TypedRPCClient(config)` - 创建新的客户端实例
|
|
132
|
-
- `client.connect()` - 连接到服务器
|
|
133
|
-
- `client.getAPI(connection)` - 获取连接的 API 实例
|
|
134
|
-
- `client.use(middleware)` - 添加中间件
|
|
135
|
-
|
|
136
|
-
## 中间件使用
|
|
137
|
-
|
|
138
|
-
TypedRPC 支持服务器和客户端的中间件:
|
|
139
|
-
|
|
140
|
-
```typescript
|
|
141
|
-
class MyMiddleware extends TypedRPCMiddleware{
|
|
142
|
-
|
|
143
|
-
async inbound(context: TypedRPCContext): Promise<TypedRPCContext> {
|
|
144
|
-
// Do something when inbound packet
|
|
145
|
-
return context;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
async outbound(context: TypedRPCContext): Promise<TypedRPCContext> {
|
|
149
|
-
// Do something when outbound packet
|
|
150
|
-
return context;
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
}
|
|
154
|
-
```
|
|
155
|
-
|
|
156
|
-
## 上下文使用
|
|
157
|
-
|
|
158
|
-
TypedRPC 提供内置的上下文系统,允许您在服务方法中访问请求上下文。这对于访问连接信息、认证数据或其他请求特定数据特别有用。
|
|
159
|
-
|
|
160
|
-
### 示例:在服务中使用上下文
|
|
161
|
-
|
|
162
|
-
```typescript
|
|
163
|
-
// Server-side code
|
|
164
|
-
import { TypedRPCServer, TypedRPCAPIDefine, TypedRPCContextSymbol, type TypedRPCContext, type TypedRPCContextAware } from '@mingzey/typedrpc';
|
|
165
|
-
|
|
166
|
-
// Define service interface
|
|
167
|
-
interface MathServiceInterface {
|
|
168
|
-
add(a: number, b: number):number;
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
// Create API definition
|
|
172
|
-
const serverAPIDefine = new TypedRPCAPIDefine<{
|
|
173
|
-
math: MathServiceInterface,
|
|
174
|
-
}>();
|
|
175
|
-
|
|
176
|
-
// Create server instance
|
|
177
|
-
const server = new TypedRPCServer({
|
|
178
|
-
local: serverAPIDefine,
|
|
179
|
-
});
|
|
180
|
-
|
|
181
|
-
// Implement service with context awareness
|
|
182
|
-
class MathService implements MathServiceInterface, TypedRPCContextAware {
|
|
183
|
-
// Inject context using TypedRPCContextSymbol
|
|
184
|
-
[TypedRPCContextSymbol]: TypedRPCContext | null = null;
|
|
185
|
-
|
|
186
|
-
/**
|
|
187
|
-
* For safety, must use @TypedRPCAPIDefine.method() to mark method as RPC method in service usage
|
|
188
|
-
* You need set experimentalDecorators:true in tsconfig.json
|
|
189
|
-
*/
|
|
190
|
-
@TypedRPCAPIDefine.method()
|
|
191
|
-
add(a: number, b: number): number {
|
|
192
|
-
// Access context
|
|
193
|
-
const context = this[TypedRPCContextSymbol];
|
|
194
|
-
if (!context) {
|
|
195
|
-
throw new Error('Context is not available');
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
// Use context information (e.g., connection details, authentication)
|
|
199
|
-
console.log('Request received from:', context.connection);
|
|
200
|
-
|
|
201
|
-
return a + b;
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
// Hook service to server, only methods marked with @TypedRPCAPIDefine.method() will be hooked
|
|
206
|
-
server.hookService('math', new MathService());
|
|
207
|
-
|
|
208
|
-
// Start server
|
|
209
|
-
server.listen({
|
|
210
|
-
port: 3698,
|
|
211
|
-
});
|
|
212
|
-
```
|
|
213
|
-
|
|
214
|
-
```typescript
|
|
215
|
-
// Client-side code
|
|
216
|
-
import { TypedRPCClient, TypedRPCAPIDefine } from 'typedrpc';
|
|
217
|
-
|
|
218
|
-
// Reuse API definition
|
|
219
|
-
const serverAPIDefine = new TypedRPCAPIDefine<{
|
|
220
|
-
math: MathServiceInterface,
|
|
221
|
-
}>();
|
|
222
|
-
|
|
223
|
-
// Create client
|
|
224
|
-
const client = new TypedRPCClient({
|
|
225
|
-
remote: serverAPIDefine,
|
|
226
|
-
});
|
|
227
|
-
|
|
228
|
-
// Connect and make RPC call
|
|
229
|
-
const connection = await client.connect("localhost:3698");
|
|
230
|
-
const api = client.getAPI(connection);
|
|
231
|
-
const result = await api.math.add.call(1, 2); // Returns 3
|
|
232
|
-
```
|
|
233
|
-
|
|
234
|
-
## More Usage
|
|
235
|
-
|
|
236
|
-
see `./test/*.ts` for more usage.
|
|
237
|
-
|
|
238
|
-
## Contributing
|
|
239
|
-
|
|
240
|
-
Contributions are welcome! Please feel free to submit a Pull Request.
|
|
241
|
-
|
|
242
|
-
## License
|
|
243
|
-
|
|
1
|
+
[English](./README.md) / [中文](./README.zh-CN.md)
|
|
2
|
+
|
|
3
|
+
# TypedRPC
|
|
4
|
+
|
|
5
|
+
基于 TypeScript 的 RPC 框架,支持多种连接类型,包括 HTTP、Socket 和 SocketIO。
|
|
6
|
+
|
|
7
|
+
## 仓库
|
|
8
|
+
|
|
9
|
+
[Github](https://github.com/MingZeY/TypedRPC)
|
|
10
|
+
|
|
11
|
+
## 特性
|
|
12
|
+
|
|
13
|
+
- 🛡️ **类型安全的 RPC 调用** - 利用 TypeScript 的类型系统实现端到端的类型安全
|
|
14
|
+
- 🔌 **多种连接类型** - 支持 HTTP、Socket 和 SocketIO 连接,或自定义`TypedRPCConnectionProvider`
|
|
15
|
+
- 🔄 **中间件支持** - 可扩展的中间件系统,用于请求/响应处理
|
|
16
|
+
- 📝 **上下文感知** - 内置上下文系统,用于在处理程序之间传递数据
|
|
17
|
+
- 🔁 **双向通信** - 支持客户端和服务器之间的双向 RPC 调用,能力取决于连接类型
|
|
18
|
+
- 📦 **易于使用** - 用于定义服务和方法的简单 API
|
|
19
|
+
- 🚀 **零依赖** - 不依赖任何外部库,仅依赖 TypeScript 标准库
|
|
20
|
+
- 🌐 **前后端通用** - 可在 Node.js 后端和浏览器前端使用
|
|
21
|
+
- 📈 **高拓展性** - 可轻松集成入 Electron、Express 等框架作为 RPC 调用方案
|
|
22
|
+
|
|
23
|
+
## 安装
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
npm install @mingzey/typedrpc
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## 基本使用
|
|
30
|
+
|
|
31
|
+
### 服务器设置
|
|
32
|
+
|
|
33
|
+
```typescript
|
|
34
|
+
import { TypedRPCServer, TypedRPCAPIDefine } from '@mingzey/typedrpc';
|
|
35
|
+
|
|
36
|
+
// 定义 API 接口
|
|
37
|
+
const ServerAPIDefine = new TypedRPCAPIDefine<{
|
|
38
|
+
// 服务层 - 在此处定义服务或使用接口继承
|
|
39
|
+
math:{
|
|
40
|
+
// 方法层 - 在此处定义方法
|
|
41
|
+
add(a:number,b:number):number,
|
|
42
|
+
},
|
|
43
|
+
}>({
|
|
44
|
+
timeout:10 * 1000
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
// 创建服务器实例
|
|
48
|
+
const server = new TypedRPCServer({
|
|
49
|
+
// 让 TypeScript 从 ServerAPIDefine 推断类型
|
|
50
|
+
local:ServerAPIDefine,
|
|
51
|
+
// 连接层 - 在此处使用连接提供者
|
|
52
|
+
// connection:{
|
|
53
|
+
// provider:new TypedRPCConnectionProviderHTTP(),
|
|
54
|
+
// }
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
// 挂钩服务方法
|
|
58
|
+
server.hook('math','add',{
|
|
59
|
+
handler: (a,b) => a+b,
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
// 开始监听
|
|
63
|
+
server.listen({
|
|
64
|
+
port:3698,
|
|
65
|
+
})
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### 客户端设置
|
|
69
|
+
|
|
70
|
+
```typescript
|
|
71
|
+
import { TypedRPCClient, TypedRPCAPIDefine } from '@mingzey/typedrpc';
|
|
72
|
+
// 重用或导入相同的 API 定义
|
|
73
|
+
const ServerAPIDefine = new TypedRPCAPIDefine<{
|
|
74
|
+
math:{
|
|
75
|
+
add(a:number,b:number):number,
|
|
76
|
+
},
|
|
77
|
+
}>();
|
|
78
|
+
|
|
79
|
+
// 创建客户端实例
|
|
80
|
+
const client = new TypedRPCClient({
|
|
81
|
+
// 让 TypeScript 从 ServerAPIDefine 推断类型
|
|
82
|
+
remote:ServerAPIDefine,
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
// 连接到服务器
|
|
86
|
+
const connection = await client.connect("localhost:3698");
|
|
87
|
+
|
|
88
|
+
// 获取 API 实例
|
|
89
|
+
const api = client.getAPI(connection);
|
|
90
|
+
|
|
91
|
+
// 进行 RPC 调用
|
|
92
|
+
const result = await api.math.add.call(1,2); // 返回 3
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
## 连接类型
|
|
96
|
+
|
|
97
|
+
TypedRPC 支持多种连接类型:
|
|
98
|
+
|
|
99
|
+
1. **HTTP** - RESTful HTTP API
|
|
100
|
+
2. **Socket** - 原始套接字连接
|
|
101
|
+
3. **SocketIO** - Socket.IO 连接
|
|
102
|
+
4. **自定义** - 用户定义的连接提供者,参见抽象类 `TypedRPCConnectionProvider`
|
|
103
|
+
|
|
104
|
+
```typescript
|
|
105
|
+
new TypedRPCServer({
|
|
106
|
+
local:ServerAPIDefine,
|
|
107
|
+
connection:{
|
|
108
|
+
provider:new TypedRPCConnectionProviderHTTP(),
|
|
109
|
+
// or use socket connection
|
|
110
|
+
// provider:new TypedRPCConnectionProviderSocket(),
|
|
111
|
+
// or use socketio connection
|
|
112
|
+
// provider:new TypedRPCConnectionProviderSocketIO(),
|
|
113
|
+
// or implaement your own connection provider
|
|
114
|
+
}
|
|
115
|
+
})
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
## API 文档
|
|
119
|
+
|
|
120
|
+
### 服务器 API
|
|
121
|
+
|
|
122
|
+
- `new TypedRPCServer(config)` - 创建新的服务器实例
|
|
123
|
+
- `server.hook(serviceName, methodName, config)` - 挂钩单个方法
|
|
124
|
+
- `server.hookService(serviceName, instance)` - 挂钩整个服务
|
|
125
|
+
- `server.use(middleware)` - 添加中间件
|
|
126
|
+
- `server.listen()` - 开始监听连接
|
|
127
|
+
- `server.close()` - 关闭服务器
|
|
128
|
+
|
|
129
|
+
### 客户端 API
|
|
130
|
+
|
|
131
|
+
- `new TypedRPCClient(config)` - 创建新的客户端实例
|
|
132
|
+
- `client.connect()` - 连接到服务器
|
|
133
|
+
- `client.getAPI(connection)` - 获取连接的 API 实例
|
|
134
|
+
- `client.use(middleware)` - 添加中间件
|
|
135
|
+
|
|
136
|
+
## 中间件使用
|
|
137
|
+
|
|
138
|
+
TypedRPC 支持服务器和客户端的中间件:
|
|
139
|
+
|
|
140
|
+
```typescript
|
|
141
|
+
class MyMiddleware extends TypedRPCMiddleware{
|
|
142
|
+
|
|
143
|
+
async inbound(context: TypedRPCContext): Promise<TypedRPCContext> {
|
|
144
|
+
// Do something when inbound packet
|
|
145
|
+
return context;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
async outbound(context: TypedRPCContext): Promise<TypedRPCContext> {
|
|
149
|
+
// Do something when outbound packet
|
|
150
|
+
return context;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
}
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
## 上下文使用
|
|
157
|
+
|
|
158
|
+
TypedRPC 提供内置的上下文系统,允许您在服务方法中访问请求上下文。这对于访问连接信息、认证数据或其他请求特定数据特别有用。
|
|
159
|
+
|
|
160
|
+
### 示例:在服务中使用上下文
|
|
161
|
+
|
|
162
|
+
```typescript
|
|
163
|
+
// Server-side code
|
|
164
|
+
import { TypedRPCServer, TypedRPCAPIDefine, TypedRPCContextSymbol, type TypedRPCContext, type TypedRPCContextAware } from '@mingzey/typedrpc';
|
|
165
|
+
|
|
166
|
+
// Define service interface
|
|
167
|
+
interface MathServiceInterface {
|
|
168
|
+
add(a: number, b: number):number;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
// Create API definition
|
|
172
|
+
const serverAPIDefine = new TypedRPCAPIDefine<{
|
|
173
|
+
math: MathServiceInterface,
|
|
174
|
+
}>();
|
|
175
|
+
|
|
176
|
+
// Create server instance
|
|
177
|
+
const server = new TypedRPCServer({
|
|
178
|
+
local: serverAPIDefine,
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
// Implement service with context awareness
|
|
182
|
+
class MathService implements MathServiceInterface, TypedRPCContextAware {
|
|
183
|
+
// Inject context using TypedRPCContextSymbol
|
|
184
|
+
[TypedRPCContextSymbol]: TypedRPCContext | null = null;
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* For safety, must use @TypedRPCAPIDefine.method() to mark method as RPC method in service usage
|
|
188
|
+
* You need set experimentalDecorators:true in tsconfig.json
|
|
189
|
+
*/
|
|
190
|
+
@TypedRPCAPIDefine.method()
|
|
191
|
+
add(a: number, b: number): number {
|
|
192
|
+
// Access context
|
|
193
|
+
const context = this[TypedRPCContextSymbol];
|
|
194
|
+
if (!context) {
|
|
195
|
+
throw new Error('Context is not available');
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
// Use context information (e.g., connection details, authentication)
|
|
199
|
+
console.log('Request received from:', context.connection);
|
|
200
|
+
|
|
201
|
+
return a + b;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
// Hook service to server, only methods marked with @TypedRPCAPIDefine.method() will be hooked
|
|
206
|
+
server.hookService('math', new MathService());
|
|
207
|
+
|
|
208
|
+
// Start server
|
|
209
|
+
server.listen({
|
|
210
|
+
port: 3698,
|
|
211
|
+
});
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
```typescript
|
|
215
|
+
// Client-side code
|
|
216
|
+
import { TypedRPCClient, TypedRPCAPIDefine } from 'typedrpc';
|
|
217
|
+
|
|
218
|
+
// Reuse API definition
|
|
219
|
+
const serverAPIDefine = new TypedRPCAPIDefine<{
|
|
220
|
+
math: MathServiceInterface,
|
|
221
|
+
}>();
|
|
222
|
+
|
|
223
|
+
// Create client
|
|
224
|
+
const client = new TypedRPCClient({
|
|
225
|
+
remote: serverAPIDefine,
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
// Connect and make RPC call
|
|
229
|
+
const connection = await client.connect("localhost:3698");
|
|
230
|
+
const api = client.getAPI(connection);
|
|
231
|
+
const result = await api.math.add.call(1, 2); // Returns 3
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
## More Usage
|
|
235
|
+
|
|
236
|
+
see `./test/*.ts` for more usage.
|
|
237
|
+
|
|
238
|
+
## Contributing
|
|
239
|
+
|
|
240
|
+
Contributions are welcome! Please feel free to submit a Pull Request.
|
|
241
|
+
|
|
242
|
+
## License
|
|
243
|
+
|
|
244
244
|
MIT License - see the [LICENSE](https://github.com/MingZeY/TypedRPC/blob/master/LICENSE) file for details.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"socketio.d.ts","sourceRoot":"","sources":["../../src/connections/socketio.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,YAAY,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAAE,0BAA0B,EAAE,MAAM,YAAY,CAAC;AAS5E,KAAK,+BAA+B,GAAG;IACnC,OAAO,EAAC,CAAC,IAAI,EAAC,MAAM,KAAK,IAAI,CAAC;CACjC,CAAA;AACD,cAAM,0BAA2B,SAAQ,kBAAkB;IAS3C,OAAO,CAAC,MAAM;IARnB,UAAU,gDAAuD;IAExE,OAAO,CAAC,SAAS,CAAK;IAEtB,OAAO,CAAC,QAAQ,CAED;gBAEK,MAAM,EAAC;QACvB,EAAE,EAAC,MAAM,CAAC;QACV,IAAI,EAAC,CAAC,IAAI,EAAC,MAAM,KAAK,IAAI,CAAC;QAC3B,KAAK,EAAC,MAAM,OAAO,CAAC;QACpB,QAAQ,EAAC,MAAM,OAAO,CAAC;KAC1B;IA6BK,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAiC9D,KAAK,IAAI,MAAM;IAGf,KAAK,IAAI,OAAO;IAIhB,QAAQ,IAAI,OAAO;CAItB;AAGD,KAAK,wCAAwC,GAAG;IAC5C,MAAM,CAAC,EAAC,OAAO,MAAM,EAAE,MAAM,CAAC;IAC9B,OAAO,CAAC,EAAC,OAAO,CAAC,OAAO,WAAW,EAAE,aAAa,CAAC,CAAA;CACtD,CAAA;AAED,cAAM,kC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AED,cAAM,kCAAmC,SAAQ,0BAA0B;IAEvE,OAAO,CAAC,EAAE,CAA0C;IACpD,OAAO,CAAC,MAAM,CAA0C;gBAE5C,MAAM,CAAC,EAAC,wCAAwC;IAKtD,MAAM,CAAC,MAAM,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;KAAE,GAAG,OAAO,CAAC,OAAO,CAAC;IAyDtE,KAAK,IAAI,OAAO,CAAC,OAAO,CAAC;IAkBzB,OAAO,CAAC,MAAM,EAAE,MAAM,EAAC,IAAI,CAAC,EAAC,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC;CAiC1E;AAED,OAAO,EACH,0BAA0B,EAC1B,kCAAkC,GACrC,CAAA"}
|
|
@@ -101,6 +101,7 @@ class TypedRPCConnectionProviderSocketIO extends TypedRPCConnectionProvider {
|
|
|
101
101
|
origin: "*",
|
|
102
102
|
methods: ["GET", "POST"],
|
|
103
103
|
},
|
|
104
|
+
...this.config.options,
|
|
104
105
|
});
|
|
105
106
|
io.on('connection', (socket) => {
|
|
106
107
|
const connection = new TypedRPCConnectionSocketIO({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"socketio.js","sourceRoot":"","sources":["../../src/connections/socketio.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAAE,0BAA0B,EAAE,MAAM,YAAY,CAAC;AAY5E,MAAM,0BAA2B,SAAQ,kBAAkB;IASnC;IARb,UAAU,GAAG,IAAI,YAAY,EAAmC,CAAC;IAEhE,SAAS,GAAG,CAAC,CAAC;IAEd,QAAQ,GAEX,IAAI,GAAG,EAAE,CAAC;IAEf,YAAoB,MAKnB;QACG,KAAK,EAAE,CAAC;QANQ,WAAM,GAAN,MAAM,CAKzB;QAGG,SAAS;QACT,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC,SAAS,E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AAC,SAAS,EAAC,IAAI,CAAC,CAAC;YAC/C,CAAC,CAAC,CAAA;YACF,MAAM,CAAC,EAAE,CAAC,OAAO,EAAC,GAAG,EAAE;gBACnB,UAAU,CAAC,KAAK,EAAE,CAAC;YACvB,CAAC,CAAC,CAAA;QACN,CAAC,CAAC,CAAA;IACN,CAAC;CAEJ;AAED,OAAO,EACH,0BAA0B,EAC1B,kCAAkC,GACrC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mingzey/typedrpc",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.6",
|
|
4
4
|
"description": "TypeScript-based RPC framework with support for multiple connection types including HTTP, Socket, and SocketIO or custom",
|
|
5
5
|
"author": "MingZeY <1552904342@qq.com>",
|
|
6
6
|
"repository": {
|