Novelty Plastic Moustache
Unleash awesomeness. Private packages, team management tools, and powerful integrations. Get started with npm Orgs »

grpc.server

3.0.2 • Public • Published

grpc.server

a simple abstraction around grpc.Server


Build StatusCoverage StatusISC LicenseNodeJS

JavaScript Style Guide

api

const server = require('grpc.server')

  • server(an optional {})
    • address string with the format url:port
    • credentials can use credentials.createInsecure or with certificates through an object { key, server }, passed as a Buffer
    • metadata set metadata that can be used in all calls, an array with { key: value }

methods

  • addServices(an array with the services object)
    • package proto package name
    • name service name
    • proto proto file
    • methods an object with the methods
  • start(callback function)
  • stop(callback function)

note: you can use unary, stream or bidirecional since the comm type should be handled on the proto files and in the methods

example

const server = require('grpc.server')
 
// proto file
/*
syntax = "proto3";
 
package helloWorld;
 
// The greeting service definition.
service Greeter {
  // Sends a greeting
  rpc sayHello (HelloRequest) returns (HelloReply) {}
}
 
// The request message containing the user's name.
message HelloRequest {
  string name = 1;
}
 
// The response message containing the greetings
message HelloReply {
  string message = 1;
}
*/
 
const serverA = server()
 
const services = [
  {
    proto: protos.helloWorld,
    package: 'helloWorld',
    name: 'Greeter',
    methods: { sayHello: sayHello }
  }
]
 
serverA.
  .addServices(services)
  .startc(cb)
 
 
// to stop the server
serverA.stop(cb)
 

ISC License (ISC)

install

npm i grpc.server

Downloadsweekly downloads

3

version

3.0.2

license

ISC

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability