All checks were successful
CI / test (push) Successful in 9m2s
Security hardening: - Added IP/user rate limiting with Redis-backed counters and fail-open behavior. - Added message anti-spam controls (per-chat rate + duplicate cooldown). - Implemented refresh token rotation with JTI tracking and revoke support. Notification pipeline: - Added Celery app and async notification tasks for mention/offline delivery. - Added Redis-based presence tracking and integrated it into realtime connect/disconnect. - Added notification dispatch from message flow and notifications listing endpoint. Quality gates and CI: - Added pytest async integration tests for auth and chat/message lifecycle. - Added pytest config, test fixtures, and GitHub Actions CI workflow. - Fixed bcrypt/passlib compatibility by pinning bcrypt version. - Documented worker and quality-gate commands in README.
46 lines
1.6 KiB
Python
46 lines
1.6 KiB
Python
from contextlib import asynccontextmanager
|
|
|
|
from fastapi import FastAPI
|
|
|
|
from app.auth.router import router as auth_router
|
|
from app.chats.router import router as chats_router
|
|
from app.config.settings import settings
|
|
from app.database import models # noqa: F401
|
|
from app.database.base import Base
|
|
from app.database.session import engine
|
|
from app.media.router import router as media_router
|
|
from app.messages.router import router as messages_router
|
|
from app.notifications.router import router as notifications_router
|
|
from app.realtime.router import router as realtime_router
|
|
from app.realtime.service import realtime_gateway
|
|
from app.users.router import router as users_router
|
|
from app.utils.redis_client import close_redis_client
|
|
|
|
|
|
@asynccontextmanager
|
|
async def lifespan(_app: FastAPI):
|
|
await realtime_gateway.start()
|
|
if settings.auto_create_tables:
|
|
async with engine.begin() as conn:
|
|
await conn.run_sync(Base.metadata.create_all)
|
|
yield
|
|
await realtime_gateway.stop()
|
|
await close_redis_client()
|
|
|
|
|
|
app = FastAPI(title=settings.app_name, debug=settings.debug, lifespan=lifespan)
|
|
|
|
|
|
@app.get("/health", tags=["health"])
|
|
async def health() -> dict[str, str]:
|
|
return {"status": "ok"}
|
|
|
|
|
|
app.include_router(auth_router, prefix=settings.api_v1_prefix)
|
|
app.include_router(users_router, prefix=settings.api_v1_prefix)
|
|
app.include_router(chats_router, prefix=settings.api_v1_prefix)
|
|
app.include_router(messages_router, prefix=settings.api_v1_prefix)
|
|
app.include_router(media_router, prefix=settings.api_v1_prefix)
|
|
app.include_router(notifications_router, prefix=settings.api_v1_prefix)
|
|
app.include_router(realtime_router, prefix=settings.api_v1_prefix)
|