Skip to content

sralloza/chore-management-api

Repository files navigation

Chore Management API

API to manage chores in a shared flat.

Development

The API is written in python using FastAPI. The first implementation was written in node.js using express. The incomplete node.js version can be found in the commit fa0e9bf7ec4d0b8fa9e7cd10117684551b2afb21.

Testing

Run all tests

The run-tests.sh script will start all containers, run the tests and stop the containers. With the flag --keep-up=true it will keep the containers up until CTRL-C is pressed.

Run some tests

You must have the containers up and running before running the tests (docker-compose up -d).

# Launch all tests
behave

# Launch tests of a specific API
behave -t api.chore-types

# Launch tests of a specific endpoint
behave -t getChoreTypes

# Launch authorization tests
behave -t authorization

# Launch other common tests
behave -t common

Deploy

Docker images are provided in dockerhub.

Note: the database must be mariadb or mysql.

Configuration

Configuration is done by setting environment variables.

Required

  • ADMIN_API_KEY: master administration API key.
  • APPLICATION_SECRET: secret key for the application. Used to sign JWT tokens.

Optional

  • DATABASE_HOST: database host. Defaults to localhost.
  • DATABASE_NAME: database name. Defaults to chore-management.
  • DATABASE_PASSWORD: database password. Defaults to root.
  • DATABASE_PORT: database port. Defaults to 3306.
  • DATABASE_USERNAME: database username. Defaults to root.
  • ENABLE_DB_CLEANUP: when set to true, the scheduler will be enabled and will run periodically some cleanup database tasks. Defaults to true.
  • IS_PRODUCTION: when set to true, the application will run in production mode (for example, documentation will not be available). Defaults to true in the docker application and to false in the python application.
  • REDIS_HOST: redis host. Defaults to localhost.
  • REDIS_PORT: redis port. Defaults to 6379.

Optional only for docker

These variables are only used when running the docker image. The docker entrypoint script will manage them.

  • CREATE_DATABASE: if set to true, it will try to create the database each time the container starts.
  • RUN_MIGRATIONS: run migrations on start. Defaults to true, meaning by default migrations are executed on start.
  • WAIT_FOR_IT_ADDRESS: comma separated addresses to wait for. For example, to wait for a database to be ready, set it to database:3306.