Skip to content

Commit

Permalink
Add example
Browse files Browse the repository at this point in the history
  • Loading branch information
gawsoftpl committed Dec 19, 2023
1 parent 4491d30 commit 76140c8
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 16 deletions.
33 changes: 18 additions & 15 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -210,22 +210,25 @@ You can use one line helpers function for simple download service from grpc refl
const { serviceHelper } = require('grpc-js-reflection-client');
const grpc = require('@grpc/grpc-js');

const proto = await serviceHelper({
host: "localhost:50053",
servicePath: "addressbook.AddressesService",
credentials: grpc.ChannelCredentials.createInsecure(),
proto_filename: 'addressbook.proto',
protoLoaderOptions: {
keepCase: true
}
})
(async()=>{
const proto = await serviceHelper({
host: "localhost:50053",
servicePath: "addressbook.AddressesService",
credentials: grpc.ChannelCredentials.createInsecure(),
proto_filename: 'addressbook.proto',
protoLoaderOptions: {
keepCase: true
}
})

proto.Add({
name: "abc",
email: "test@example.com"
}, (err, response) => {
console.log(response)
});
})();

proto.Add({
name: "abc",
email: "test@example.com"
}, (err, response) => {
console.log(response)
});
```

## Tests
Expand Down
21 changes: 21 additions & 0 deletions examples/helpers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
const { serviceHelper } = require('../');
const grpc = require('@grpc/grpc-js');

(async()=>{
const proto = await serviceHelper({
host: "localhost:50053",
servicePath: "addressbook.AddressesService",
credentials: grpc.ChannelCredentials.createInsecure(),
proto_filename: 'addressbook.proto',
protoLoaderOptions: {
keepCase: true
}
})

proto.Add({
name: "abc",
email: "test@example.com"
}, (err, response) => {
console.log(response)
});
})();
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
"build": "tsc",
"test:start-node-server": "ts-node tests/e2e/grpc-node-server-reflection/server.ts",
"test:start-node-server2": "ts-node tests/e2e/grpc-node-grpc-reflection-server/server.ts",

"test": "jest --forceExit",
"test:e2e": "jest --config ./tests/jest-e2e.json --forceExit",
"start:dev": "nodemon --watch './**/*.ts' --exec 'ts-node' src/test.ts"
Expand Down

0 comments on commit 76140c8

Please sign in to comment.