# @rough/rx-grpc

> The simplest RxJS wrapper around grpc lib

Latest version **2.1.1** (published 2022-06-04) · MIT license · 0 weekly downloads

## Install

```sh
npm install @rough/rx-grpc
pnpm add @rough/rx-grpc
yarn add @rough/rx-grpc
bun add @rough/rx-grpc
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.1.1 |
| Published | 2022-06-04 |
| First published | 2019-02-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 9.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Igor Ostapenko |
| Maintainers | ihoro |
| Keywords | rpc, grpc, microservice, framework, service, soa, protobuf, proto, http2, binary, reactive, rx, rxjs, observable |

## Links

- npm: https://www.npmjs.com/package/@rough/rx-grpc
- Repository: https://github.com/ihoro/rough-rx-grpc
- Homepage: https://github.com/ihoro/rough-rx-grpc#readme
- Issues: https://github.com/ihoro/rough-rx-grpc/issues
- npm.io page: https://npm.io/package/@rough/rx-grpc

## Dependencies (4)

- [glob](https://npm.io/package/glob.md) ^7.2.0
- [rxjs](https://npm.io/package/rxjs.md) ^6.4.0
- [@grpc/grpc-js](https://npm.io/package/@grpc/grpc-js.md) ^1.4.1
- [@grpc/proto-loader](https://npm.io/package/@grpc/proto-loader.md) ^0.4.0

## Alternatives

- [@sveltejs/kit](https://npm.io/package/@sveltejs/kit.md) — 2.2M weekly downloads
- [@atlaskit/theme](https://npm.io/package/@atlaskit/theme.md) — 402.0K weekly downloads
- [@tangle-network/brand](https://npm.io/package/@tangle-network/brand.md) — 10.0K weekly downloads
- [seneca](https://npm.io/package/seneca.md) — 7.4K weekly downloads
- [@bsb/base](https://npm.io/package/@bsb/base.md) — 7.2K weekly downloads

## Recent versions

- 2.1.1 (latest) — 2022-06-04
- 2.1.0 — 2021-10-25
- 2.0.0 — 2021-01-22
- 1.7.0 — 2019-07-22
- 1.6.0 — 2019-07-01
- 1.5.0 — 2019-02-26
- 1.4.3 — 2019-02-14
- 1.4.2 — 2019-02-13
- 1.4.1 — 2019-02-12
- 1.4.0 — 2019-02-12
- 1.3.1 — 2019-02-09
- 1.3.0 — 2019-02-09
- 1.2.0 — 2019-02-06
- 1.1.0 — 2019-02-06
- 1.0.0 — 2019-02-06

## README

# The simplest RxJS wrapper around grpc lib

[![Build Status](https://travis-ci.com/ihoro/rough-rx-grpc.svg?branch=master)](https://travis-ci.com/ihoro/rough-rx-grpc)
[![npm version](https://badge.fury.io/js/%40rough%2Frx-grpc.svg)](https://badge.fury.io/js/%40rough%2Frx-grpc)

Rough implementation of [rxified](https://npmjs.com/rxjs) wrapper and tools for [grpc-js](https://www.npmjs.com/package/@grpc/grpc-js) lib.

## Usage example

```proto
// GreetingService.proto

syntax = "proto3";

package org.example;

service GreetingService {
  rpc Greet(Request) returns (Response);
}

message Request {
  string name = 1;
}

message Response {
  string message = 1;
}
```

```js
// server.js

class GreetingService {
  Greet(call, callback) {
    const name = call.request.name;
    if (name)
      callback(null, { message: `Hello, ${name}!` });
    else
      callback(new Error('Name is not defined.'));
  }
}

const RxGrpc = require('@rough/rx-grpc');
new RxGrpc()
  .withProtoFiles(__dirname + '/*.proto')
  .serve('org.example.GreetingService', new GreetingService())
  .startServer()
  .subscribe(
    started => console.log('Listening at grpc://0.0.0.0:50051 ...'),
    err => console.log(err),
    complete => {}
  );
```

```js
// client.js

const { flatMap } = require('rxjs/operators');
const RxGrpc = require('@rough/rx-grpc');

const rxgrpc = new RxGrpc().withProtoFiles(__dirname + '/*.proto');

const name = (process.argv.length > 2) ? process.argv[2] : null;

rxgrpc.service('org.example.GreetingService', 'localhost:50051').pipe(
  flatMap(GreetingService => GreetingService.Greet({ name }))
)
.subscribe(
  response => console.log(response.message),
  err => console.log(err),
  complete => {}
);
```

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