PD Client JS SDK.
Please ensure that each commit is followed the setting of:
.editorconfig
.prettierrc
All test files should be placed in src/__tests__
dir.
Install dependencies and build:
$ yarn
$ yarn build
Make sure the necessary unit tests passed.
$ yarn test
Currently we only publish this package to the GitHub Packages, we need to follow its instruction - Installing a package.
According to the instruction, we need to authenticate to the GitHub Packages with a personal access token.
-
Create a personal access token
Follow personal "Settings" -> "Developer settings" -> "Personal access tokens" -> "Generate new token" path, the "Select scopes" must select "repo" and "read:packages" at least.
-
Edit
~/.npmrc
, add a new line by the following content//npm.pkg.github.com/:_authToken=[YOUR_PERSONAL_ACCESS_TOKEN]
-
For project owner: Create or edit
.npmrc
inside your project folder, in the same directory as thepackage.json
, to include the following line specifying GitHub Packages and the account ownerregistry=https://npm.pkg.github.com/pingcap-incubator
If you use yarn, create
.yarnrc
instead of the.npmrc
, fill with following content:"@pingcap-incubator:registry" "https://npm.pkg.github.com"
-
For project owner: Install the
@pingcap-incubator/pd-client-js
for your project$ npm install @pingcap-incubator/pd-client-js
If you use yarn, add the
"@pingcap-incubator/pd-client-js": "^0.1.5"
into the package.json, then runyarn install --update-checksums
. Related issue about yarn: Integrity checked failed error.
Create an instance of PDClient and call its methods:
import PDClient from '@pingcap-incubator/pd-client-js'
const client = new PDClient({
endpoint: 'API_BASE_URL'
})
client.getHeatmap()
pd-client-js is under the Apache 2.0 license.