Compare commits
19 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 078749a586 | |||
| 24d1b199ea | |||
| 46906cc333 | |||
| 0c0cc63d59 | |||
| 280882f515 | |||
| 21443a266a | |||
| ec4eaa1f03 | |||
| 0e3c9fb52e | |||
| cc6ca5982c | |||
| c9fd066c31 | |||
| 6799b0e7b1 | |||
| 50110a54b7 | |||
| 28ad343759 | |||
| 06c6dbed5c | |||
| 228a83c355 | |||
| fbfedd4e8f | |||
| 6a8db71537 | |||
| cb180b511f | |||
| 556b43b424 |
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"mcpServers": {
|
||||||
|
"gitea": {
|
||||||
|
"type": "http",
|
||||||
|
"url": "https://git-mcp.farh.net/mcp",
|
||||||
|
"headers": {
|
||||||
|
"Authorization": "Bearer ${GITEA_TOKEN}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -11,6 +11,7 @@ engine = create_async_engine(
|
|||||||
echo=False,
|
echo=False,
|
||||||
pool_size=10,
|
pool_size=10,
|
||||||
max_overflow=20,
|
max_overflow=20,
|
||||||
|
pool_timeout=30,
|
||||||
pool_pre_ping=True,
|
pool_pre_ping=True,
|
||||||
pool_recycle=3600,
|
pool_recycle=3600,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,16 +1,23 @@
|
|||||||
"""Health check and error metrics endpoints."""
|
"""Health check and error metrics endpoints."""
|
||||||
|
|
||||||
from fastapi import APIRouter, Depends
|
from fastapi import APIRouter, Depends
|
||||||
|
from sqlalchemy import text
|
||||||
|
from sqlalchemy.ext.asyncio import AsyncSession
|
||||||
|
|
||||||
from cartsnitch_api.auth.dependencies import verify_service_key
|
from cartsnitch_api.auth.dependencies import verify_service_key
|
||||||
|
from cartsnitch_api.database import get_db
|
||||||
from cartsnitch_api.middleware.error_handler import get_error_monitor
|
from cartsnitch_api.middleware.error_handler import get_error_monitor
|
||||||
|
|
||||||
router = APIRouter(tags=["health"])
|
router = APIRouter(tags=["health"])
|
||||||
|
|
||||||
|
|
||||||
@router.get("/health")
|
@router.get("/health")
|
||||||
async def health():
|
async def health(db: AsyncSession = Depends(get_db)):
|
||||||
return {"status": "ok"}
|
try:
|
||||||
|
await db.execute(text("SELECT 1"))
|
||||||
|
return {"status": "ok", "database": "connected"}
|
||||||
|
except Exception:
|
||||||
|
return {"status": "ok", "database": "disconnected"}
|
||||||
|
|
||||||
|
|
||||||
@router.get("/internal/error-stats", dependencies=[Depends(verify_service_key)])
|
@router.get("/internal/error-stats", dependencies=[Depends(verify_service_key)])
|
||||||
|
|||||||
+11
-3
@@ -53,6 +53,10 @@ def disable_rate_limiting():
|
|||||||
def engine():
|
def engine():
|
||||||
"""Sync in-memory SQLite engine for model unit tests."""
|
"""Sync in-memory SQLite engine for model unit tests."""
|
||||||
eng = create_engine("sqlite:///:memory:")
|
eng = create_engine("sqlite:///:memory:")
|
||||||
|
from cartsnitch_api.models.user import User
|
||||||
|
|
||||||
|
col = User.__table__.columns["email_inbound_token"]
|
||||||
|
col.server_default = None
|
||||||
Base.metadata.create_all(eng)
|
Base.metadata.create_all(eng)
|
||||||
yield eng
|
yield eng
|
||||||
eng.dispose()
|
eng.dispose()
|
||||||
@@ -77,6 +81,9 @@ async def db_engine():
|
|||||||
cursor.close()
|
cursor.close()
|
||||||
|
|
||||||
async with engine.begin() as conn:
|
async with engine.begin() as conn:
|
||||||
|
from cartsnitch_api.models.user import User
|
||||||
|
|
||||||
|
User.__table__.columns["email_inbound_token"].server_default = None
|
||||||
await conn.run_sync(Base.metadata.create_all)
|
await conn.run_sync(Base.metadata.create_all)
|
||||||
# Create Better-Auth tables (not managed by SQLAlchemy models)
|
# Create Better-Auth tables (not managed by SQLAlchemy models)
|
||||||
await conn.execute(
|
await conn.execute(
|
||||||
@@ -178,9 +185,9 @@ async def _create_test_user_and_session(
|
|||||||
await conn.execute(
|
await conn.execute(
|
||||||
text(
|
text(
|
||||||
"INSERT INTO users (id, email, hashed_password, display_name, "
|
"INSERT INTO users (id, email, hashed_password, display_name, "
|
||||||
"email_verified, created_at, updated_at) "
|
"email_verified, email_inbound_token, created_at, updated_at) "
|
||||||
"VALUES (:id, :email, :hashed_password, :display_name, :email_verified, "
|
"VALUES (:id, :email, :hashed_password, :display_name, "
|
||||||
":created_at, :updated_at)"
|
":email_verified, :email_inbound_token, :created_at, :updated_at)"
|
||||||
),
|
),
|
||||||
{
|
{
|
||||||
"id": user_id,
|
"id": user_id,
|
||||||
@@ -188,6 +195,7 @@ async def _create_test_user_and_session(
|
|||||||
"hashed_password": "not-used-with-better-auth",
|
"hashed_password": "not-used-with-better-auth",
|
||||||
"display_name": display_name,
|
"display_name": display_name,
|
||||||
"email_verified": False,
|
"email_verified": False,
|
||||||
|
"email_inbound_token": secrets.token_urlsafe(16),
|
||||||
"created_at": now,
|
"created_at": now,
|
||||||
"updated_at": now,
|
"updated_at": now,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -139,8 +139,8 @@ async def test_expired_session_rejected(client, db_engine):
|
|||||||
await conn.execute(
|
await conn.execute(
|
||||||
text(
|
text(
|
||||||
"INSERT INTO users (id, email, hashed_password, display_name, "
|
"INSERT INTO users (id, email, hashed_password, display_name, "
|
||||||
"email_verified, created_at, updated_at) "
|
"email_verified, email_inbound_token, created_at, updated_at) "
|
||||||
"VALUES (:id, :email, :hp, :dn, :ev, :ca, :ua)"
|
"VALUES (:id, :email, :hp, :dn, :ev, :token, :ca, :ua)"
|
||||||
),
|
),
|
||||||
{
|
{
|
||||||
"id": user_id,
|
"id": user_id,
|
||||||
@@ -148,6 +148,7 @@ async def test_expired_session_rejected(client, db_engine):
|
|||||||
"hp": "unused",
|
"hp": "unused",
|
||||||
"dn": "Expired User",
|
"dn": "Expired User",
|
||||||
"ev": False,
|
"ev": False,
|
||||||
|
"token": secrets.token_urlsafe(16),
|
||||||
"ca": now,
|
"ca": now,
|
||||||
"ua": now,
|
"ua": now,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -66,8 +66,8 @@ class TestSessionValidation:
|
|||||||
await conn.execute(
|
await conn.execute(
|
||||||
text(
|
text(
|
||||||
"INSERT INTO users (id, email, hashed_password, display_name, "
|
"INSERT INTO users (id, email, hashed_password, display_name, "
|
||||||
"email_verified, created_at, updated_at) "
|
"email_verified, email_inbound_token, created_at, updated_at) "
|
||||||
"VALUES (:id, :email, :hp, :dn, :ev, :ca, :ua)"
|
"VALUES (:id, :email, :hp, :dn, :ev, :token, :ca, :ua)"
|
||||||
),
|
),
|
||||||
{
|
{
|
||||||
"id": user_id,
|
"id": user_id,
|
||||||
@@ -75,6 +75,7 @@ class TestSessionValidation:
|
|||||||
"hp": "unused",
|
"hp": "unused",
|
||||||
"dn": "Expired User",
|
"dn": "Expired User",
|
||||||
"ev": False,
|
"ev": False,
|
||||||
|
"token": secrets.token_urlsafe(16),
|
||||||
"ca": now,
|
"ca": now,
|
||||||
"ua": now,
|
"ua": now,
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user