DHP Metering API provides an api to store and aggregate credential verification usage metrics and provide api to query the counts using a predefined set as grouping attributes.
It is recommended to use Node.js v12
The following environment variables must be set before starting the application regardless of the deployment environment.
Environment Variable | Value |
---|---|
AUTH_STRATEGY | DEVELOPMENT or PROD |
PORT | Server port, default 9002 |
USE_HTTPS | true or false. If true, then endpoints must be accessed via https, otherwise http |
TLS_FOLDER_PATH | Default ./config/tls , Path to tls certs for https enabling |
The rest of app configuration is set in config file config/app/config.json
The following environment variables must be set to execute the service in IBM Cloud
Environment Variable | Value |
---|---|
POSTGRES_HOST | PgSQL server host |
POSTGRES_USER | PgSQL user |
POSTGRES_USERPWD | PgSQL user password |
POSTGRES_DB_NAME | PgSQL database name |
POSTGRES_PORT | PgSQL server port |
POSTGRES_SSLMODE | PgSQL ssl mode, e.g. prefer |
POSTGRES_CACERT | Server CA cert, with newline escaped, for e.g. "-----BEGIN CERTIFICATE-----\nMIID....nRmk\n-----END CERTIFICATE-----" |
APP_ID_URL | The App ID URL found in IBM Cloud service credentials oauthServerUrl value |
APP_ID_TENANT_ID | The App ID URL found in IBM Cloud service credentials tenantId value |
APP_ID_AUTH_SERVER_HOST | The App ID appidServiceEndpoint value, for e.g. https://us-east.appid.cloud.ibm.com |
APP_ID_CLIENT_ID | App ID instance ClientID |
APP_ID_SECRET | App ID instance secret |
- Start pg in docker
docker pull postgres:12
docker run --name dev-postgres -p 5432:5432 -e POSTGRES_PASSWORD=mysecretpassword -d postgres:12
# CREATE db
docker exec dev-postgres psql -U postgres -c"CREATE DATABASE verifier_metrics" postgres
npm install
npm run start
The API uses App ID for authorization. The api caller must be authorized with scope meter.reporter
to be able to query,
and the user must be authenticated (with no special scope) to be able to add metrics.
This section lists license details of libraries / dependencies.