42 lines
1.1 KiB
Python
42 lines
1.1 KiB
Python
"""
|
|
TicketHub - Lightweight Issue Tracking System
|
|
"""
|
|
from fastapi import FastAPI
|
|
from fastapi.middleware.cors import CORSMiddleware
|
|
from fastapi.staticfiles import StaticFiles
|
|
from contextlib import asynccontextmanager
|
|
import os
|
|
|
|
from app.routers import tickets, projects, webhooks, health
|
|
from app.services.database import init_db
|
|
|
|
@asynccontextmanager
|
|
async def lifespan(app: FastAPI):
|
|
await init_db()
|
|
yield
|
|
|
|
app = FastAPI(
|
|
title="TicketHub",
|
|
description="Lightweight open-source ticket/issue tracking system",
|
|
version="1.0.0",
|
|
lifespan=lifespan
|
|
)
|
|
|
|
app.add_middleware(
|
|
CORSMiddleware,
|
|
allow_origins=["*"],
|
|
allow_credentials=True,
|
|
allow_methods=["*"],
|
|
allow_headers=["*"],
|
|
)
|
|
|
|
# API routes
|
|
app.include_router(health.router, prefix="/api", tags=["health"])
|
|
app.include_router(projects.router, prefix="/api/projects", tags=["projects"])
|
|
app.include_router(tickets.router, prefix="/api/tickets", tags=["tickets"])
|
|
app.include_router(webhooks.router, prefix="/api/webhooks", tags=["webhooks"])
|
|
|
|
# Serve frontend
|
|
if os.path.exists("/app/static"):
|
|
app.mount("/", StaticFiles(directory="/app/static", html=True), name="static")
|