mirror of
https://github.com/grillazz/fastapi-sqlalchemy-asyncpg.git
synced 2025-08-26 16:40:40 +03:00
format code
This commit is contained in:
parent
7aace85eeb
commit
060bdb65fe
11
app/main.py
11
app/main.py
@ -20,6 +20,7 @@ from app.services.auth import AuthBearer
|
||||
logger = AppStructLogger().get_logger()
|
||||
templates = Jinja2Templates(directory=Path(__file__).parent.parent / "templates")
|
||||
|
||||
|
||||
@asynccontextmanager
|
||||
async def lifespan(app: FastAPI):
|
||||
app.redis = await get_redis()
|
||||
@ -30,12 +31,15 @@ async def lifespan(app: FastAPI):
|
||||
min_size=5,
|
||||
max_size=20,
|
||||
)
|
||||
await logger.ainfo("Postgres pool created", idle_size=app.postgres_pool.get_idle_size())
|
||||
await logger.ainfo(
|
||||
"Postgres pool created", idle_size=app.postgres_pool.get_idle_size()
|
||||
)
|
||||
yield
|
||||
finally:
|
||||
await app.redis.close()
|
||||
await app.postgres_pool.close()
|
||||
|
||||
|
||||
def create_app() -> FastAPI:
|
||||
app = FastAPI(
|
||||
title="Stuff And Nonsense API",
|
||||
@ -47,7 +51,9 @@ def create_app() -> FastAPI:
|
||||
app.include_router(shakespeare_router)
|
||||
app.include_router(user_router)
|
||||
app.include_router(ml_router, prefix="/v1/ml", tags=["ML"])
|
||||
app.include_router(health_router, prefix="/v1/public/health", tags=["Health, Public"])
|
||||
app.include_router(
|
||||
health_router, prefix="/v1/public/health", tags=["Health, Public"]
|
||||
)
|
||||
app.include_router(
|
||||
health_router,
|
||||
prefix="/v1/health",
|
||||
@ -61,6 +67,7 @@ def create_app() -> FastAPI:
|
||||
|
||||
return app
|
||||
|
||||
|
||||
app = create_app()
|
||||
|
||||
# --- Unused/experimental code and TODOs ---
|
||||
|
@ -9,6 +9,7 @@ config = ConfigDict(from_attributes=True)
|
||||
class RandomStuff(BaseModel):
|
||||
chaos: dict[str, Any] = Field(..., description="JSON data for chaos field")
|
||||
|
||||
|
||||
class StuffSchema(BaseModel):
|
||||
name: str = Field(
|
||||
title="",
|
||||
|
@ -30,7 +30,7 @@ class RotatingBytesLogger:
|
||||
lineno=0,
|
||||
msg=message.rstrip("\n"),
|
||||
args=(),
|
||||
exc_info=None
|
||||
exc_info=None,
|
||||
)
|
||||
|
||||
# Check if rotation is needed before emitting
|
||||
@ -78,7 +78,7 @@ class AppStructLogger(metaclass=SingletonMetaNoArgs):
|
||||
filename=_log_path,
|
||||
maxBytes=10 * 1024 * 1024, # 10MB
|
||||
backupCount=5,
|
||||
encoding="utf-8"
|
||||
encoding="utf-8",
|
||||
)
|
||||
structlog.configure(
|
||||
cache_logger_on_first_use=True,
|
||||
@ -90,7 +90,7 @@ class AppStructLogger(metaclass=SingletonMetaNoArgs):
|
||||
structlog.processors.TimeStamper(fmt="iso", utc=True),
|
||||
structlog.processors.JSONRenderer(serializer=orjson.dumps),
|
||||
],
|
||||
logger_factory=RotatingBytesLoggerFactory(_handler)
|
||||
logger_factory=RotatingBytesLoggerFactory(_handler),
|
||||
)
|
||||
self._logger = structlog.get_logger()
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user