This is the API server.
Find a file
2024-08-12 13:49:24 -04:00
.vscode vscodium extension recommendatiosn 2024-06-28 11:46:13 -04:00
src run on localhost by default 2024-08-12 13:49:24 -04:00
tests not needed number 2024-08-07 20:32:29 -04:00
.dockerignore ignore logs 2024-08-12 13:40:18 -04:00
.gitignore ignore logs 2024-08-12 13:40:18 -04:00
bin.dockerfile rename exe to glimpse instead of server 2024-08-01 19:59:15 -04:00
docker-compose.yml remove unused volume 2024-08-07 14:30:03 -04:00
dockerfile add missing lib 2024-08-01 21:47:38 -04:00
LICENSE Initial commit 2024-06-11 12:51:31 -04:00
nim.cfg dont log sql queries by default 2024-08-12 12:51:16 -04:00
README.md dont log sql queries by default 2024-08-12 12:51:16 -04:00
server.nimble rename exe to glimpse instead of server 2024-08-01 19:59:15 -04:00

Glimpse API server

This is the Glimpse API server.

Compilation and deployment

Host

Install needed libraries:

nimble install jester norm checksums

Build glimpse executable (if you want the SQL queries logged, compile with normDebug):

nimble build

Compile and run:

nimble run

Run unit tests:

nimble test

Docker

Compile binary

To compile the binary only, run the following (executable will be found in /bin/):

docker buildx build -t glimpse-server:latest --output=bin --target=runner -f bin.dockerfile .

Deploy using docker run

To deploy an instance of glimpse within docker, run the following (make sure to update the database's host accordingly):

docker buildx build -t glimpse-server:latest .
docker run -it --rm -p 8080:8080 glimpse-server:latest

Use the following to run a temporary PostgreSQL database, (DO NOT USE IN PRODUCTION):

docker run -it --rm -e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=postgresql -p 5432:5432 postgres

Deploy using docker compose

The docker compose provided sets up a postgres server alongside glimpse. To deploy, run (add the -d to detach and run in the background):

docker compose up

To shutdown the servers:

docker compose down

Usage

Configuration

Glimpse will create the default configuration file, config.ini, in the root of the directory if it does not exist. Configuration relating to web framework, Jester, is under the Server section. Database configuration is under the Database section. Other configuration variables are under General. If running glimpse using the docker image, docker run ..., make sure to adjust container's network pointing it to the database (When using docker compose, use network_mode: host if database is running from host).

API Endpoints

Each endpoint has comments describing what type of request it is and what parameters it takes. Example requests using cURL, more examples can be found in /tests/:

curl -X <POST|GET|PUT|DELETE> <Endpoint URI> -H '<Request Header Contents>'
curl -X POST http://0.0.0.0:8080/api/v1/newUser -H 'Username=Array' -H 'Password=i8Vl8XZaVRiZFsZ'
curl -X POST -H "Authorization: <access_token>" -F "file=@image.png" http://0.0.0.0:8080/api/v1/newFile