The library contains the implementation of the Global Registry API Client
Clone the repository and install dependencies:
git clone [email protected]:CruGlobal/global-registry-nodejs-client.git
cd global-registry-nodejs-client
npm install
Determine configuration parameters:
Base URL is the URL address of the Global Registry endpoint.
You can provide the address in the client options as baseUrl
or through environment variable GLOBAL_REGISTRY_URL
.
You can provide the access token in the client options as accessToken
or through environment variable GLOBAL_REGISTRY_TOKEN
const { GRClient } = require('global-registry-nodejs-client')
const options = {baseUrl: ' ... ', accessToken: ' ... '}
const client = new GRClient(options)
Now you can use specific objects of the client, to access Global Registry resources.
For example, to access EntityType resources:
// GET records
client.EntityType.get( {filters: {name: 'person'}} ).then( result => result.entities.map(e => e.entity_type) )
// GET one record, by ID
client.EntityType.getOne('1200beca-169c-4443-85b3-80611f5c25a5').then( result => result.entity.entity_type )
// POST:
client.EntityType.post({name: '', parent_id: ''}, {full_response: true}).then()
// PUT:
client.EntityType.put(123, {name: '', parent_id: ''}).then()
// or
client.EntityType.put(123, {name: '', parent_id: ''}, {full_response: true}).then()
// DELETE
client.EntityType.delete(123).then()
Mind, that the input data for POST
and PUT
does not contain wrapping entity type!
So it looks like
{
"name": "xx",
"parent_id": 123
}
not:
{ "entity_type":
{
"name": "xx",
"parent_id": 123
}
}
however, for now, results are wrapped in pluralized object name, for example:
{ "entity_types": [
{
"name": "xx",
"parent_id": 123
}
]}
- Entity
- EntityType
- RelationshipType
- EnumValue
- Measurement
- MeasurementType
- System
npm test