Save test environment changes

This commit is contained in:
2026-02-04 21:58:57 +00:00
parent 5dd5692d83
commit a57d5333d4
67 changed files with 1603 additions and 239 deletions

View File

@@ -1,45 +1,50 @@
import os
from contextlib import asynccontextmanager
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from sqlalchemy import text
import os
from app.api.v1.api import api_router
from app.api.v2.auth import router as auth_v2_router
from app.models import Base
from app.db.base import Base
from app.db.session import engine
@asynccontextmanager
async def lifespan(app: FastAPI):
from app.db.session import engine
# Séma és alap táblák ellenőrzése indításkor
async with engine.begin() as conn:
await conn.execute(text("CREATE SCHEMA IF NOT EXISTS data"))
# Base.metadata.create_all helyett javasolt az Alembic,
# de fejlesztési fázisban a run_sync biztonságos
await conn.run_sync(Base.metadata.create_all)
yield
await engine.dispose()
app = FastAPI(
title="Traffic Ecosystem SuperApp 2.0",
version="2.0.0",
openapi_url="/api/v2/openapi.json",
title="Service Finder API",
version="1.0.0",
docs_url="/docs",
openapi_url="/api/v1/openapi.json",
lifespan=lifespan
)
# BIZTONSÁG: CORS beállítások .env-ből
# Ha nincs megadva, csak a localhost-ot engedi
origins = os.getenv("CORS_ORIGINS", "http://localhost:3000").split(",")
app.add_middleware(
CORSMiddleware,
allow_origins=[
"http://192.168.100.43:3000", # A szerver címe a böngészőben
"http://localhost:3000", # Helyi teszteléshez
],
allow_origins=origins,
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
# ÚTVONALAK INTEGRÁCIÓJA
# ÚTVONALAK KONSZOLIDÁCIÓJA (V2 törölve, minden a V1 alatt)
app.include_router(api_router, prefix="/api/v1")
app.include_router(auth_v2_router, prefix="/api/v2/auth")
@app.get("/", tags=["health"])
async def root():
return {"status": "online", "version": "2.0.0", "docs": "/docs"}
return {
"status": "online",
"version": "1.0.0",
"environment": os.getenv("ENV", "production")
}