Skip to content
Discussion options

You must be logged in to vote

Hey, Alex

Here is a sample code that shows making a simple gRPC client.

`const GRPC_METHODS = Object.values(GRPC_SERVICES).flatMap((service) =>
Object.keys(service.methods)
) as (keyof (typeof GRPC_SERVICES)[keyof typeof GRPC_SERVICES]['methods'])[];

export type GRPCServiceType = keyof typeof GRPC_SERVICES;
export type GRPCMethodType = (typeof GRPC_METHODS)[number];

const header: Interceptor = (next) => async (req) => {
const zhbr = getAccessToken();
if (zhbr !== null) {
req.header.set('Authorization', 'Bearer ' + zhbr);
}

const serviceName = req?.service?.typeName;
const methodName = req?.method?.name;

logger.log([HTTP][REQ][${methodName}], req.url, {
request: req,
});

return await next(…

Replies: 3 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by alexkoren-dev
Comment options

You must be logged in to vote
1 reply
@it-mario
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Apps API and Webhooks Discussions related to GitHub's APIs or Webhooks Question Ask and answer questions about GitHub features and usage Welcome 🎉 Used to greet and highlight first-time discussion participants. Welcome to the community! source:ui Discussions created via Community GitHub templates API Discussions around GitHub API platform and docs
3 participants