New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

uservices

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

uservices

Library to enable remoting of an object with asynchronous functions.

latest
Source
npmnpm
Version
0.6.5
Version published
Weekly downloads
19
90%
Maintainers
1
Weekly downloads
 
Created
Source

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:

Keywords

service

FAQs

Package last updated on 27 Oct 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts