Coder Social home page Coder Social logo

global-registry-nodejs-client's Introduction

Global Registry Client for Node.js

The library contains the implementation of the Global Registry API Client

Installation

Clone the repository and install dependencies:

git clone [email protected]:CruGlobal/global-registry-nodejs-client.git
cd global-registry-nodejs-client
npm install

Usage

Determine configuration parameters:

baseUrl

Base URL is the URL address of the Global Registry endpoint.

You can provide the address in the client options as baseUrlor through environment variable GLOBAL_REGISTRY_URL.

accessToken

You can provide the access token in the client options as accessToken or through environment variable GLOBAL_REGISTRY_TOKEN

Initialize the client object

const { GRClient } = require('global-registry-nodejs-client')
const options = {baseUrl: ' ... ', accessToken: ' ... '}
const client = new GRClient(options)

Call API

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
  }
]} 

Supported Global Registry resources:

  • Entity
  • EntityType
  • RelationshipType
  • EnumValue
  • Measurement
  • MeasurementType
  • System

Running Tests

npm test

global-registry-nodejs-client's People

Contributors

omicron7 avatar pkoz avatar mattdrees avatar dependabot-preview[bot] avatar

Watchers

Josh Starcher avatar Ryan Strandt avatar  avatar Scotty Waggoner avatar James Cloos avatar Todd Gross avatar Gyasi Story avatar Jon Vellacott avatar Bill Randall avatar Jay Holt avatar Ken Yeo avatar Adam Johnson avatar Sam Kohler avatar Randy McDowell avatar  avatar Rachael Skeath avatar Kewei Jiang avatar  avatar Alvin Siu avatar David Navarro avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.