Version 0.2.0
All checks were successful
Run linters on applied template / Python 3.13 lint and build (push) Successful in 54s

Changes:
- add metrics dispencer
- add basic authentication dependency
- enable GZIP middleware
- add !env() example to deploy section
- update dependencies state attribute name
This commit is contained in:
2025-11-30 16:59:25 +03:00
parent afe5d882ac
commit 34c1347402
16 changed files with 180 additions and 74 deletions

View File

@@ -5,12 +5,13 @@ from contextlib import asynccontextmanager
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from fastapi.middleware.gzip import GZipMiddleware
from fastapi.openapi.docs import get_swagger_ui_html
from fastapi.responses import JSONResponse
from {{project_slug}}.config import {{ProjectName}}Config
from {{project_slug}}.db.connection.manager import PostgresConnectionManager
from {{project_slug}}.dependencies import connection_manager_dep, logger_dep
from {{project_slug}}.dependencies import connection_manager_dep, logger_dep, metrics_dep
from {{project_slug}}.exceptions.mapper import ExceptionMapper
from {{project_slug}}.handlers.debug import DebugException, DebugExceptionWithParams
from {{project_slug}}.middlewares.exception_handler import ExceptionHandlerMiddleware
@@ -90,11 +91,13 @@ def get_app(prefix: str = "/api") -> FastAPI:
allow_methods=app_config.app.cors.allow_methods,
allow_headers=app_config.app.cors.allow_headers,
)
application.add_middleware(GZipMiddleware, minimum_size=1000, compresslevel=5)
application.state.config = app_config
exception_mapper = _get_exception_mapper(app_config.app.debug)
metrics = init_metrics()
metrics_dep.init_dispencer(application, metrics)
urls_mapper = URLsMapper(app_config.observability.prometheus.urls_mapping)
application.add_middleware(