# @ruiyun/fastify-grpc-client

> fastify grpc plugin

Latest version **0.2.6** (published 2020-06-10) · MIT license · 0 weekly downloads

## Install

```sh
npm install @ruiyun/fastify-grpc-client
pnpm add @ruiyun/fastify-grpc-client
yarn add @ruiyun/fastify-grpc-client
bun add @ruiyun/fastify-grpc-client
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.6 |
| Published | 2020-06-10 |
| First published | 2019-04-04 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 7 |
| Unpacked size | 5.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | wen911119@gmail.com |
| Maintainers | wen911119 |
| Keywords | fastify, grpc |

## Links

- npm: https://www.npmjs.com/package/@ruiyun/fastify-grpc-client
- npm.io page: https://npm.io/package/@ruiyun/fastify-grpc-client

## Dependencies (7)

- [dlv](https://npm.io/package/dlv.md) ^1.1.3
- [grpc](https://npm.io/package/grpc.md) ^1.24.3
- [globby](https://npm.io/package/globby.md) ^11.0.1
- [lodash](https://npm.io/package/lodash.md) ^4.17.15
- [fs-extra](https://npm.io/package/fs-extra.md) ^9.0.1
- [fastify-plugin](https://npm.io/package/fastify-plugin.md) ^1.6.1
- [@grpc/proto-loader](https://npm.io/package/@grpc/proto-loader.md) ^0.5.4

## Recent versions

- 0.2.6 (latest) — 2020-06-10
- 0.2.5 — 2020-03-19
- 0.2.4 — 2019-09-06
- 0.2.3 — 2019-09-06
- 0.2.2 — 2019-05-23
- 0.2.1 — 2019-05-23
- 0.2.0 — 2019-04-04

## README

> #### 在fastapi内使用
fastapi框架已经内置该插件，所以只要写好配置就可以了。
```javascript
// src/conifg/index.default.js
module.exports = {
  // ...
  grpc: {
    pbPathsRegExp:
      process.cwd() +
      "/node_modules/@quancheng/**/src/main/proto/**/*_service.proto", // pb文件位置
    pemPath: process.cwd() + "/grpc.pem", // grpc证书路径
    retry: 5, // 重试次数
    services: { // services包名映射
      UserService: "com.quancheng.zeus.service.UserService:zeus-service:1.0.0",
      CompanyService:
        "com.quancheng.zeus.service.CompanyService:zeus-service:1.0.0",
      AccountService:
        "com.quancheng.zeus.service.AccountService:zeus-service:1.0.0"
    },
    options: { // 其它grpc配置
      "grpc.ssl_target_name_override": "grpc",
      "grpc.default_authority": "grpc"
    }
  }
  // ...
}

```
之后就可以在api或者servcie内通过this.grpc.UserService取到的UserService实例。

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