- Build & Run tests locally
- Debug Mode
- Update Stargate and Data API versions
- Build API Reference Documentation
- Contributing
- Creating a release
Prerequisites:
npm install
npm run build
- Start Docker
- Start Data API
bin/start_data_api.sh
- Copy the
.env.example
file and create a new.env
file that should have all the connection details as shown below.
DATA_API_URI=http://localhost:8181/v1/testks1
STARGATE_AUTH_URL=http://localhost:8081/v1/auth
STARGATE_USERNAME=cassandra
STARGATE_PASSWORD=cassandra
- Run the tests
npm run test
Run npm run lint
to run ESLint.
ESLint will point out any formatting and code quality issues it finds.
ESLint can automatically fix some issues: run npm run lint -- --fix
to tell ESLint to automatically fix what issues it can.
You should try to run npm run lint
before committing to minimize risk of regressions.
You can make stargate-mongoose print all HTTP requests to the console using the logger
option as follows.
import { logger } from 'stargate-mongoose';
logger.setLevel('http');
Once you've enabled the http
logging level, you should see every HTTP request and response logged to the console in a format similar to the following:
http: --- request POST http://localhost:8181/v1/testks1 {
"deleteCollection": {
"name": "collection1"
}
}
http: --- response 200 POST http://localhost:8181/v1/testks1 {
"status": {
"ok": 1
}
}
When running tests, you can turn on the http
logging level by setting the D
environment variable as follows:
env D=1 npm test
Stargate-mongoose's tests automatically enable http
logging level if the D
environment variable is set.
Otherwise, all console output is suppressed using logger.silent = true
.
This means there's no way to enable console output without setting the D
environment variable when running npm test
.
Stargate and the Data API versions are maintained in the file api-compatibility.versions
. Update the versions accordingly, submit a PR and make sure that the GitHub Actions that verify the new versions run fine.
API Documentation of this library is generated using jsdoc-to-markdown
Run below to generate API documentation. This takes the APIReference.hbs
and the library code as input and generates APIReference.md file.
npm run build:docs
We are using npm-publish to handle publishing. So to publish a release to NPM, we need to
- Create a branch out of 'main' and change
version
in thepackage.json
as needed. - Run
npm install
(this will updatesrc/version.ts
file). - Run
npm run build
- Submit a PR and get that merged into
main
branch - Check out 'main' branch & pull the latest
git checkout main
git pull origin main
- Then create a tag with the required version, prefixed with 'rel-'. This will trigger a workflow that publishes the current version to npm. For example:
rel-0.2.0-ALPHA
git tag rel-x.y.z
git push origin rel-x.y.z
- Finally, check the stargate-mongoose npm registry page https://www.npmjs.com/package/stargate-mongoose and make sure the latest version is updated.