新規作成
This commit is contained in:
44
backend/app/main.py
Normal file
44
backend/app/main.py
Normal file
@@ -0,0 +1,44 @@
|
||||
from dotenv import load_dotenv
|
||||
load_dotenv()
|
||||
|
||||
from fastapi import FastAPI, Request
|
||||
from fastapi.responses import JSONResponse
|
||||
from pydantic import ValidationError
|
||||
|
||||
# FastAPI アプリケーション作成
|
||||
app = FastAPI(
|
||||
title="日本小規模企業向け会計システム"
|
||||
)
|
||||
|
||||
@app.exception_handler(ValidationError)
|
||||
async def validation_exception_handler(request: Request, exc: ValidationError):
|
||||
# ここでは最初のエラーだけ簡潔に返す(必要に応じて整形)
|
||||
first = exc.errors()[0]
|
||||
msg = first.get("msg", "入力値が不正です。")
|
||||
return JSONResponse(status_code=400, content={"detail": msg})
|
||||
|
||||
# ─────────────────────────
|
||||
# ルート(稼働確認)
|
||||
# ─────────────────────────
|
||||
@app.get("/", summary="稼働確認")
|
||||
def root():
|
||||
return {"status": "ok"}
|
||||
|
||||
# ─────────────────────────
|
||||
# ルーター登録(※ 必ず app 定義の後)
|
||||
# ─────────────────────────
|
||||
from app.modules.accounts.router import router as accounts_router
|
||||
app.include_router(accounts_router)
|
||||
|
||||
|
||||
from app.modules.journals.router import router as journals_router
|
||||
app.include_router(journals_router)
|
||||
|
||||
|
||||
from app.modules.ledger.router import router as ledger_router
|
||||
app.include_router(ledger_router)
|
||||
|
||||
|
||||
from app.modules.trial_balance.router import router as trial_balance_router
|
||||
app.include_router(trial_balance_router)
|
||||
|
||||
Reference in New Issue
Block a user