@msaki/jsonrpc 0.0.1 → 0.0.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 CHANGED
@@ -2,7 +2,9 @@
2
2
 
3
3
  ## Usage
4
4
 
5
- ```sh
5
+ ### RPC Server
6
+
7
+ ```ts
6
8
  import { JsonRpcServer } from "@msaki/jsonrpc";
7
9
 
8
10
  const server = new JsonRpcServer()
@@ -27,3 +29,25 @@ Bun.serve({
27
29
 
28
30
  console.log("JSON-RPC sever on http://localhost:4444")
29
31
  ```
32
+
33
+ ### PRC Client
34
+
35
+ ```ts
36
+ import { JsonRpcClient } from "@msaki/jsonrpc";
37
+ import type {
38
+ JsonRpcRequest,
39
+ JsonRpcResponse
40
+ } from "@msaki/jsonrpc";
41
+
42
+ const url = "http://localhost:4444";
43
+
44
+ const client = new JsonRpcClient(async (req: JsonRpcRequest) => {
45
+ const res = await fetch(url, {
46
+ method: "POST",
47
+ headers: { "Content-Type": "application/json" },
48
+ body: JSON.stringify(req)
49
+ });
50
+
51
+ return (await res.json()) as JsonRpcResponse
52
+ });
53
+ ```
package/package.json CHANGED
@@ -1,18 +1,26 @@
1
1
  {
2
2
  "name": "@msaki/jsonrpc",
3
3
  "author": "Meek Msaki",
4
- "version": "0.0.1",
4
+ "version": "0.0.3",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.mjs",
8
8
  "types": "dist/index.d.ts",
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/mmsaki/libs.git",
12
+ "directory": "packages/jsonrpc"
13
+ },
14
+ "publishConfig": {
15
+ "access": "public",
16
+ "directory": "dist"
17
+ },
9
18
  "scripts": {
10
19
  "build": "tsup index.ts --format cjs,esm --dts",
11
- "publish": "bun run build && changeset publish",
20
+ "publish": "bun run build && npm publish --access public",
12
21
  "lint": "tsc"
13
22
  },
14
23
  "devDependencies": {
15
- "@changesets/cli": "^2.29.8",
16
24
  "@types/bun": "latest",
17
25
  "tsup": "^8.5.1"
18
26
  },
@@ -1,8 +0,0 @@
1
- # Changesets
2
-
3
- Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works
4
- with multi-package repos, or single-package repos to help you version and publish your code. You can
5
- find the full documentation for it [in our repository](https://github.com/changesets/changesets)
6
-
7
- We have a quick list of common questions to get you started engaging with this project in
8
- [our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md)
@@ -1,11 +0,0 @@
1
- {
2
- "$schema": "https://unpkg.com/@changesets/config@3.1.2/schema.json",
3
- "changelog": "@changesets/cli/changelog",
4
- "commit": false,
5
- "fixed": [],
6
- "linked": [],
7
- "access": "public",
8
- "baseBranch": "main",
9
- "updateInternalDependencies": "patch",
10
- "ignore": []
11
- }
@@ -1,5 +0,0 @@
1
- ---
2
- "@msaki/jsonrpc": patch
3
- ---
4
-
5
- add changeset and build process