use

uservices

Library to enable remoting of an object with asynchronous functions.

Showing:

Popularity

Downloads/wk

0

GitHub Stars

1

Maintenance

Last Commit

6yrs ago

Contributors

2

Package

Dependencies

1

License

MIT

Type Definitions

Built-In

Tree-Shakeable

No?

Categories

Readme

Remotable Micro (u)Services

Overview

A uService is just an object with asynchronous functions (returning either Promises or Observables). Functions returning Promises are referred to as methods, and functions returning Observables (which must currently be compatible with rxjs) are referred to as events.

This library defines a specification that allows easy creation of proxies of these uServices, e.g. for remote use.

This specification is just a JSON format, which can be either created directly, or generated from code analysis. The example provided below uses the typescript-schema library to analyse TypeScript code in order to output a corresponding specification.

Moreover, this specification format is extensible. For example, the markscript-uservices library extends this to allow uServices to be implemented in, or proxies deployed to, a MarkLogic server.

A javascript model of a spec can be found under the model module in this library, and allows for easy programmatic usage of a spec.

A number of libraries also provide abstractions over various transports to easily create remote proxies for uServices; some of these are listed at the end.

Usage

Install:

npm install uservices

Basic Usage:

An example specification: (All fields are optional)

{
  "myService": {
    "implementation": {
      "moduleName": "my/javascript/module",
      "className": "MyService"
    },
    "methods": {
      "someMethod": {
        "type": {}
      }
    },
    "events": {
      "someEvent": {}
    }
  }
}

To parse a JSON spec into a javascript model:

import * as u from 'uservices'

let someSpecJSON

let spec = u.parse(someSpecJSON)

To easily navigate a specification (javascript model):

import * as u from 'uservices'

let someSpec

u.visitServices(someSpec, {
  onService: function(serviceSpec){
    return {
      onMethod: function(methodSpec){
        let name = methodSpec.name
      },
      onEvent: function(eventSpec){
        let name = eventSpec.name
      }
    }
  }
})

To generate a spec from a typescript-schema model:

import * as u from 'uservices'
import * as s from 'typescript-schema'

let module:s.Map<s.Module>

let specs = u.generateServiceSpecs(modules)

Remote Proxy libraries

Various libraries exist for making the services deployable as remote proxies. Some of them are listed below:

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100
No reviews found
Be the first to rate

Alternatives

No alternatives found

Tutorials

No tutorials found
Add a tutorial