Archived
Подключены модели и auth routers
This commit is contained in:
+13
-4
@@ -4,7 +4,10 @@ from fastapi import FastAPI
|
|||||||
from fastapi.middleware.cors import CORSMiddleware
|
from fastapi.middleware.cors import CORSMiddleware
|
||||||
from sqlalchemy import create_engine, text
|
from sqlalchemy import create_engine, text
|
||||||
|
|
||||||
|
from . import models
|
||||||
from .config import settings
|
from .config import settings
|
||||||
|
from .database import Base, engine
|
||||||
|
from .routers import admin, auth
|
||||||
|
|
||||||
logging.basicConfig(
|
logging.basicConfig(
|
||||||
level=logging.INFO,
|
level=logging.INFO,
|
||||||
@@ -14,7 +17,7 @@ logger = logging.getLogger(__name__)
|
|||||||
|
|
||||||
app = FastAPI(
|
app = FastAPI(
|
||||||
title="Proxmox VPS Panel Secure",
|
title="Proxmox VPS Panel Secure",
|
||||||
version="1.0.0",
|
version="1.1.0",
|
||||||
)
|
)
|
||||||
|
|
||||||
origins = [item.strip() for item in settings.allow_origins.split(",") if item.strip()]
|
origins = [item.strip() for item in settings.allow_origins.split(",") if item.strip()]
|
||||||
@@ -29,6 +32,12 @@ app.add_middleware(
|
|||||||
allow_headers=["Authorization", "Content-Type"],
|
allow_headers=["Authorization", "Content-Type"],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Временное создание базовых таблиц до добавления Alembic-миграций.
|
||||||
|
# После появления миграций этот вызов должен быть удалён.
|
||||||
|
Base.metadata.create_all(bind=engine)
|
||||||
|
app.include_router(auth.router)
|
||||||
|
app.include_router(admin.router)
|
||||||
|
|
||||||
|
|
||||||
@app.get("/health")
|
@app.get("/health")
|
||||||
def health() -> dict[str, str]:
|
def health() -> dict[str, str]:
|
||||||
@@ -39,10 +48,10 @@ def health() -> dict[str, str]:
|
|||||||
@app.get("/health/ready")
|
@app.get("/health/ready")
|
||||||
def readiness() -> dict[str, str]:
|
def readiness() -> dict[str, str]:
|
||||||
"""Проверяет доступность критичной зависимости PostgreSQL."""
|
"""Проверяет доступность критичной зависимости PostgreSQL."""
|
||||||
engine = create_engine(settings.database_url, pool_pre_ping=True)
|
check_engine = create_engine(settings.database_url, pool_pre_ping=True)
|
||||||
try:
|
try:
|
||||||
with engine.connect() as connection:
|
with check_engine.connect() as connection:
|
||||||
connection.execute(text("SELECT 1"))
|
connection.execute(text("SELECT 1"))
|
||||||
finally:
|
finally:
|
||||||
engine.dispose()
|
check_engine.dispose()
|
||||||
return {"status": "ready"}
|
return {"status": "ready"}
|
||||||
|
|||||||
Reference in New Issue
Block a user