2 Getting Started
Anton Nesterov edited this page 2026-02-21 15:30:07 +01:00

Installation

Linux

Download the standalone binary with embedded web UI:

#!/bin/bash

# Download latest VSKI standalone
wget https://git.vski.sh/x/platform/releases/download/latest/vski-standalone

# Make executable
chmod +x vski-standalone

# Move to local bin
sudo mv vski-standalone /usr/local/bin/vski

# Run VSKI
vski

Docker

Pull and run the official Docker image:

# Pull latest version
docker pull git.vski.sh/x/vski:latest-standalone

# Run with default configuration
docker run -p 3000:3000 -v $(pwd)/data:/app/data git.vski.sh/x/vski:latest-standalone

Initial Setup

After starting VSKI, navigate to:

http://localhost:3000/installer

This will guide you through creating your first admin user and initial setup.

SDK Usage

VSKI provides a powerful JavaScript/TypeScript SDK for interacting with your backend.

Installation

Install the VSKI SDK:

npm install @vski/sdk

Initialize Client

import { VskiClient } from "@vski/sdk";

// Initialize client
const client = new VskiClient("http://localhost:3000");

// Authenticate as admin
const authRes = await client.admins.authWithPassword(
  "admin@yourdomain.com",
  "your-password",
);
client.setToken(authRes.token);

Create a Collection

Collections are containers for your data. Define fields and types:

// Create a 'posts' collection
const postsCollection = await client.settings.collections.create({
  name: "posts",
  type: "base",
  fields: [
    { name: "title", type: "text", required: true },
    { name: "content", type: "text" },
    { name: "published", type: "bool" },
    { name: "views", type: "number" },
  ],
});

CRUD Operations

Create, read, update, and delete records:

// Create a record
const post = await client.collection("posts").create({
  title: "Hello VSKI",
  content: "This is my first post",
  published: true,
  views: 0,
});

// Get a single record
const fetchedPost = await client.collection("posts").getOne(post.id);

// Update a record
const updatedPost = await client.collection("posts").update(post.id, {
  title: "Updated Title",
  views: 10,
});

// List records
const list = await client.collection("posts").getList(1, 30);
console.log(`Total posts: ${list.totalItems}`);
list.items.forEach((item) => console.log(item.title));

// Delete a record
await client.collection("posts").delete(post.id);

Query Records

Filter and search your data:

// Find published posts
const publishedPosts = await client.collection("posts").getList(1, 20, {
  filter: "published = true",
});

// Search for specific content
const searchResults = await client.collection("posts").getList(1, 20, {
  filter: 'title ~ "Hello"',
});

// Sort and paginate
const sortedPosts = await client.collection("posts").getList(1, 50, {
  sort: "-created",
});

Workflows

Define and execute complex multi-step processes:

import { step, workflow } from "@vski/sdk/functional";
import { WorkflowWorker } from "@vski/sdk/worker";

// Define a workflow step
const greetUser = step("greet", async (name: string) => {
  return `Hello, ${name}!`;
});

// Create a workflow
const myWorkflow = workflow("welcome-user")
  .run(async (ctx, name: string) => {
    const greeting = await greetUser(name);
    return { message: greeting };
  });

// Start the worker
const worker = new WorkflowWorker(client);
await worker.start("welcome-user");

// Trigger the workflow
const run = await client.workflow.trigger("welcome-user", ["Alice"]);
console.log(`Workflow status: ${run.status}`);

// Wait for completion
const completedRun = await client.workflow.getRun(run.runId);
console.log(`Result: ${completedRun.output.message}`);

Real-time Subscriptions

Listen to real-time updates on your data:

// Subscribe to all changes in a collection
client.collection("posts").subscribe((event) => {
  console.log(`Event type: ${event.action}`);
  console.log(`Record: ${event.record}`);
});

// Subscribe with filter
client.collection("posts").subscribe((event) => {
  if (event.action === "create") {
    console.log("New post created:", event.record);
  }
}, {
  filter: "published = true",
});

Database Management

Manage multiple databases:

// List all databases
const databases = await client.settings.databases.list();

// Create a new database
const newDb = await client.settings.databases.create({
  name: "analytics",
});

// Delete a database
await client.settings.databases.delete("analytics");