Skip to content

Commit

Permalink
docs(api): Add api-common info on generating TypeScript bindings (#3330)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kissaki authored Jun 28, 2023
1 parent bef7663 commit 0f91759
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions crates/api_common/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,10 @@ As you can see, each API endpoint needs a parameter type ( GetPosts), path (/pos
For a real example of a Lemmy API client, look at [lemmyBB](https://github.com/LemmyNet/lemmyBB/tree/main/src/api).

Lemmy also provides a websocket API. You can find the full websocket code in [this file](https://github.com/LemmyNet/lemmy/blob/main/src/api_routes_websocket.rs).

## Generate TypeScript bindings

TypeScript bindings (API types) can be generated by running `cargo test --features full`.
The ts files be generated into a `bindings` folder.

This crate uses [`ts_rs`](https://docs.rs/ts-rs/6.2.1/ts_rs/#traits) macros `derive(TS)` and `ts(export)` to attribute types for binding generating.

0 comments on commit 0f91759

Please sign in to comment.