Newer
Older
reseda-search / README.md

RESEDA API Search

Prerequisites

Installation

$ git clone https://gitbucket.inist.fr/git/METADoRe/reseda-search.git
$ cd ./reseda-search

Production

$ docker-compose up -d api

Usage

API Key

A master API key is created at the first launch of the application, API keys are stored in ./api-keys.json file.

An API key gives access to more fields returned by the API, for examples:

{
  "a7e666ed93d877d9a4f9": {
    "name": "my-api-key",
    "fields": {
      "employees": ["*"],
      "structures": ["field", "field.subfield", "field.*"],
    }
  },
  "939500eae15165ab4b8a": {
    "name": "my-api-key",
    "fields": {
      "employees": ["field"],
    }
  },
  "e24d1167135d65bfcaad": {
    "name": "my-api-key",
    "fields": {
      "structures": ["field.*"],
    }
  }
}

employees (type: Array) and structures (type: Array) are optional, the fields returned by the API will be the default ones (cf: Environment variables - FIELDS_NAME).

The values of its tables can be:

  • * gives access to all the fields.
  • field gives access to a field
  • field.subfield gives access to a subfield
  • field.* gives access to all subfields

There are two ways to use an api key, by the header x-api-key (in lowercase) or the url parameter apiKey.

Examples:

$ curl -H "x-api-key: 6596ae25fdfdc83b85a7" http://localhost:3000/employees

$ curl http://localhost:3000/employees?apiKey=6596ae25fdfdc83b85a7

Development

$ npm install # Install Node.JS dependencies
$ docker-compose -f docker-compose.debug.yml run --rm elastic chown -R elasticsearch /usr/share/elasticsearch/ # Chown ElasticSearch volume
$ docker-compose -f docker-compose.debug.yml up -d elastic # Run ElasticSearch
$ docker-compose -f docker-compose.debug.yml up -d api # Run API in development mode

Tests

$ npm run test

Environment variables

Name Type Description
APP_PORT Integer Application port (default: 3000)
ELASTICSEARCH_SCHEME String URI scheme (default: https)
ELASTICSEARCH_HOST String ElasticSerach host (default: localhost)
ELASTICSEARCH_PORT Integer ElasticSerach port (default: 9200)
ELASTICSEARCH_USERNAME String ElasticSerach host (default: elastic)
ELASTICSEARCH_PASSWORD String ElasticSerach host (default: changeme)
RESEDA_EMPLOYEES_INDEX String Reseda employees index name (default: employees)
RESEDA_STRUCTURES_INDEX String Reseda structures index name (default: structures)
PARAMS_MAX_SIZE Integer Query max size (default: 1000)
PARAMS_DEFAULT_SIZE Integer Query default size (default: 25)
RESEDA_DOC_URL String OpenAPI URL (default: docs)
FIELDS_NAME JSON Default returned fields (default: { "employees": [ "nomUsage", "prenom", "UUIDPersonne", "affectationAdministrative.codeUnite" ], "structures": [ "codeUnite", "intituleUnite" ] })