Node.js developing
Getting started
Clone the repo, then install dependencies:
npm i
Testing
Running tests will require you have Docker installed on your machine; see their documentation for installation details based on your platform.
Then run the tests:
npm test
These tests include an integration suite that uses the Testcontainers library to spin up a Docker container running Stargate to test a gRPC connection and issues queries.
See the integration tests at src/client/client.test.ts
for more example uses of this client.
Generating gRPC code stubs
Should the Stargate protobuf files change and you need to generate new gRPC code, this project has an NPM script you can use:
npm run gen
After running, you will find the new generated *grpc_pb.d.ts
and *pb.d.ts
files in stargate-grpc-node-client/src/proto/
.
TypeScript compilation
This client is written in TypeScript but must compile JS for use in vanilla JavaScript environments.
If you change source code in this client, be sure to use the npm run compile
command after your changes to reflect them in the lib
folder packaged for NPM consumers.
Testing changes locally
You can use the yalc library to publish
changes to this client locally and test with a consuming application.
Assuming you have yalc
installed and you’ve already made your changes, do the following:
(In your local copy of this repo)
npm run compile
yalc publish @stargate-oss/stargate-grpc-node-client
(In your local consuming application)
yalc add @stargate-oss/stargate-grpc-node-client
You may need to rm -rf node_modules
and do a fresh npm i
in the consuming application for the changes to take effect.
Once you have this dependency established, you can update this client locally
with new changes at any time by running yalc push
from the
stargate-grpc-node-client
directory.
Coding style
This project uses eslint
and prettier
to lint and format code.
These standards are enforced automatically with a husky pre-commit hook and in the CI pipeline.