vovk-examples
v3.0.17
Published
Vovk examples
Downloads
372
Readme
vovk-examples v3.0.17

Vovk examples
License: MIT
# Install the package
npm install vovk-examplesUserZodRPC
UserZodRPC.updateUser
Update user (Zod)
Update user by ID with Zod validation
POST https://examples.vovk.dev/api/users-zod/{id}
import { UserZodRPC } from 'vovk-examples';
const response = await UserZodRPC.updateUser({
body: {
// -----
// User object
// -----
// User full name
name: 'string',
// User age
age: 0,
// User email
email: '[email protected]',
},
query: {
// Notification type
notify: 'email',
},
params: {
// User ID
id: '00000000-0000-0000-0000-000000000000',
},
});
console.log(response);
/*
{
// -----
// Response object
// -----
// Success status
success: true
}
*/UserZodWithServiceRPC
UserZodWithServiceRPC.updateUser
Update user (Zod with service)
Update user by ID with Zod validation
POST https://examples.vovk.dev/api/users-zod-with-service/{id}
import { UserZodWithServiceRPC } from 'vovk-examples';
const response = await UserZodWithServiceRPC.updateUser({
body: {
// -----
// User object
// -----
// User full name
name: 'string',
// User age
age: 0,
// User email
email: '[email protected]',
},
query: {
// Notification type
notify: 'email',
},
params: {
// User ID
id: '00000000-0000-0000-0000-000000000000',
},
});
console.log(response);
/*
{
// -----
// Response object
// -----
// Success status
success: true,
// User ID
id: "00000000-0000-0000-0000-000000000000"
}
*/UserYupRPC
UserYupRPC.updateUser
Update user (Yup)
Update user by ID with Yup validation
POST https://examples.vovk.dev/api/users-yup/{id}
import { UserYupRPC } from 'vovk-examples';
const response = await UserYupRPC.updateUser({
body: {
// -----
// User object
// -----
// User full name
name: 'string',
// User age
age: 0,
// User email
email: '[email protected]',
},
query: {
// Notification type
notify: 'email',
},
params: {
// User ID
id: 'string',
},
});
console.log(response);
/*
{
// -----
// Response object
// -----
// Success status
success: true
}
*/UserDtoRPC
UserDtoRPC.updateUser
Update user (DTO)
Update user by ID with DTO validation
POST https://examples.vovk.dev/api/users-dto/{id}
import { UserDtoRPC } from 'vovk-examples';
const response = await UserDtoRPC.updateUser({
body: {
// -----
// User object
// -----
// User full name
name: 'string',
// User age
age: 0,
// User email
email: '[email protected]',
},
query: {
// -----
// Query parameters
// -----
// Notification type
notify: 'email',
},
params: {
// -----
// Path parameters
// -----
// User ID
id: '00000000-0000-0000-0000-000000000000',
},
});
console.log(response);
/*
{
// -----
// Response object
// -----
// Success status
success: true
}
*/UserArktypeRPC
UserArktypeRPC.updateUser
Update user (Arktype)
Update user by ID with Arktype validation
POST https://examples.vovk.dev/api/users-arktype/{id}
import { UserArktypeRPC } from 'vovk-examples';
const response = await UserArktypeRPC.updateUser({
body: {
// User age
age: 0,
// User email
email: '[email protected]',
// User full name
name: 'string',
},
query: {
// Notification type
notify: 'email',
},
params: {
// User ID
id: '00000000-0000-0000-0000-000000000000',
},
});
console.log(response);
/*
{
// Success status
success: true
}
*/UserValibotRPC
UserValibotRPC.updateUser
Update user (Valibot)
Update user by ID with Valibot validation
POST https://examples.vovk.dev/api/users-valibot/{id}
import { UserValibotRPC } from 'vovk-examples';
const response = await UserValibotRPC.updateUser({
body: {
// -----
// User object
// -----
// User full name
name: 'string',
// User age
age: 0,
// User email
email: '[email protected]',
},
query: {
// Notification type
notify: 'email',
},
params: {
// User ID
id: '00000000-0000-0000-0000-000000000000',
},
});
console.log(response);
/*
{
// -----
// Response object
// -----
// Success status
success: true
}
*/BasicRPC
BasicRPC.getHello
Get a greeting
Get a greeting from the server
GET https://examples.vovk.dev/api/basic/greeting
import { BasicRPC } from 'vovk-examples';
const response = await BasicRPC.getHello();BasicRPC.postHello
Post a greeting
Post a greeting to the server
POST https://examples.vovk.dev/api/basic/greeting
import { BasicRPC } from 'vovk-examples';
const response = await BasicRPC.postHello();BasicRPCWithService
BasicRPCWithService.getHello
Get a greeting using a service
Get a greeting from the server using a service
GET https://examples.vovk.dev/api/basic-with-service/greeting
import { BasicRPCWithService } from 'vovk-examples';
const response = await BasicRPCWithService.getHello();JSONLinesRPC
JSONLinesRPC.streamTokens
Stream tokens
Stream tokens to the client
GET https://examples.vovk.dev/api/jsonlines/tokens
import { JSONLinesRPC } from 'vovk-examples';
const response = await JSONLinesRPC.streamTokens();JSONLinesResponseRPC
JSONLinesResponseRPC.streamTokens
Stream tokens using Response object
Stream tokens to the client using Response object
GET https://examples.vovk.dev/api/jsonlines-response-object/tokens
import { JSONLinesResponseRPC } from 'vovk-examples';
const response = await JSONLinesResponseRPC.streamTokens();OpenAiRPC
OpenAiRPC.createChatCompletion
Create a chat completion
Create a chat completion using OpenAI and yield the response
POST https://examples.vovk.dev/api/openai/chat
import { OpenAiRPC } from 'vovk-examples';
const response = await OpenAiRPC.createChatCompletion();AiSdkRPC
AiSdkRPC.chat
Vercel AI SDK
Uses @ai-sdk/openai and ai packages to chat with an AI model
POST https://examples.vovk.dev/api/ai-sdk/chat
import { AiSdkRPC } from 'vovk-examples';
const response = await AiSdkRPC.chat();ProxyRPC
ProxyRPC.getHello
Proxy endpoint
Get a greeting from vovk.dev
GET https://examples.vovk.dev/api/proxy/greeting
import { ProxyRPC } from 'vovk-examples';
const response = await ProxyRPC.getHello();PollRPC
PollRPC.streamPollResponse
GET https://examples.vovk.dev/api/polling
import { PollRPC } from 'vovk-examples';
using response = await PollRPC.streamPollResponse({
query: {
i: 'string',
},
});
for await (const item of response) {
console.log(item);
/*
{
i: 0
}
*/
}ProgressiveRPC
ProgressiveRPC.streamProgressiveResponse
GET https://examples.vovk.dev/api/progressive
import { ProgressiveRPC } from 'vovk-examples';
using response = await ProgressiveRPC.streamProgressiveResponse();
for await (const item of response) {
console.log(item);
/*
{
users: [
{
id: 0,
name: "string"
}
]
}
*/
}FormZodRPC
FormZodRPC.submitForm
Submit form (Zod)
Submit form with Zod validation
POST https://examples.vovk.dev/api/form-zod/{id}
import { FormZodRPC } from 'vovk-examples';
const formData = new FormData();
// User email
formData.append('email', '[email protected]');
// Resume file
formData.append('resume', new Blob([binary_data]));
// Portfolio samples
formData.append('portfolioSamples', new Blob([binary_data]));
// Portfolio samples
formData.append('portfolioSamples', new Blob([binary_data]));
const response = await FormZodRPC.submitForm({
body: formData,
params: {
// User ID
id: '00000000-0000-0000-0000-000000000000',
},
});
console.log(response);
/*
{
// -----
// Response object
// -----
// User email
email: "[email protected]",
resume: {
// Resume file name
name: "resume.pdf",
// Resume file size
size: 0,
// Resume file type
type: "application/pdf"
},
// Array of portfolio sample files
portfolioSamples: [
{
// Portfolio sample file name
name: "portfolio.zip",
// Portfolio sample file size
size: 0,
// Portfolio sample file type
type: "application/zip"
}
]
}
*/OpenApiRPC
OpenApiRPC.getSpec
OpenAPI spec
Get the OpenAPI spec for the examples API
GET https://examples.vovk.dev/api/static/openapi.json
import { OpenApiRPC } from 'vovk-examples';
const response = await OpenApiRPC.getSpec();StaticParamsRPC
StaticParamsRPC.getStaticParams
Static Params
Get the static params: section and page
GET https://examples.vovk.dev/api/static/static-params/{section}/page{page}.json
import { StaticParamsRPC } from 'vovk-examples';
const response = await StaticParamsRPC.getStaticParams({
params: {
section: 'a',
page: '1',
},
});