This repo contains the API for the KLIPS project.
with local Node.js:
# install dependencies
npm i
# run with hot-reload
npm run watch
# create a local build
npm run build
using Node.js inside Docker:
# build image
docker build \
--file Dockerfile.dev \
--tag klips-api-dev \
.
# run image with mounted source code
docker run \
-p 3000:3000 \
-v $(pwd):/usr/app \
-v $(pwd)/src/config:/klips-conf \
--env-file docker.env \
klips-api-dev
## build the production image
docker build --tag klips-api .
On every push GitHub Actions builds the Docker image and hosts it on the GitHub registry.
Use the Docker image hosted on GitHub:
docker run \
-p 3000:3000 \
-v /home/terrestris/klips-api-config:/klips-conf \
-e PORT=3000 \
-e CONFIG_DIR=/klips-conf \
ghcr.io/klips-project/klips-api:latest
USE_RABBIT_MQ
- if API shall forward messages to RabbitMQ. Allowed values:0
,1
. Default is0
PORT
- The Port on which to publish this APIDISPATCHERQUEUE
- the name of the dispatcher queueRABBITHOST
- the host of the RabbitMQ instanceRABBITUSER
- the username for the RabbitMQ instanceRABBITPASS
- the password for the RabbitMQ instanceCONFIG_DIR
- the path to the directory with the configuration filesPARTNER_URL_START
- the start string of the partner's API URL, e.g. "https://www.example.com/api"PARTNER_API_USERNAME
- the username of the partner's APIPARTNER_API_PASSWORD
- the password of the partner's API
The API has two config files:
basic-auth-users.json
: the credentials for basic authenticationschema-geotiff-upload.json
: the JSON schema for validating the API inputjob-conf.json
: options for each job that shall be send to RabbitMQ
API starts on port 3000 with these endpoints:
GET /status
POST /job
curl \
--request POST \
--header 'Authorization: Basic a2xpcHM6a2xpcHM=' \
--header 'Content-Type: application/json' \
--data @example_requests/send-geotiff.json \
'http://localhost:3000/api/job'
The script in api-monitor
can be used to regularly check if the API is running.