# uservices

> Library to enable remoting of an object with asynchronous functions.

Latest version **0.6.5** (published 2015-10-27) · MIT license · 0 weekly downloads

## Install

```sh
npm install uservices
pnpm add uservices
yarn add uservices
bun add uservices
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.6.5 |
| Published | 2015-10-27 |
| First published | 2015-06-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Christy Haragan |
| Maintainers | christyharagan |
| Keywords | service, portable, asynchronous, observable, actor, micro |

## Links

- npm: https://www.npmjs.com/package/uservices
- Repository: https://github.com/christyharagan/uservices
- Homepage: https://github.com/christyharagan/uservices#readme
- Issues: https://github.com/christyharagan/uservices/issues
- npm.io page: https://npm.io/package/uservices

## Dependencies (1)

- [typescript-schema](https://npm.io/package/typescript-schema.md) ^0.7.6

## Alternatives

- [promise-throttle](https://npm.io/package/promise-throttle.md) — 44.2K weekly downloads
- [@commercetools/sync-actions](https://npm.io/package/@commercetools/sync-actions.md) — 25.1K weekly downloads
- [cwait](https://npm.io/package/cwait.md) — 21.4K weekly downloads
- [@ledgerhq/hw-app-cosmos](https://npm.io/package/@ledgerhq/hw-app-cosmos.md) — 4.2K weekly downloads
- [@financial-times/o-loading](https://npm.io/package/@financial-times/o-loading.md) — 2.8K weekly downloads

## Recent versions

- 0.6.5 (latest) — 2015-10-27
- 0.6.4 — 2015-10-20
- 0.6.3 — 2015-10-10
- 0.6.2 — 2015-10-08
- 0.6.1 — 2015-09-25
- 0.6.0 — 2015-09-23
- 0.5.0 — 2015-09-18
- 0.4.0 — 2015-09-06
- 0.3.0 — 2015-07-08
- 0.2.0 — 2015-06-22
- 0.1.3 — 2015-06-17
- 0.1.2 — 2015-06-17
- 0.1.1 — 2015-06-17
- 0.1.0 — 2015-06-17

## 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](https://github.com/Reactive-Extensions/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](https://github.com/christyharagan/ts-schema) library to analyse TypeScript code in order to output a corresponding specification.

Moreover, this specification format is extensible. For example, the [markscript-uservices](https://github.com/christyharagan/markscript-uservices) library extends this to allow uServices to be implemented in, or proxies deployed to, a [MarkLogic](www.marklogic.com) 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:
```TypeScript
import * as u from 'uservices'

let someSpecJSON

let spec = u.parse(someSpecJSON)
```

To easily navigate a specification (javascript model):
```TypeScript
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:

```TypeScript
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:

 - [Socket.io on the server](www.github.com/christyharagan/uservice-socket.io-server)
 - [Socket.io on the client](www.github.com/christyharagan/uservice-socket.io-client)
 - [Marklogic database](www.github.com/christyharagan/markscript-uservices)

---
_Source: https://npm.io/package/uservices · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
