@pyrpc/client 0.1.0-alpha.2 → 0.1.0-alpha.3
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 +9 -12
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -6,6 +6,10 @@ Universal TypeScript client for [pyRPC](https://pyrpc.dev). Type-safe RPC calls
|
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
8
|
npm install @pyrpc/client
|
|
9
|
+
# or
|
|
10
|
+
pnpm add @pyrpc/client
|
|
11
|
+
# or
|
|
12
|
+
bun add @pyrpc/client
|
|
9
13
|
```
|
|
10
14
|
|
|
11
15
|
The postinstall script in `@pyrpc/types` will prompt for your server URL and generate typed contracts automatically.
|
|
@@ -32,17 +36,6 @@ console.log(user.name);
|
|
|
32
36
|
|
|
33
37
|
The proxy-based API lets you call any remote procedure as a local method. Parameters are passed positionally or as a single object for named arguments.
|
|
34
38
|
|
|
35
|
-
### Dynamic headers (auth)
|
|
36
|
-
|
|
37
|
-
```typescript
|
|
38
|
-
const client = createClient({
|
|
39
|
-
baseUrl: "https://api.example.com",
|
|
40
|
-
headers: () => ({
|
|
41
|
-
Authorization: `Bearer ${localStorage.getItem("token")}`,
|
|
42
|
-
}),
|
|
43
|
-
});
|
|
44
|
-
```
|
|
45
|
-
|
|
46
39
|
### Error handling
|
|
47
40
|
|
|
48
41
|
```typescript
|
|
@@ -64,7 +57,11 @@ try {
|
|
|
64
57
|
Creates a proxy client that forwards method calls to the server.
|
|
65
58
|
|
|
66
59
|
- `baseUrl` — Server root URL (defaults to `window.location.origin` in browsers)
|
|
67
|
-
- `headers` — Static
|
|
60
|
+
- `headers` — Static or async `HeadersInit`
|
|
61
|
+
|
|
62
|
+
## Keywords
|
|
63
|
+
|
|
64
|
+
rpc, pyrpc, typescript, client, type-safe, api, remote-procedure-call
|
|
68
65
|
|
|
69
66
|
## License
|
|
70
67
|
|