vovk-hello-world

vovk-hello-world v0.0.45 TypeScript Vovk.ts

A showcase for Next.js + Vovk.ts + Zod, demonstrating its capabilities with TypeScript, Rust, and Python RPC.

License: MIT

# Install the package
npm install vovk-hello-world

UserRPC

UserRPC.updateUser

POST http://localhost:3000/api/users/{id}

import { UserRPC } from 'vovk-hello-world';

const response = await UserRPC.updateUser({
    body: {
        // User email
        email: "john@example.com",
        // User profile object
        profile: {
            // User full name
            name: "John Doe",
            // User age
            age: 25
        }
    },
    query: {
        // Notification type
        notify: "email"
    },
    params: {
        // User ID
        id: "123e4567-e89b-12d3-a456-426614174000"
    },
});

console.log(response); 
/* 
{
    // -----
    // Response object
    // -----
    // Success status
    success: true
}
*/

StreamRPC

StreamRPC.streamTokens

GET http://localhost:3000/api/streams/tokens

import { StreamRPC } from 'vovk-hello-world';

using response = await StreamRPC.streamTokens();

for await (const item of response) {
    console.log(item); 
    /*
    {
        // Message from the token
        message: "string"
    }
    */
}

OpenApiRPC

OpenApiRPC.getSpec

GET http://localhost:3000/api/static/openapi/spec.json

import { OpenApiRPC } from 'vovk-hello-world';

const response = await OpenApiRPC.getSpec();