Skip to content
/ pktapi Public

Pokémon Trainer API project for studying purposes using FastAPI.

Notifications You must be signed in to change notification settings

atoivat/pktapi

Repository files navigation

Pokémon Trainer API

Project for studying purposes using FastAPI.

Installing

Make sure your .env file is configured with:

DB
DB_NAME
DB_USER
DB_PSWD
DB_HOST
DB_PORT

SECRET_KEY
  • You can generate a new SECRET_KEY with
openssl rand -hex 32

Install Using Pipenv

Make sure you have pipenv installed:

pip install pipenv

Install dependencies:

pipenv install

Enter the virtual env.:

pipenv shell

Start the server:

uvicorn app.main:app

Install Using Docker

Build the docker image

docker-compose build

Run the containers

docker-compose up

The server will be listening at localhost:8000.

Check both Dockerfile and docker-compose.yml for further documentation.

Testing

You can test inside the container, on the postgres database, using

docker-compose run --rm --no-deps --entrypoint=pytest app /tests

To test locally using sqlite, add the following line to .env:

TESTING_DB_URL=sqlite:///testing.db

And then everything you run locally (the app or pytest) will use the local sqlite database (./testing.db).

If you consider usefull, you can also run only the postgres database container using

docker-compose up -d postgres

Other commands

Other useful commands are specified at Makefile.

Known Issues

Psycopg dependencies

  • Problem: pipenv was unable to install psycopg2 or psycopg-binary.
  • Solution found: install missing dependency
sudo apt-get install libpq-dev

Releases

No releases published

Packages

No packages published

Languages