Skip to content

tsytsyksvitlana/FastAPI_users

Repository files navigation

FastAPI

Python FastAPI SQLAlchemy Pydantic PostgreSQL Docker pre-commit isort


Production

Create .env and .env.test file and fill with required data

POSTGRES_USER=
POSTGRES_PASSWORD=
POSTGRES_DB=
POSTGRES_HOST=
POSTGRES_PORT=

Generate an RSA private key, of size 2048

mkdir certs
cd certs
openssl genrsa -out jwt-private.pem 2048

Extract the public key from the key pair, which can be used in a certificate

openssl rsa -in jwt-private.pem -outform PEM -pubout -out jwt-public.pem

Create home network

docker network create home

Run docker-compose file

docker-compose up -d

To see interactive documentation in Swagger, visit

http://localhost:8000/

To delete container

docker-compose down -v

Development

Finish production setup

Pre-commit command

pre-commit run --all-files

Migrations

docker exec -it fastapi-fastapi-1 /bin/sh
cd /code/web_app
alembic revision --autogenerate -m "message"
exit

Testing

docker exec -it fastapi-fastapi-1 pytest

CLI

Create database

docker exec -it fastapi-fastapi-1 python -m web_app.db.cli create

Drop database

docker exec -it fastapi-fastapi-1 python -m web_app.db.cli drop

Populate database with data

docker exec -it fastapi-fastapi-1 python -m web_app.cli populate --file tests/test_data/data.json

Create user with admin role

docker exec -it fastapi-fastapi-1 python -m web_app.cli create-admin

To run ipython

docker-compose up ipython

Technology

  • Python 3
  • FastAPI
  • Pydantic
  • Postgres
  • SQLAlchemy
  • Docker

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages