gluer
A wrapper for rust frameworks which addresses the persistent issue of redundant type and function definitions between the frontend and backend. At present, it exclusively supports the axum framework.
Installation
Add this to your Cargo.toml:
[]
= "0.1.0"
Disclaimer
Please be informed that this crate is in a very early state and is expected to work in not every case. Open a Issue if you encounter one! What works is:
- Defining the routing and api generation as outlined in How to use
- Inferring the input and output types of functions (but only
Json<...>for inputs) - Converting them to ts types
- Generating the ts file with the functions and data types
How to use
Firstly you have to use the add_route! macro when adding api important routes to your router:
use ;
use add_route;
async
let mut app: = new;
// Not api important, so adding without macro
app = app.route;
// You cannot use inline functions because of rust limitations of inferring types in macros
add_route!;
add_route!;
Then you only have to use the gen_spec! macro which generates after specifying the path the api on comptime:
use gen_spec;
gen_spec!;
Complete Example
use ;
use ;
async
async