A showcase for Next.js + Vovk.ts + Zod, demonstrating its capabilities with TypeScript, Rust, and Python RPC.
License: MIT
# Install the package
cargo install vovk_hello_world
POST https://vovk-hello-world.vercel.app/api/users/{id}
use vovk_hello_world::user_rpc;
use serde_json::{
from_value,
json
};
pub fn main() {
let response = user_rpc::update_user(
from_value(json!({
// User email
"email": "john@example.com",
// User profile object
"profile": {
// User full name
"name": "John Doe",
// User age
"age": 25
}
})).unwrap(), /* body */
from_value(json!({
// Notification type
"notify": "email"
})).unwrap(), /* query */
from_value(json!({
// User ID
"id": "123e4567-e89b-12d3-a456-426614174000"
})).unwrap(), /* params */
None, /* headers (HashMap) */
None, /* api_root */
false, /* disable_client_validation */
);
match response {
Ok(output) => println!("{:?}", output),
/*
output {
// Success status
success: true
}
*/
Err(e) => println!("error: {:?}", e),
}
}
GET https://vovk-hello-world.vercel.app/api/streams/tokens
use vovk_hello_world::stream_rpc;
use serde_json::{
from_value,
json
};
pub fn main() {
let response = stream_rpc::stream_tokens(
(), /* body */
(), /* query */
(), /* params */
None, /* headers (HashMap) */
None, /* api_root */
false, /* disable_client_validation */
);
match response {
Ok(stream) => {
for (i, item) in stream.enumerate() {
println!("#{}: {:?}", i, item);
/*
#0: iteration {
// Message from the token
message: "string"
}
*/
}
},
Err(e) => println!("Error initiating stream: {:?}", e),
}
}
GET https://vovk-hello-world.vercel.app/api/static/openapi/spec.json
use vovk_hello_world::open_api_rpc;
use serde_json::{
from_value,
json
};
pub fn main() {
let response = open_api_rpc::get_spec(
(), /* body */
(), /* query */
(), /* params */
None, /* headers (HashMap) */
None, /* api_root */
false, /* disable_client_validation */
);
}