mirror of
https://github.com/Significant-Gravitas/AutoGPT-Code-Ability.git
synced 2026-11-09 23:51:28 -10:00
* Introduce event logging, captured event: All non-Get HTTP operations. * Refactor routes.py on each API: removed redundant try-catch for unknown exception, use JsonResponse * Fix broken api_test.py due to DB seeding being removed. --------- Co-authored-by: majdyz <[email protected]>
68 lines
2.1 KiB
Python
68 lines
2.1 KiB
Python
import logging
|
|
import os
|
|
from contextlib import asynccontextmanager
|
|
|
|
import sentry_sdk
|
|
from fastapi import FastAPI
|
|
from prisma import Prisma
|
|
from sentry_sdk.integrations.aiohttp import AioHttpIntegration
|
|
from sentry_sdk.integrations.asyncio import AsyncioIntegration
|
|
from sentry_sdk.integrations.fastapi import FastApiIntegration
|
|
from sentry_sdk.integrations.starlette import StarletteIntegration
|
|
|
|
from codex.api import core_routes
|
|
from codex.deploy.routes import deployment_router
|
|
from codex.develop.routes import delivery_router
|
|
from codex.interview.routes import interview_router
|
|
from codex.middleware import RouterLoggingMiddleware
|
|
from codex.requirements.routes import spec_router
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
db_client = Prisma(auto_register=True)
|
|
|
|
|
|
@asynccontextmanager
|
|
async def lifespan(app: FastAPI):
|
|
await db_client.connect()
|
|
yield
|
|
await db_client.disconnect()
|
|
|
|
|
|
sentry_sdk.init(
|
|
dsn="https://0dc3905d347a9e4e81280f02deac234d@o4505260022104064.ingest.sentry.io/4506844882075648",
|
|
# Set traces_sample_rate to 1.0 to capture 100%
|
|
# of transactions for performance monitoring.
|
|
traces_sample_rate=1.0,
|
|
# Set profiles_sample_rate to 1.0 to profile 100%
|
|
# of sampled transactions.
|
|
# We recommend adjusting this value in production.
|
|
profiles_sample_rate=1.0,
|
|
enable_tracing=True,
|
|
environment=os.environ.get("ENV", default="dev").lower(),
|
|
integrations=[
|
|
StarletteIntegration(transaction_style="url"),
|
|
FastApiIntegration(transaction_style="url"),
|
|
AsyncioIntegration(),
|
|
AioHttpIntegration(),
|
|
],
|
|
)
|
|
app = FastAPI(
|
|
title="Codex",
|
|
description=(
|
|
"Codex is a platform for creating, deploying, and managing web applications."
|
|
),
|
|
summary="Codex API",
|
|
version="0.1",
|
|
lifespan=lifespan,
|
|
)
|
|
|
|
|
|
app.include_router(core_routes, prefix="/api/v1")
|
|
app.include_router(interview_router, prefix="/api/v1")
|
|
app.include_router(spec_router, prefix="/api/v1")
|
|
app.include_router(delivery_router, prefix="/api/v1")
|
|
app.include_router(deployment_router, prefix="/api/v1")
|
|
|
|
app.add_middleware(RouterLoggingMiddleware)
|