feat: overhaul with modular API, agent endpoints, migrations, backup and tests
- Split monolithic app.py into server/api/ routers - Add Pydantic schemas for input validation - Add /agent/* API with separate AGENT_TOKEN auth - Replace static schema.sql with versioned migrations (datenerhaltend) - Add tools/backup_db.py for SQLite backups - Add Dockerfile HEALTHCHECK and compose.yml AGENT_TOKEN env - Add pytest tests for user and agent API - Update README with API docs and deployment safety notes - Bump version to 1.2.0
This commit is contained in:
+5
-7
@@ -2,21 +2,19 @@ from __future__ import annotations
|
||||
|
||||
import pathlib
|
||||
import uuid
|
||||
from datetime import datetime, timezone
|
||||
from datetime import UTC, datetime
|
||||
|
||||
import aiosqlite
|
||||
|
||||
from server.settings import settings
|
||||
|
||||
SCHEMA_PATH = str(pathlib.Path(__file__).resolve().parents[1] / "tools" / "schema.sql")
|
||||
|
||||
|
||||
def new_id() -> str:
|
||||
return str(uuid.uuid4())
|
||||
|
||||
|
||||
def utc_now_iso() -> str:
|
||||
return datetime.now(timezone.utc).replace(microsecond=0).isoformat()
|
||||
return datetime.now(UTC).replace(microsecond=0).isoformat()
|
||||
|
||||
|
||||
async def get_db() -> aiosqlite.Connection:
|
||||
@@ -27,6 +25,6 @@ async def get_db() -> aiosqlite.Connection:
|
||||
|
||||
|
||||
async def ensure_schema(db: aiosqlite.Connection) -> None:
|
||||
schema = pathlib.Path(SCHEMA_PATH).read_text(encoding="utf-8")
|
||||
await db.executescript(schema)
|
||||
await db.commit()
|
||||
from server.migrations import run_migrations
|
||||
|
||||
await run_migrations(db)
|
||||
|
||||
Reference in New Issue
Block a user