vlserver automates api interfaces by automatically binding Services and ViewModels from the server to one or multiple clients.
This package requires vlquery.
Getting Started
Adapters
Data Exchange
This project is sponsored and supported by inter allied crypsis / ACRYPS and VLVT.IN GmbH.
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, ... ]
});