Git Product home page Git Product logo

fastapi-template's Introduction

Hi there 👋, I'm Pavel Kirilin

I've got many useless and useful projects to tell about. I develop my projects here or on my private gitlab. Experienced with many technologies and languages such as Python, Rust, Haskell and more. Always want to know more and develop things to ease my and others lives.

Hall of fame

Contact me

fastapi-template's People

Contributors

aitoehigie avatar alisayyah avatar am1ru1 avatar andcarnivorous avatar anton-petrov avatar bensebabillal avatar chandr-andr avatar codeleta avatar deanneaht avatar emorozov avatar gpkc avatar haluk avatar nicognaw avatar s3rius avatar sorasful avatar tschiolborg avatar wp-lkl avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fastapi-template's Issues

Add gunicorn startup option.

Gunicorn with uvicorn workers is faster than raw uvicorn. This feature might be useful for folks who want to gain more speed to their projects.

Add psycopg support.

It would be super nice to have ability to generate project without ORM.
Since for highload it's really useful.

Fix connection pools dependencies.

It's not that cool that some connections, that were taken from the pools, are waiting until the handler function is complete.
In this issue we must provide more convenient way for managing connections in web service.

  • Fix psycopg dependency (#107)
  • Fix redis dependency (#110)

SQLAlchemy and rabbitmq were already using pools.

Optimize tests

We need to optimize tests.

Currently pytest runs for 20 minutes which is really slow. Maybe run tests in parallel.

Add AWS cloud deployment.

We need to create an AWS configuration for cloud deploy.

I guess, that terraform is a really good way to create infrastructure.

In this thread we must choose the best way to deploy a cloud app. Currently I'm thinking about creating REST Gateway. But maybe someone would like to choose something else.

This feature is planned for release/3.3.0.

Issue with project name and k8s namespace

The regex for project name is not the same that is allowed for k8s namespaces

Error from server (Invalid): error when creating "deploy/kube/namespace.yml": Namespace "tmp_test" is invalid: metadata.name: Invalid value: "tmp_test": a lowercase RFC 1123 label must consist of lower case alphanumeric characters or '-', and must start and end with an alphanumeric character (e.g. 'my-name',  or '123-abc', regex used for validation is '[a-z0-9]([-a-z0-9]*[a-z0-9])?')

Template using syntax docker-compose v2 "depends_on", but docker-compose version: '3.7'

Issue:

$ docker-compose -f deploy/docker-compose.yml --project-directory . build
ERROR: The Compose file './deploy/docker-compose.yml' is invalid because:
services.api.depends_on contains an invalid type, it should be an array
services.migrator.depends_on contains an invalid type, it should be an array

In docker-compose file:

    depends_on:
      db:
        condition: service_healthy
      redis:
        condition: service_healthy

Should be:

    depends_on:
      - db
      - redis

Reference: https://docs.docker.com/compose/compose-file/compose-file-v3/#depends_on

Add travis-ci.

Many opensource projects use travis-ci to build systems. It would be nice to have ability to generate such configs.

Translations

Translate README.md in the template in English.

Add kafka integration.

Many people use kafka as message broker, so it might be useful to have an option to add kafka easily.

Rest is not enough.

For now, we have only REST API controllers. I want to add a prompt to choose between REST, GraphQL, JsonRPC.

Question: where to put Mangum handler?

How do I add the Mangum handler into this template produced code?

Intention:
https://dwisulfahnur.medium.com/fastapi-deployment-to-aws-lambda-with-serverless-framework-b637b455142c

from fastapi import FastAPI

from app.api.api_v1.api import router as api_router
from mangum import Mangum

app = FastAPI()

@app.get("/")
async def root():
    return {"message": "Hello World!"}

app.include_router(api_router, prefix="api/v1")
handler = Mangum(app)

not sure how to wrap the handler to the app?

def main() -> None:
    """Entrypoint of the application."""
    uvicorn.run(
        "<project>.web.application:get_app",
        workers=settings.workers_count,
        host=settings.host,
        port=settings.port,
        reload=settings.reload,
        factory=True,
    )

def get_app() -> FastAPI:
    """
    Get FastAPI application.

    This is the main constructor of an application.

    :return: application.
    """
    app = FastAPI(
        title="<project>",
        description="<project>",
        version=metadata.version("<project>"),
        docs_url=None,
        redoc_url=None,
        openapi_url="/api/openapi.json",
        default_response_class=UJSONResponse,
    )

    app.on_event("startup")(startup(app))
    app.on_event("shutdown")(shutdown(app))

    app.include_router(router=api_router, prefix="/api")
    app.mount(
        "/static",
        StaticFiles(directory=APP_ROOT / "static"),
        name="static",
    )

    return app

Question: what is the endpoint link when running from python -m ?

Hi I executed the a newly generated template with dummy model, router and self-hosted API. But somehow the endpoint (including /health) is returning 404. I did not change the router settings either.
What is the url link?

http://127.0.0.1:8000/health

$ python -m main
INFO: Started server process [4505]
INFO: Waiting for application startup.
INFO: Application startup complete.
INFO: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
INFO: 127.0.0.1:60642 - "GET / HTTP/1.1" 404 Not Found
INFO: 127.0.0.1:60642 - "GET / HTTP/1.1" 404 Not Found
INFO: 127.0.0.1:60644 - "GET /health HTTP/1.1" 404 Not Found
INFO: 127.0.0.1:60644 - "GET /dummy HTTP/1.1" 404 Not Found
INFO: 127.0.0.1:60646 - "GET //dummy HTTP/1.1" 404 Not Found
INFO: 127.0.0.1:60648 - "GET /docs HTTP/1.1" 404 Not Found
INFO: 127.0.0.1:60656 - "GET /health HTTP/1.1" 404 Not Found

Add tests

Add tests to check project generation.

Add a way to send tasks to Redis (celery ?)

Hi there !

I find it very nice to have Redis/RabbitMQ but it seems that for now we are a route to get and set values in these services, but we don't really have a way to send background tasks to them easily.

Do you think it would be a good idea/possible to add a way to send and consume background tasks easily ? I was thinking about Celery but maybe there are others options that could be worth.

What do you think ?

Fix kubernetes configs.

Currently we have several problems in kubernetes configs.

  • migrator job doesn't have limits on cpu and ram;
  • redis env value converted to boolean after formatting;
  • wrong indent in yamls;
  • invalid format for CMD in Dockerfile.

If you find more, please fell free to add comments.

Add GINO support.

GINO is a new async ORM on top of SQLAlchemy. It must be relatively easy to add this ORM, because we already have alembic integration.

Add Docker-Swarm support

Hi there !

Since we are using docker-compose and there is also a Kubernetes config, I was wondering If it would be a good idea to add a Docker Swarm configuration. That's something I would be interested in and I would like to propose something if that's accepted !

Use async url for Ormar ORM

Hello,

While looking at the template here :

I noticed that for SqlAlchemy we use async scheme ("postgresql+asyncpg" ) but not for Ormar, is there a reason or it's just missing the template ?

Thanks !

Failed tests on initilization and unreachable /w Docker-Compose

python3 -m fastapi_template                                                                                                                  ✔  ccdemo 3.9.10  
Project name: fatemplate
Project description: fatemplate
Removing resources for disabled feature Gitlab CI...
Removing resources for disabled feature Tortoise ORM...
Removing resources for disabled feature Ormar ORM...
Removing resources for disabled feature PsycoPG...
Removing resources for disabled feature MySQL DB...
Removing resources for disabled feature SQLite DB...
cleanup complete!
⭐ Placing resources nicely in your new project ⭐
Resources are happy to be where they are needed the most.
hint: Using 'master' as the name for the initial branch. This default branch name
hint: is subject to change. To configure the initial branch name to use in all
hint: of your new repositories, which will suppress this warning, call:
hint: 
hint:   git config --global init.defaultBranch <name>
hint: 
hint: Names commonly chosen instead of 'master' are 'main', 'trunk' and
hint: 'development'. The just-created branch can be renamed via this command:
hint: 
hint:   git branch -m <name>
Git repository initialized.
Added files to index.
Updating dependencies
Resolving dependencies... (14.9s)

Writing lock file

No dependencies to install or update

Installing the current project: fatemplate (0.1.0)
pre-commit installed at .git/hooks/pre-commit
pre-commit installed.
Check python ast.........................................................Passed
Trim Trailing Whitespace.................................................Failed
- hook id: trailing-whitespace
- exit code: 1
- files were modified by this hook

Fixing fatemplate/web/application.py
Fixing deploy/docker-compose.yml
Fixing fatemplate/settings.py
Fixing fatemplate/web/lifetime.py
Fixing deploy/kube/db.yml

Check Toml...............................................................Passed
Fix End of Files.........................................................Failed
- hook id: end-of-file-fixer
- exit code: 1
- files were modified by this hook

Fixing deploy/docker-compose.yml
Fixing fatemplate/tests/test_dummy.py
Fixing fatemplate/static/docs/swagger-ui-bundle.js
Fixing fatemplate/static/docs/redoc.standalone.js
Fixing fatemplate/tests/test_echo.py
Fixing fatemplate/static/docs/swagger-ui.css

Add trailing commas......................................................Failed
- hook id: add-trailing-comma
- exit code: 1
- files were modified by this hook

Rewriting fatemplate/tests/test_redis.py
Rewriting fatemplate/web/application.py
Rewriting fatemplate/conftest.py
Rewriting fatemplate/db/dao/dummy_dao.py
Rewriting fatemplate/db/utils.py
Rewriting fatemplate/tests/test_echo.py
Rewriting fatemplate/tests/test_dummy.py

Pretty format YAML.......................................................Failed
- hook id: pretty-format-yaml
- exit code: 1
- files were modified by this hook

File deploy/docker-compose.yml is not pretty-formatted
Fixing file deploy/docker-compose.yml
File .github/workflows/tests.yml is not pretty-formatted
Fixing file .github/workflows/tests.yml
File .pre-commit-config.yaml is not pretty-formatted
Fixing file .pre-commit-config.yaml
File deploy/kube/app.yml is not pretty-formatted
Fixing file deploy/kube/app.yml
File deploy/kube/db.yml is not pretty-formatted
Fixing file deploy/kube/db.yml
File deploy/kube/redis.yml is not pretty-formatted
Fixing file deploy/kube/redis.yml

Format with Black........................................................Failed
- hook id: black
- files were modified by this hook

reformatted fatemplate/web/api/dummy/__init__.py
reformatted fatemplate/web/lifetime.py

All done! ✨ 🍰 ✨
2 files reformatted, 2 files left unchanged.
reformatted fatemplate/settings.py

All done! ✨ 🍰 ✨
1 file reformatted, 3 files left unchanged.
reformatted fatemplate/db/migrations/env.py

All done! ✨ 🍰 ✨
1 file reformatted, 3 files left unchanged.
reformatted fatemplate/web/api/monitoring/views.py

All done! ✨ 🍰 ✨
1 file reformatted, 3 files left unchanged.
reformatted fatemplate/web/api/monitoring/__init__.py
reformatted fatemplate/tests/test_fatemplate.py

All done! ✨ 🍰 ✨
2 files reformatted, 2 files left unchanged.
reformatted fatemplate/web/api/docs/views.py
reformatted fatemplate/tests/test_redis.py

All done! ✨ 🍰 ✨
2 files reformatted, 2 files left unchanged.
reformatted fatemplate/web/application.py

All done! ✨ 🍰 ✨
1 file reformatted, 3 files left unchanged.
reformatted fatemplate/conftest.py

All done! ✨ 🍰 ✨
1 file reformatted, 3 files left unchanged.
reformatted fatemplate/web/api/docs/__init__.py
reformatted fatemplate/web/api/echo/__init__.py
reformatted fatemplate/db/utils.py

All done! ✨ 🍰 ✨
3 files reformatted, 1 file left unchanged.
reformatted fatemplate/tests/test_echo.py
reformatted fatemplate/tests/test_dummy.py

All done! ✨ 🍰 ✨
2 files reformatted, 2 files left unchanged.
reformatted fatemplate/web/api/redis/__init__.py

All done! ✨ 🍰 ✨
1 file reformatted, 1 file left unchanged.

autoflake................................................................Failed
- hook id: autoflake
- files were modified by this hook
isort....................................................................Failed
- hook id: isort
- files were modified by this hook

Fixing /home/mano/Desktop/test/fatemplate/fatemplate/web/lifetime.py
Fixing /home/mano/Desktop/test/fatemplate/fatemplate/tests/test_fatemplate.py
Fixing /home/mano/Desktop/test/fatemplate/fatemplate/tests/test_redis.py
Fixing /home/mano/Desktop/test/fatemplate/fatemplate/web/api/docs/views.py
Fixing /home/mano/Desktop/test/fatemplate/fatemplate/web/application.py
Fixing /home/mano/Desktop/test/fatemplate/fatemplate/conftest.py
Fixing /home/mano/Desktop/test/fatemplate/fatemplate/db/dao/dummy_dao.py
Fixing /home/mano/Desktop/test/fatemplate/fatemplate/web/api/docs/__init__.py
Fixing /home/mano/Desktop/test/fatemplate/fatemplate/db/utils.py
Fixing /home/mano/Desktop/test/fatemplate/fatemplate/tests/test_echo.py
Fixing /home/mano/Desktop/test/fatemplate/fatemplate/tests/test_dummy.py
Fixing /home/mano/Desktop/test/fatemplate/fatemplate/web/api/router.py

Check with Flake8........................................................Passed
Validate types with MyPy.................................................Passed
Remove usless noqa.......................................................Failed
- hook id: yesqa
- exit code: 1
- files were modified by this hook

Rewriting fatemplate/conftest.py

Check python ast.........................................................Passed
Trim Trailing Whitespace.................................................Passed
Check Toml...............................................................Passed
Fix End of Files.........................................................Passed
Add trailing commas......................................................Passed
Pretty format YAML.......................................................Passed
Format with Black........................................................Passed
autoflake................................................................Passed
isort....................................................................Passed
Check with Flake8........................................................Passed
Validate types with MyPy.................................................Passed
Remove usless noqa.......................................................Passed
hint: The '.git/hooks/commit-msg' hook was ignored because it's not set as executable.
hint: You can disable this warning with `git config advice.ignoredHook false`.
Project successfully generated. You can read information about usage in README.md

Building and then running with docker-compose the server is unreachable on localhost:8000 or 0.0.0.0:8000:

Sending build context to Docker daemon  777.3kB
Step 1/9 : FROM python:3.9.6-slim-buster
 ---> e18d3088c48c
Step 2/9 : RUN pip install poetry==1.1.8
 ---> Using cache
 ---> 1c68c5835316
Step 3/9 : RUN poetry config virtualenvs.create false
 ---> Using cache
 ---> 738969c2c64f
Step 4/9 : COPY pyproject.toml poetry.lock /app/src/
 ---> Using cache
 ---> b6024b866e35
Step 5/9 : WORKDIR /app/src
 ---> Using cache
 ---> fb117ba5c837
Step 6/9 : RUN poetry install
 ---> Using cache
 ---> efe0dcf90249
Step 7/9 : COPY . /app/src/
 ---> Using cache
 ---> 298c2bf3d8d7
Step 8/9 : RUN poetry install
 ---> Using cache
 ---> 39f4a9b1f1ad
Step 9/9 : CMD ["/usr/local/bin/python", "-m", "fatemplate"]
 ---> Using cache
 ---> e0af20beef2a
Successfully built e0af20beef2a
Successfully tagged fatemplate:latest
[+] Running 6/6
 ⠿ Network fatemplate_default       Created                                                                                                                                           0.0s
 ⠿ Volume "fatemplate-db-data"      Created                                                                                                                                           0.0s
 ⠿ Container fatemplate-redis-1     Created                                                                                                                                           0.1s
 ⠿ Container fatemplate-db-1        Created                                                                                                                                           0.1s
 ⠿ Container fatemplate-migrator-1  Created                                                                                                                                           0.2s
 ⠿ Container fatemplate-api-1       Created                                                                                                                                           0.1s
Attaching to fatemplate-api-1, fatemplate-db-1, fatemplate-migrator-1, fatemplate-redis-1
fatemplate-db-1        | The files belonging to this database system will be owned by user "postgres".
fatemplate-db-1        | This user must also own the server process.
fatemplate-db-1        | 
fatemplate-db-1        | The database cluster will be initialized with locale "en_US.utf8".
fatemplate-db-1        | The default database encoding has accordingly been set to "UTF8".
fatemplate-db-1        | The default text search configuration will be set to "english".
fatemplate-db-1        | 
fatemplate-db-1        | Data page checksums are disabled.
fatemplate-db-1        | 
fatemplate-db-1        | fixing permissions on existing directory /var/lib/postgresql/data ... ok
fatemplate-db-1        | creating subdirectories ... ok
fatemplate-db-1        | selecting dynamic shared memory implementation ... posix
fatemplate-db-1        | selecting default max_connections ... 100
fatemplate-db-1        | selecting default shared_buffers ... 128MB
fatemplate-db-1        | selecting default time zone ... Etc/UTC
fatemplate-db-1        | creating configuration files ... ok
fatemplate-redis-1     | redis 16:46:16.54 
fatemplate-redis-1     | redis 16:46:16.54 Welcome to the Bitnami redis container
fatemplate-redis-1     | redis 16:46:16.54 Subscribe to project updates by watching https://github.com/bitnami/bitnami-docker-redis
fatemplate-redis-1     | redis 16:46:16.54 Submit issues and feature requests at https://github.com/bitnami/bitnami-docker-redis/issues
fatemplate-redis-1     | redis 16:46:16.54 
fatemplate-redis-1     | redis 16:46:16.54 INFO  ==> ** Starting Redis setup **
fatemplate-redis-1     | redis 16:46:16.55 WARN  ==> You set the environment variable ALLOW_EMPTY_PASSWORD=yes. For safety reasons, do not use this flag in a production environment.
fatemplate-redis-1     | redis 16:46:16.55 INFO  ==> Initializing Redis
fatemplate-redis-1     | redis 16:46:16.55 INFO  ==> Setting Redis config file
fatemplate-redis-1     | redis 16:46:16.56 INFO  ==> ** Redis setup finished! **
fatemplate-redis-1     | 
fatemplate-redis-1     | redis 16:46:16.57 INFO  ==> ** Starting Redis **
fatemplate-redis-1     | 1:C 16 Apr 2022 16:46:16.579 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
fatemplate-redis-1     | 1:C 16 Apr 2022 16:46:16.579 # Redis version=6.2.5, bits=64, commit=00000000, modified=0, pid=1, just started
fatemplate-redis-1     | 1:C 16 Apr 2022 16:46:16.579 # Configuration loaded
fatemplate-redis-1     | 1:M 16 Apr 2022 16:46:16.579 * monotonic clock: POSIX clock_gettime
fatemplate-redis-1     | 1:M 16 Apr 2022 16:46:16.580 * Running mode=standalone, port=6379.
fatemplate-redis-1     | 1:M 16 Apr 2022 16:46:16.580 # Server initialized
fatemplate-redis-1     | 1:M 16 Apr 2022 16:46:16.580 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
fatemplate-redis-1     | 1:M 16 Apr 2022 16:46:16.580 * Ready to accept connections
fatemplate-db-1        | running bootstrap script ... ok
fatemplate-db-1        | performing post-bootstrap initialization ... ok
fatemplate-db-1        | syncing data to disk ... ok
fatemplate-db-1        | 
fatemplate-db-1        | 
fatemplate-db-1        | Success. You can now start the database server using:
fatemplate-db-1        | 
fatemplate-db-1        |     pg_ctl -D /var/lib/postgresql/data -l logfile start
fatemplate-db-1        | 
fatemplate-db-1        | initdb: warning: enabling "trust" authentication for local connections
fatemplate-db-1        | You can change this by editing pg_hba.conf or using the option -A, or
fatemplate-db-1        | --auth-local and --auth-host, the next time you run initdb.
fatemplate-db-1        | waiting for server to start....2022-04-16 16:46:17.100 UTC [47] LOG:  starting PostgreSQL 13.4 (Debian 13.4-1.pgdg100+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 8.3.0-6) 8.3.0, 64-bit
fatemplate-db-1        | 2022-04-16 16:46:17.102 UTC [47] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
fatemplate-db-1        | 2022-04-16 16:46:17.112 UTC [48] LOG:  database system was shut down at 2022-04-16 16:46:16 UTC
fatemplate-db-1        | 2022-04-16 16:46:17.118 UTC [47] LOG:  database system is ready to accept connections
fatemplate-db-1        |  done
fatemplate-db-1        | server started
fatemplate-db-1        | CREATE DATABASE
fatemplate-db-1        | 
fatemplate-db-1        | 
fatemplate-db-1        | /usr/local/bin/docker-entrypoint.sh: ignoring /docker-entrypoint-initdb.d/*
fatemplate-db-1        | 
fatemplate-db-1        | 2022-04-16 16:46:17.322 UTC [47] LOG:  received fast shutdown request
fatemplate-db-1        | waiting for server to shut down....2022-04-16 16:46:17.324 UTC [47] LOG:  aborting any active transactions
fatemplate-db-1        | 2022-04-16 16:46:17.325 UTC [47] LOG:  background worker "logical replication launcher" (PID 54) exited with exit code 1
fatemplate-db-1        | 2022-04-16 16:46:17.325 UTC [49] LOG:  shutting down
fatemplate-db-1        | 2022-04-16 16:46:17.339 UTC [47] LOG:  database system is shut down
fatemplate-db-1        |  done
fatemplate-db-1        | server stopped
fatemplate-db-1        | 
fatemplate-db-1        | PostgreSQL init process complete; ready for start up.
fatemplate-db-1        | 
fatemplate-db-1        | 2022-04-16 16:46:17.439 UTC [1] LOG:  starting PostgreSQL 13.4 (Debian 13.4-1.pgdg100+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 8.3.0-6) 8.3.0, 64-bit
fatemplate-db-1        | 2022-04-16 16:46:17.439 UTC [1] LOG:  listening on IPv4 address "0.0.0.0", port 5432
fatemplate-db-1        | 2022-04-16 16:46:17.439 UTC [1] LOG:  listening on IPv6 address "::", port 5432
fatemplate-db-1        | 2022-04-16 16:46:17.442 UTC [1] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
fatemplate-db-1        | 2022-04-16 16:46:17.449 UTC [75] LOG:  database system was shut down at 2022-04-16 16:46:17 UTC
fatemplate-db-1        | 2022-04-16 16:46:17.454 UTC [1] LOG:  database system is ready to accept connections
fatemplate-api-1       | INFO:     Will watch for changes in these directories: ['/app/src']
fatemplate-api-1       | INFO:     Uvicorn running on http://0.0.0.0:8000 (Press CTRL+C to quit)
fatemplate-api-1       | INFO:     Started reloader process [1] using statreload
fatemplate-migrator-1  | INFO  [alembic.runtime.migration] Context impl PostgresqlImpl.
fatemplate-migrator-1  | INFO  [alembic.runtime.migration] Will assume transactional DDL.
fatemplate-migrator-1  | INFO  [alembic.runtime.migration] Running upgrade  -> 819cbf6e030b, Initial migration.
fatemplate-migrator-1  | INFO  [alembic.runtime.migration] Running upgrade 819cbf6e030b -> 2b7380507a71, Created Dummy Model.
fatemplate-api-1       | INFO:     Started server process [8]
fatemplate-api-1       | INFO:     Waiting for application startup.
fatemplate-migrator-1 exited with code 0
fatemplate-api-1       | INFO:     Application startup complete.

What default configuration are you testing with @s3rius that I could try, or more likely -- I am performing an error at some point?

Add loguru logging

Loguru is an easy to use and configure logger.

I would be super nice to have it in a template.

Add a reverse proxy ?

Hi there !

Since this template is very complete and handle a lot of things, I was wondering if it could be a good idea to add an option to set up a reverse proxy (Nginx or Traefik or both).

Since anyway, it's most likely that a lot of people will go through this phase and each time, it's kind of a pain.
And now we have solutions to automatically generate SSL certificates with LetsEncrypt, so I was thinking about this.

What do you think ?

.gitlab-ci.yml doesn't run the CI properly when configured with postgres

Hello there !

After I generated the .gitlab-ci.yml, I just pushed the newly created project to Gitlab and had few troubles.

The first one : Because of the tags, the gitlab's runners weren't able to pick up the jobs, and they were in a PENDING state undefinitely.

The second one : The values specified in the .gitlab-ci.yml file, in the "VARIABLES" section are not valid to run properly on Postgres.

Also, changing the variables in the "VARIABLES" section did not changed anything since the configuration is not loaded using environment variables.

I will create a PR for this !

Thanks for your time.

Add Sentry as Exception tracking

Hi there, I thought it could be a good idea to add Sentry as an optional service.

I think a lot of people use this solution to monitor their exceptions. What do you think ?

Add healthcheck for application.

We has the /health endpoint, but it doesn't used at all.

It must be fixed by adding healthcheck in docker-compose and in kubernetes config.

Request object isn't passed as argument

Thanks for this package. I have created graphql app using template but getting below error. It seems fastapi doesn't pass request object.

ERROR:    Exception in ASGI application
Traceback (most recent call last):
  File "/Users/test/Library/Caches/pypoetry/virtualenvs/fastapi-graphql-practice-1UuEp-7G-py3.10/lib/python3.10/site-packages/uvicorn/protocols/websockets/websockets_impl.py", line 184, in run_asgi
    result = await self.app(self.scope, self.asgi_receive, self.asgi_send)
  File "/Users/test/Library/Caches/pypoetry/virtualenvs/fastapi-graphql-practice-1UuEp-7G-py3.10/lib/python3.10/site-packages/uvicorn/middleware/proxy_headers.py", line 75, in __call__
    return await self.app(scope, receive, send)
  File "/Users/test/Library/Caches/pypoetry/virtualenvs/fastapi-graphql-practice-1UuEp-7G-py3.10/lib/python3.10/site-packages/fastapi/applications.py", line 261, in __call__
    await super().__call__(scope, receive, send)
  File "/Users/test/Library/Caches/pypoetry/virtualenvs/fastapi-graphql-practice-1UuEp-7G-py3.10/lib/python3.10/site-packages/starlette/applications.py", line 112, in __call__
    await self.middleware_stack(scope, receive, send)
  File "/Users/test/Library/Caches/pypoetry/virtualenvs/fastapi-graphql-practice-1UuEp-7G-py3.10/lib/python3.10/site-packages/starlette/middleware/errors.py", line 146, in __call__
    await self.app(scope, receive, send)
  File "/Users/test/Library/Caches/pypoetry/virtualenvs/fastapi-graphql-practice-1UuEp-7G-py3.10/lib/python3.10/site-packages/starlette/exceptions.py", line 58, in __call__
    await self.app(scope, receive, send)
  File "/Users/test/Library/Caches/pypoetry/virtualenvs/fastapi-graphql-practice-1UuEp-7G-py3.10/lib/python3.10/site-packages/fastapi/middleware/asyncexitstack.py", line 21, in __call__
    raise e
  File "/Users/test/Library/Caches/pypoetry/virtualenvs/fastapi-graphql-practice-1UuEp-7G-py3.10/lib/python3.10/site-packages/fastapi/middleware/asyncexitstack.py", line 18, in __call__
    await self.app(scope, receive, send)
  File "/Users/test/Library/Caches/pypoetry/virtualenvs/fastapi-graphql-practice-1UuEp-7G-py3.10/lib/python3.10/site-packages/starlette/routing.py", line 656, in __call__
    await route.handle(scope, receive, send)
  File "/Users/test/Library/Caches/pypoetry/virtualenvs/fastapi-graphql-practice-1UuEp-7G-py3.10/lib/python3.10/site-packages/starlette/routing.py", line 315, in handle
    await self.app(scope, receive, send)
  File "/Users/test/Library/Caches/pypoetry/virtualenvs/fastapi-graphql-practice-1UuEp-7G-py3.10/lib/python3.10/site-packages/starlette/routing.py", line 77, in app
    await func(session)
  File "/Users/test/Library/Caches/pypoetry/virtualenvs/fastapi-graphql-practice-1UuEp-7G-py3.10/lib/python3.10/site-packages/fastapi/routing.py", line 264, in app
    solved_result = await solve_dependencies(
  File "/Users/test/Library/Caches/pypoetry/virtualenvs/fastapi-graphql-practice-1UuEp-7G-py3.10/lib/python3.10/site-packages/fastapi/dependencies/utils.py", line 498, in solve_dependencies
    solved_result = await solve_dependencies(
  File "/Users/test/Library/Caches/pypoetry/virtualenvs/fastapi-graphql-practice-1UuEp-7G-py3.10/lib/python3.10/site-packages/fastapi/dependencies/utils.py", line 498, in solve_dependencies
    solved_result = await solve_dependencies(
  File "/Users/test/Library/Caches/pypoetry/virtualenvs/fastapi-graphql-practice-1UuEp-7G-py3.10/lib/python3.10/site-packages/fastapi/dependencies/utils.py", line 498, in solve_dependencies
    solved_result = await solve_dependencies(
  File "/Users/test/Library/Caches/pypoetry/virtualenvs/fastapi-graphql-practice-1UuEp-7G-py3.10/lib/python3.10/site-packages/fastapi/dependencies/utils.py", line 523, in solve_dependencies
    solved = await solve_generator(
  File "/Users/test/Library/Caches/pypoetry/virtualenvs/fastapi-graphql-practice-1UuEp-7G-py3.10/lib/python3.10/site-packages/fastapi/dependencies/utils.py", line 443, in solve_generator
    cm = asynccontextmanager(call)(**sub_values)
  File "/Users/test/.pyenv/versions/3.10.2/lib/python3.10/contextlib.py", line 314, in helper
    return _AsyncGeneratorContextManager(func, args, kwds)
  File "/Users/test/.pyenv/versions/3.10.2/lib/python3.10/contextlib.py", line 103, in __init__
    self.gen = func(*args, **kwds)
TypeError: get_db_session() missing 1 required positional argument: 'request'
INFO:     connection open
INFO:     connection closed

Add helm configuration.

Helm is a modern way of configuring systems.
It might be a little tricky to embed template into template, but helm config would be a really good feature.

Update README to make it more helpful.

Today @sorasful and I found out that documentation about CI\CD of a project might be confusing and this problem led us to this issue: #56.

So here I want to discuss what to add in README.md of a generated project to make it more helpful.

Add docker wrapper.

It's super nice if people can use your project with only one command. So why we don't have a Docker Image with fastapi-template inside?

It must be fixed.

Generation of .gitlab-ci doesn't work

Hello there !

I just tried this project that looks really awesome! And I noticed that despite checking the "Gitlab-ci" box when selecting CI, it doesn't happen. The rest of the options seems to be working nicely but I got this :

image

So, when looking a little bit, I found the problem was during the declaration of the possibles values in input_models we have this :

@enum.unique
class CIType(enum.Enum):
    none = "none"
    gitlab_ci = "gitlab"
    github = "github"

But when looking at the conditional_files.json we check for gitlab_ci and not just gitlab:

    "Gitlab CI": {
        "enabled": "{{cookiecutter.ci_type == 'gitlab_ci'}}",
        "resources": [
            ".gitlab-ci.yml"
        ]
    },

And after updating it, it now works. I will submit a PR for this.

Add optional monitoring solution (Prometheus, Datadog ...)

Hello there !

I thought it would be a nice complement to add one or multiple services to be able to monitor the code, the calls, the performances.

I know that a lot of people use Prometheus, so I thought it could be nice. But I also know that DataDog also provides methods to monitor the code.

What do you think ?

Add Jaeger integration.

Jaeger is an easy to use request tracer for distributed systems. It's super useful for microservices.

Fix postgres error in docker-compose.

We need to change healthcheck command.

Because healthcheck command is incorrect postgres is constantly write in log "FATAL: role "root" does not exist".

It must be fixed by providing different healthcheck command.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.