Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/acryps/vlserver

VLServer Managed Server
https://github.com/acryps/vlserver

Last synced: 5 days ago
JSON representation

VLServer Managed Server

Awesome Lists containing this project

README

        

[![npm version](http://badge.acryps.com/npm/vlserver)](http://badge.acryps.com/go/npm/vlserver)
![vlquery](http://badge.acryps.com/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](https://npmjs.com/vlquery).

## Documentation
[Getting Started](doc/getting-started.md)

[Adapters](doc/adapters.md)

[Data Exchange](doc/exchange.md)

## Sponsoring and support
This project is sponsored and supported by [inter allied crypsis / ACRYPS](https://acryps.com) and [VLVT.IN GmbH](https://vlvt.in).

## Example
Declare view models on the server
```
export class AuthorViewModel extends ViewModel {
id;

firstname;
lastname;
}

export class BookViewModel extends ViewModel {
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, ... ]
});
```