2022-01-01 01:08:05 +00:00
# JSON-RPC 2.0 Code-Gen
Type/Service definition language and code generator for json-rpc 2.0. Currently generating code for NodeJS, Deno and the Web. Other targets are possible, but not implemented yet.
| Name | Description |
| ------- | --------------------------------- |
| ts-node | Typescript for NodeJS |
| ts-esm | Typescript in ESM format for Deno |
2023-01-02 15:34:13 +00:00
| rust | Rust |
| dart | Dart |
| c# | C# |
2022-01-01 01:08:05 +00:00
## Usage
Create a definition file like `test.jrpc` :
```jrpc
enum TestEnum {
VAL1,
VAL2,
VAL10 = 10,
VAL11,
VAL12
}
type Test {
testen: TestEnum;
someString: string;
2023-01-02 15:34:13 +00:00
someNumber?: number;
2022-01-01 01:08:05 +00:00
array: string[];
map: {number, TestEnum};
}
service TestService {
2022-01-03 21:08:25 +00:00
@Description ("This Function adds two number")
@Param ("v1", "The first Number")
@Param ("v2", "The second Number")
@Returns ("The added values of the two numbers")
2022-01-01 01:08:05 +00:00
AddNumbers(v1: number, v2: number): number;
notification SendTest(test: Test);
}
```
Then run the generator like this `jrpc compile test.jrpc -o=ts-node:output/` .
This will generate the Client and Server code in the specified folder.
2023-01-02 15:34:13 +00:00
## TODOS
1. Documentation
2. Null Checks/Enforcements in all languages
3. More and better tests