项目作者: s3rius

项目描述 :
Robust FastAPI template
高级语言: Python
项目地址: git://github.com/s3rius/FastAPI-template.git
创建时间: 2020-10-05T20:29:19Z
项目社区:https://github.com/s3rius/FastAPI-template

开源协议:

下载


python version version



Flexible general-purpose template for FastAPI.

Usage

⚠️ Git, Python and Poetry must be installed and accessible ⚠️

Poetry version must be greater or equal than 1.1.8. Otherwise it won’t be able to install SQLAlchemy.



Templator in action


You can install it directly from pypi with pip.

  1. python3 -m pip install fastapi_template
  2. python3 -m fastapi_template
  3. # or fastapi_template
  4. # Answer all the questions
  5. # 🍪 Enjoy your new project 🍪
  6. cd new_project
  7. docker-compose up --build

If you want to install it from sources, try this:

  1. python3 -m pip install poetry
  2. python3 -m pip install .
  3. python3 -m fastapi_template

Also, you can use it with docker.

  1. docker run --rm -it -v "$(pwd):/projects" ghcr.io/s3rius/fastapi_template

Features

One of the coolest features is that this project is extremely configurable.
You can choose between different databases and even ORMs, or
you can even generate a project without a database!
Currently SQLAlchemy 2.0, TortoiseORM, Piccolo, Ormar and Beanie are supported.

This project can run as TUI or CLI and has excellent code documentation.

Generator features:

  • Pydantic V2 (Where it’s possible. Some libs doesn’t have support);
  • You can choose between GraphQL and REST api;
  • Uvicorn and gunicorn;
  • Different databases support;
  • Different ORMs support;
  • Optional migrations for each ORM except raw drivers;
  • Optional redis support;
  • Optional rabbitmq support;
  • different CI\CD;
  • Optional Kubernetes config generation;
  • Optional Demo routers and models (This helps you to see how project is structured);
  • Pre-commit integration;
  • Generated tests with almost 90% coverage;
  • Tests for the generator itself;
  • Optional Prometheus integration;
  • Optional Sentry integration;
  • Optional Loguru logger;
  • Optional Opentelemetry integration.
  • Optional taskiq integration.

This project can handle arguments passed through command line.

  1. $ python -m fastapi_template --help
  2. Usage: fastapi_template [OPTIONS]
  3. Options:
  4. -n, --name TEXT Name of your awesome project
  5. -V, --version Prints current version
  6. --force Owerrite directory if it exists
  7. --quiet Do not ask for features during generation
  8. --api-type [rest|graphql] Select API type for your application
  9. --db [none|sqlite|mysql|postgresql|mongodb]
  10. Select a database for your app
  11. --orm [none|ormar|sqlalchemy|tortoise|psycopg|piccolo|beanie]
  12. Choose ObjectRelational Mapper lib
  13. --ci [none|gitlab_ci|github] Select a CI for your app
  14. --redis Add redis support
  15. --add_users Add fastapi-users support
  16. --rabbit Add RabbitMQ support
  17. --taskiq Add Taskiq support
  18. --migrations Add Migrations
  19. --kube Add kubernetes configs
  20. --dummy Add dummy model
  21. --routers Add example routers
  22. --swagger Add self hosted swagger
  23. --prometheus Add prometheus compatible metrics
  24. --sentry Add sentry integration
  25. --loguru Add loguru logger
  26. --opentelemetry Add opentelemetry integration
  27. --traefik Adds traefik labels to docker container
  28. --kafka Add Kafka support
  29. --gunicorn Add gunicorn server
  30. --cookie-auth Add authentication via cookie support
  31. --jwt-auth Add JWT auth support
  32. --help Show this message and exit.