MCPcopy
hub / github.com/nestjs/nest / createServiceMethod

Method createServiceMethod

packages/microservices/server/server-grpc.ts:269–295  ·  view source on GitHub ↗

* Will return async function which will handle gRPC call * with Rx streams or as a direct call passthrough * * @param methodHandler * @param protoNativeHandler * @param streamType

(
    methodHandler: Function,
    protoNativeHandler: any,
    streamType: GrpcMethodStreamingType,
  )

Source from the content-addressed store, hash-verified

267 * @param streamType
268 */
269 public createServiceMethod(
270 methodHandler: Function,
271 protoNativeHandler: any,
272 streamType: GrpcMethodStreamingType,
273 ): Function {
274 // If proto handler has request stream as "true" then we expect it to have
275 // streaming from the side of requester
276 if (protoNativeHandler.requestStream) {
277 // If any handlers were defined with GrpcStreamMethod annotation use RX
278 if (streamType === GrpcMethodStreamingType.RX_STREAMING) {
279 return this.createRequestStreamMethod(
280 methodHandler,
281 protoNativeHandler.responseStream,
282 );
283 }
284 // If any handlers were defined with GrpcStreamCall annotation
285 else if (streamType === GrpcMethodStreamingType.PT_STREAMING) {
286 return this.createStreamCallMethod(
287 methodHandler,
288 protoNativeHandler.responseStream,
289 );
290 }
291 }
292 return protoNativeHandler.responseStream
293 ? this.createStreamServiceMethod(methodHandler)
294 : this.createUnaryServiceMethod(methodHandler);
295 }
296
297 public createUnaryServiceMethod(methodHandler: Function): Function {
298 return async (call: GrpcCall, callback: Function) => {

Callers 3

createServiceMethod · 0.95

Tested by

no test coverage detected