Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@nersent/grpc-nest

Package Overview
Dependencies
Maintainers
2
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nersent/grpc-nest

Type-safe thin wraper around [grpc-js](https://github.com/grpc/grpc-node) for [Nest.js](https://github.com/nestjs/nest) with support for promises.

  • 1.0.0-dev.5
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
increased by100%
Maintainers
2
Weekly downloads
 
Created
Source

☁️ grpc-nest

Type-safe thin wraper around grpc-js for Nest.js with support for promises.

Note: This library is in an early development stage. Expect breaking changes.

Installation

yarn add @nersent/grpc-nest

Example

Quick Start

1. Compile proto

yarn grpc-nest ./example/*.proto ./example/generated

2.

index.ts

import { createGrpcTransport } from '@nersent/grpc-nest'; 

const app = await NestFactory.create(AppModule);

app.connectMicroservice<MicroserviceOptions>(
  createGrpcTransport({ address: "0.0.0.0:4269" }, app),
);

await app.startAllMicroservices();

app_module.ts

import { GrpcModule } from '@nersent/grpc-nest';

@Module({
  imports: [GrpcModule],
  controllers: [ApiController]
})
export class AppModule {}

api_controller.ts

import {
  IExampleApiService,
  ExampleApiService,
} from "./generated/example_grpc_pb";
import {
  ExampleApiStatusRequest,
  ExampleApiStatusResponse,
} from "./generated/example_pb";

@GrpcController(ExampleApiService)
export class ApiController implements IGrpcController<IExampleApiService> {
  public async status(
    req: ExampleApiStatusRequest,
  ): Promise<ExampleApiStatusResponse> {
    const name = req.getName();
    const res = new ExampleApiStatusResponse();
    res.setMessage(name);
    return res;
  }
}

Made by Nersent

FAQs

Package last updated on 20 Jul 2023

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc