# service-commons

> TypeScript pattern implemenation for service clients

Latest version **1.0.12** (published 2021-11-04) · MIT license · 0 weekly downloads

## Install

```sh
npm install service-commons
pnpm add service-commons
yarn add service-commons
bun add service-commons
```

## Health

**Score 35/100 (D)** — status: abandoned.

Positive: no vulnerabilities; high maintenance score; popular repo.

Warnings: low downloads; no types; no esm support.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 1.0.12 |
| Published | 2021-11-04 |
| First published | 2021-10-26 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 206.4 KB |
| Known vulnerabilities | 0 (+23 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 10130 |
| Author | OpenStandards.net |
| Maintainers | openstandards |
| Keywords | TypeScript, service, http, client |

## Links

- npm: https://www.npmjs.com/package/service-commons
- Repository: https://github.com/npm/cli
- Homepage: https://github.com/npm/cli#readme
- Issues: https://github.com/npm/cli/issues
- npm.io page: https://npm.io/package/service-commons

## Dependencies (4)

- [ws](https://npm.io/package/ws.md) ^8.2.3
- [rxjs](https://npm.io/package/rxjs.md) ^7.4.0
- [axios](https://npm.io/package/axios.md) ^0.24.0
- [@types/ws](https://npm.io/package/@types/ws.md) ^8.2.0

## Alternatives

- [launchdarkly-js-client-sdk](https://npm.io/package/launchdarkly-js-client-sdk.md) — 2.5M weekly downloads
- [@elastic/elasticsearch](https://npm.io/package/@elastic/elasticsearch.md) — 2.1M weekly downloads
- [@c8y/client](https://npm.io/package/@c8y/client.md) — 15.3K weekly downloads
- [@signaldb/maverickjs](https://npm.io/package/@signaldb/maverickjs.md) — 1.7K weekly downloads
- [@bbc/http-transport-cache](https://npm.io/package/@bbc/http-transport-cache.md) — 1.2K weekly downloads

## Recent versions

- 1.0.12 (latest) — 2021-11-04
- 1.0.11 — 2021-11-03
- 1.0.10 — 2021-11-03
- 1.0.9 — 2021-11-03
- 1.0.8 — 2021-11-02
- 1.0.7 — 2021-11-02
- 1.0.6 — 2021-11-02
- 1.0.5 — 2021-10-31
- 1.0.4 — 2021-10-28
- 1.0.3 — 2021-10-27
- 1.0.2 — 2021-10-26
- 1.0.1 — 2021-10-26
- 1.0.0 — 2021-10-26

## README

# Service Commons

Provides common building blocks for creating service infrastructure, including in servers and client APIs. 

This contains 

Injection: the implementation of Injection from the @angular/core project to help with service extensibility patterns. 
WebSockets: WebSocketClientService wraps a WebSocket with an rxjs Observer.

## WebSocketClientService

    const wsService = new WebSocketClientService(WebSocketEnvironment.Node);
    const handleMessage = (data) => {
      console.debug("data: " + data);
    };
    const subMessages = <Subject<MessageEvent>>wsService
      .create(URL)
      .pipe(
        map((response: MessageEvent): any => {
          // We have to parse because message data is always text
          const data = JSON.parse(response.data);
          handleMessage(data);
          return data;
        }));

## Notes

https://www.npmjs.com/package/ws

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