From bee5042c4ffb1f4b42bafd5fc68259997a74fb72 Mon Sep 17 00:00:00 2001 From: mariari Date: Wed, 16 Oct 2024 16:32:12 +0800 Subject: [PATCH] Implement the connect function in TS We simply connect to the typescripted client a good example of the usage is like this > ind.connect('localhost', 50051) --- index.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/index.ts b/index.ts index e69de29..0fc4587 100644 --- a/index.ts +++ b/index.ts @@ -0,0 +1,12 @@ +import * as announce_pb from './proto/anoma_pb'; +import * as service from './proto/anoma_grpc_pb'; +import * as grpc from '@grpc/grpc-js'; + +export function connect(address: string, port: number, creds?: grpc.ChannelCredentials) + : service.IntentsClient { + if (typeof creds == 'undefined') { + creds = grpc.credentials.createInsecure(); + } + let target: string = address + ':' + port; + return new service.IntentsClient(target, creds) +}