Skip to content

How to implement the server #1

Closed
@artemyarulin

Description

@artemyarulin

Thank you very much for your example, but I'm not sure how to implement the actual logic and a server?

I guess it should look something like that, but I struggle how to actually implement the interface?

// src/index.ts
import * as grpc from '@grpc/grpc-js'
import * as services from './proto/echo_service_grpc_pb'

class EchoService implements services.IEchoServiceService {
    // ?
}

var server = new grpc.Server();
server.addService(services.EchoServiceService, new EchoService());
server.bindAsync("127.0.0.1:50051", grpc.ServerCredentials.createInsecure(), (err, port) => {
    if (!err) server.start();
});

Or is there is something missing? For example in https://github.com/agreatfool/grpc_tools_node_protoc_ts/blob/b7b5e97349d3f9463214f4cc65e2ec2c9e44320a/examples/src/grpcjs/proto/book_grpc_pb.d.ts#L57-L62 there is also additional interface IBookServiceServer defined which I guess should be used as implementation interface for servers but here it's missing?

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions