- Nouveau router app/routers/collections.py - GET/POST/PUT/DELETE /db pour les collections - POST/GET/PUT/DELETE pour les pages dans une collection - Vue HTML basique par collection + vue par défaut auto-créée - CSRF exempté pour /db/ - 5 nouveaux tests (collections list, CRUD, pages CRUD, validation, HTML render) - 33/33 tests passent
59 lines
1.8 KiB
Python
59 lines
1.8 KiB
Python
"""FlowDeck — Kanban léger intégré à Gitea."""
|
|
from __future__ import annotations
|
|
|
|
import logging
|
|
from contextlib import asynccontextmanager
|
|
|
|
from fastapi import FastAPI
|
|
from fastapi.staticfiles import StaticFiles
|
|
from fastapi.middleware.cors import CORSMiddleware
|
|
from starlette.middleware.sessions import SessionMiddleware
|
|
|
|
from app.config import settings
|
|
from app.db import init_db
|
|
from app.middleware.csrf import CSRFMiddleware
|
|
from app.routers import dashboard, board, notes, api, auth, webhooks, collections
|
|
from app.services.gitea_client import gitea
|
|
|
|
logging.basicConfig(
|
|
level=getattr(logging, settings.log_level.upper(), logging.INFO),
|
|
format="%(asctime)s [%(levelname)s] %(message)s",
|
|
)
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
@asynccontextmanager
|
|
async def lifespan(_app: FastAPI):
|
|
init_db()
|
|
from app.db import get_conn
|
|
with get_conn() as conn:
|
|
conn.execute(
|
|
"INSERT OR IGNORE INTO users (login, full_name, email, is_admin) VALUES ('admin', 'Admin', '', 1)"
|
|
)
|
|
conn.commit()
|
|
logger.info("FlowDeck v1.0.0 started on port %d", settings.app_port)
|
|
yield
|
|
|
|
|
|
app = FastAPI(
|
|
title="FlowDeck",
|
|
version="1.0.0",
|
|
docs_url="/docs" if settings.log_level == "DEBUG" else None,
|
|
redoc_url=None,
|
|
lifespan=lifespan,
|
|
)
|
|
|
|
app.add_middleware(SessionMiddleware, secret_key=settings.app_secret_key, max_age=3600)
|
|
app.add_middleware(CSRFMiddleware)
|
|
app.add_middleware(CORSMiddleware, allow_origins=["*"], allow_methods=["*"], allow_headers=["*"])
|
|
|
|
app.include_router(auth.router)
|
|
app.include_router(dashboard.router)
|
|
app.include_router(board.router)
|
|
app.include_router(notes.router)
|
|
app.include_router(api.router)
|
|
app.include_router(webhooks.router)
|
|
app.include_router(collections.router)
|
|
|
|
app.mount("/static", StaticFiles(directory="static"), name="static")
|