Go to file
Alie 937c7db2d5
Unit Tests with docker compose / unit-test (pull_request) Successful in 5m21s Details
added mountpoints to existing directories on didn
2024-01-06 17:32:04 +01:00
.gitea/workflows added mountpoints to existing directories on didn 2024-01-06 17:32:04 +01:00
src added tests and auth to PUT images 2024-01-06 12:57:22 +01:00
tests Merge pull request 'put-images' (#18) from put-images into develop 2024-01-06 12:45:36 +00:00
.dockerignore Adding docker compose to test api with mongodb 2023-12-25 07:47:16 +01:00
.gitignore fmt 2023-12-27 20:41:35 +01:00
Dockerfile made the dockerfile usable to our usecase 2023-12-31 13:26:10 +01:00
README.md Documentation for some API endpoints 2024-01-06 11:43:21 +00:00
compose.yaml unit testing (#7) 2023-12-31 11:11:22 +00:00
package.json Added fake data for testing and dev environment 2024-01-06 13:25:24 +01:00
tsconfig.json first commit 2023-12-08 14:05:20 +01:00

README.md

bot-api

Introduction

The function of the API is basically to access the images' metadata stored in the database.

Usage

The API exposes some endpoints to interact with the database.

GET /images

Allows to get a list of image documents.

Query params

  • limit: an optional parameter, which accepts a non-negative integer that dictates the number of documents that the list will have. If its value is equal to 0, or if this parameter is missing, the endpoint will return all the image documents in the database.
  • status: an optional parameter, which accepts the values consumed, available and unavailable. It filters the documents that have only the status attribute equal to that indicated in the parameter's value. If the parameter is missing, no filter will be applied to the document.

Example

  • GET /images?limit=5&status=available: will return 5 documents that have the available value in their status attribute.

PUT /images/<id>

Modifies an existing image document. The request must provide a JSON-formatted body, with one or more valid document attributes. The existing document attributes will be replaced with the provided new ones.

Params

  • id: the id of the document to be modified.

Example

  • PUT /images/61f7e48f0c651345677b7775 with body { "status": "consumed" }: will modify the document referenced by the id param, changing their status value to consumed.

POST /images

POST /login

Installation

To install dependencies:

bun install

To run:

docker compose up

For testing, remember:

docker compose down -v
docker compose run bot-api bun run test

This project was created using bun init in bun v1.0.13. Bun is a fast all-in-one JavaScript runtime.