.husky | 1 month ago | ||
config | 6 days ago | ||
elastic | 7 days ago | ||
lib | 6 days ago | ||
openapi | 7 days ago | ||
routes | 7 days ago | ||
.dockerignore | 2 months ago | ||
.eslintignore | 26 days ago | ||
.eslintrc.js | 2 months ago | ||
.gitignore | 20 days ago | ||
.npmrc | 2 months ago | ||
.nvmrc | 2 months ago | ||
Dockerfile | 1 month ago | ||
README.md | 7 days ago | ||
app.js | 1 month ago | ||
docker-compose.debug.yml | 20 days ago | ||
docker-compose.yml | 20 days ago | ||
package-lock.json | 6 days ago | ||
package.json | 6 days ago | ||
server.js | 7 days ago |
$ git clone https://gitbucket.inist.fr/git/METADoRe/reseda-search.git $ cd ./reseda-search
$ docker-compose up -d api
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:
{ "scope": [], "fields": { "employees": [], "structures": [] }, "metadata": { "application": "", "tags": [] } }
Key | Type | Description |
---|---|---|
scope | Array[String] | The scope defines the access to the routes, if it is not defined the key cannot access the different routes. You have to add "employees" and/or "structures" to give access. (ex: "scope": ["employees"]) |
fields.employees | Array[String] | Define the fields returned by the API, if empty all fields are returned. (default: []) |
fields.structures | Array[String] | Define the fields returned by the API, if empty all fields are returned. (default: []) |
metadata.application | String | It is necessary to fill in the name of the application that will use the API key to ensure a follow-up of the requests. |
metadata.tags | Array[String] | Different tags can be filled in or not, you can indicate the information you want. (default: []) |
There are one way to use an api key, by the header x-api-key
.
Examples:
$ curl -H "x-api-key: 6596ae25fdfdc83b85a7" http://localhost:3000/employees $ curl http://localhost:3000/employees?apiKey=6596ae25fdfdc83b85a7
$ 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
$ npm run test
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) |
RESEDA_TOKENS_INDEX | String | API Key index name (default: tokens) |
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" ] }) |
SCROLL_TIME | String | Scroll time (default: 5m) |
MASTER_TOKEN_KEY | String | Master token key to manage tokens (default: b1230abd533c8e9c41cb9e562b1b2017bcb968322dacd973162ce5135baf15b8) |
MASTER_TOKEN_PARAMS | JSON | Master token key to manage tokens (default: { "scope": ["managment", "admin"], "metadata": { "application": "@metadore/reseda-search", "tags": ["apiKey", "@metadore/reseda-search"] } }) |
The OpenAPI page is by default available on /docs
, example: http://localhost:3000/docs. You can change the URL via the environment variable RESEDA_DOC_URL.