vlserver

VLServer Managed Server

Usage no npm install needed!

<script type="module">
  import vlserver from 'https://cdn.skypack.dev/vlserver';
</script>

README

npm version vlquery

vlserver API Binder

vlserver automates api interfaces by automatically binding Services and ViewModels from the server to one or multiple clients.

This package requires vlquery.

Documentation

Getting Started
Adapters
Data Exchange

Sponsoring and support

This project is sponsored and supported by inter allied crypsis / ACRYPS and VLVT.IN GmbH.

Example

Declare view models on the server

export class AuthorViewModel extends ViewModel<Person> {
    id;

    firstname;
    lastname;
}

export class BookViewModel extends ViewModel<Book> {
    id;

    name;
    author: AuthorViewModel;
}

Create a service on the server

export class BookService extends Service {
    constructor(
        private db: DbContext
    ) {
        super();
    }

    getBooks() {
        return BookViewModel.from(this.db.book);
    }
}

You can use the service in your client (after generating the bindings with vlserver compile)

const service = new BookService();
service.getBooks().then(books => {
    console.log(books); // [ BookViewModel, BookViewModel, ... ]
});