45 lines
1.1 KiB
Python
45 lines
1.1 KiB
Python
import os
|
|
|
|
from fastapi import FastAPI
|
|
from fastapi.middleware.cors import CORSMiddleware
|
|
|
|
from app.config import settings
|
|
from app.database import Base, SessionLocal, engine
|
|
from app.migrations import run_migrations
|
|
from app.models.verification_token import VerificationToken # noqa: F401
|
|
from app.routers import auth, documents, templates, users
|
|
from app.seed import seed_admin_user
|
|
|
|
Base.metadata.create_all(bind=engine)
|
|
run_migrations()
|
|
|
|
os.makedirs(settings.upload_dir, exist_ok=True)
|
|
os.makedirs(settings.export_dir, exist_ok=True)
|
|
|
|
with SessionLocal() as db:
|
|
seed_admin_user(db)
|
|
|
|
app = FastAPI(
|
|
title="Document Template Editor",
|
|
description="Upload Jinja2-annotated .docx templates, fill variables, preview and export",
|
|
version="1.0.0",
|
|
)
|
|
|
|
app.add_middleware(
|
|
CORSMiddleware,
|
|
allow_origins=settings.cors_origin_list,
|
|
allow_credentials=True,
|
|
allow_methods=["*"],
|
|
allow_headers=["*"],
|
|
)
|
|
|
|
app.include_router(auth.router)
|
|
app.include_router(users.router)
|
|
app.include_router(templates.router)
|
|
app.include_router(documents.router)
|
|
|
|
|
|
@app.get("/api/health")
|
|
def health():
|
|
return {"status": "ok"}
|