vlserver
v4.9.2
Published
VLServer Managed Server
Downloads
79
Maintainers
Readme
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, ... ]
});