22
33[ ![ NPM version] ( https://img.shields.io/npm/v/@stackb/bzl-sdk-node.svg )] ( https://www.npmjs.com/package/@stackb/bzl-sdk-node )
44
5- This repository contains the generated protobuf definitions for the
5+ This repository contains the generated protobuf/grpc-js definitions for the
66[ Bzl] ( https://build.bzl.io ) gRPC API as well as a more developer-friendly
77index.js entrypoint.
88
@@ -17,18 +17,23 @@ npm install @stackb/bzl-sdk-node
1717Given a running process (e.g. ` bzl serve ` ), connect to the server and retrieve metadata:
1818
1919``` js
20+ const grpc = require (' @grpc/grpc-js' );
2021const v1beta1 = require (' @stackb/bzl-sdk-node' ).v1beta ;
2122
22- // Create a grpc client to the Application service
23- const appClient = v1beta1 .newApplicationClient (' localhost:1080' );
23+ const client = new v1beta1.ApplicationClient (
24+ ' localhost:1080' ,
25+ grpc .credentials .createInsecure ());
2426
25- // Wait for the connection to be ready and perform a call to the unary GetApplicationMetata rpc endpoint.
26- appClient .waitForReady (4000 , () => {
27- appClient .getApplicationMetadata (
28- new v1beta1.pb.ApplicationMetadataRequest (),
29- (err , metadata ) => {
27+ client .waitForReady (4000 , () => printMetadata);
28+
29+ function printMetadata () {
30+ const request = new v1beta1.GetApplicationMetadataRequest ();
31+ client .getApplicationMetadata (request, (err , metadata ) => {
32+ if (err) {
33+ console .warn (' could not get metadata' , err);
34+ } else {
3035 console .log (` Connected to Bzl ${ metadata .getVersion ()} ` );
3136 }
32- )
33- });
37+ });
38+ }
3439```
0 commit comments