You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I did not find an enterprise nodejs client available; is it possible to have a client created similar to the python and go clients?
I have been trying to use @grpc/grpc-js and @grpc/proto-loader to create it and this is what I have come up with so far (against the update-docs-template branch):
constgulp=require('gulp');constthrough2=require('through2');constfs=require('fs');constpath=require('path');constgrpc=require('@grpc/grpc-js');constprotoLoader=require('@grpc/proto-loader');gulp.task('generate-sdk',function(){constprotoDir='proto';constincludeDirs=[path.resolve(__dirname,'lib/envoyproxy/data-plane-api'),path.resolve(__dirname,'lib/googleapis/googleapis'),path.resolve(__dirname,'lib/bufbuild/protoc-gen-validate'),path.resolve(__dirname,'lib/cncf/udpa'),path.resolve(__dirname,'proto/pomerium'),]returngulp.src(`${protoDir}/**/*.proto`).pipe(through2.obj(function(file,_,cb){constpackageDefinition=protoLoader.loadSync(file.path,{keepCase: true,longs: String,enums: String,defaults: true,oneofs: true,
includeDirs
});constprotoDescriptor=grpc.loadPackageDefinition(packageDefinition);constserviceName=Object.keys(protoDescriptor)[0];// Assume the service name is the first keyconstrelativePath=path.relative(protoDir,path.dirname(file.path));constoutputFilePath=path.join('build',relativePath,`${serviceName}Client.js`);constclientFactory=` const grpc = require('@grpc/grpc-js'); const protoDescriptor = ${JSON.stringify(protoDescriptor)}; class ${serviceName}Client { constructor(endpoint, channelCredentials) { this.service = new protoDescriptor.${serviceName}(endpoint, channelCredentials); } } module.exports = ${serviceName}Client; `;fs.mkdirSync(path.dirname(outputFilePath),{recursive: true});fs.writeFileSync(outputFilePath,clientFactory);cb(null,file);}));});// Define a task that uses the generate file and includes the copy taskgulp.task('copy',()=>{returngulp.src('src/**/*').pipe(gulp.dest('build'))});// Define a task to clean the build directorygulp.task('clean',async()=>{constdel=awaitimport('del');returndel(['build']);});// Default taskgulp.task('generate',gulp.series('copy','generate-sdk'));gulp.task('default',gulp.series('clean','generate'));
I did not find an enterprise nodejs client available; is it possible to have a client created similar to the python and go clients?
I have been trying to use
@grpc/grpc-js
and@grpc/proto-loader
to create it and this is what I have come up with so far (against theupdate-docs-template
branch):pull.sh:
gulpfile.js
src/package.json
The text was updated successfully, but these errors were encountered: