c086f64363
- Add 7 core API endpoints: users, transactions, partners, products, inventory, payments, credit - Implement role-based authentication (admin/write/read-only access) - Add comprehensive database models with proper relationships - Include full test coverage for all endpoints and business logic - Set up Alembic migrations and Docker configuration - Configure FastAPI app with CORS and database integration
49 lines
1.5 KiB
Python
49 lines
1.5 KiB
Python
#!/usr/bin/env python3
|
|
"""Entry point for fastapi app
|
|
|
|
NOTE:
|
|
-
|
|
"""
|
|
from app.core.config import settings
|
|
from fastapi import FastAPI
|
|
from fastapi.middleware.cors import CORSMiddleware
|
|
from app.api.v1.users import router as users_router
|
|
from app.api.v1.transactions import router as transactions_router
|
|
from app.api.v1.partners import router as partners_router
|
|
from app.api.v1.products import router as products_router
|
|
from app.api.v1.transaction_details import router as transaction_details_router
|
|
from app.api.v1.payments import router as payments_router
|
|
from app.api.v1.credit import router as credit_router
|
|
from app.api.v1.inventory import router as inventory_router
|
|
|
|
|
|
app = FastAPI(
|
|
title=settings.project_name,
|
|
openapi_url=f"{settings.api_v1_str}/openapi.json"
|
|
)
|
|
|
|
|
|
# CORS for React frontend
|
|
app.add_middleware(
|
|
CORSMiddleware,
|
|
allow_origins=["http://localhost:5173"],
|
|
allow_credentials=True,
|
|
allow_methods=["*"],
|
|
allow_headers=["*"]
|
|
)
|
|
|
|
app.include_router(users_router, prefix=settings.api_v1_str)
|
|
app.include_router(transactions_router, prefix=settings.api_v1_str)
|
|
app.include_router(partners_router, prefix=settings.api_v1_str)
|
|
app.include_router(products_router, prefix=settings.api_v1_str)
|
|
app.include_router(transaction_details_router, prefix=settings.api_v1_str)
|
|
app.include_router(payments_router, prefix=settings.api_v1_str)
|
|
app.include_router(credit_router, prefix=settings.api_v1_str)
|
|
app.include_router(inventory_router, prefix=settings.api_v1_str)
|
|
|
|
@app.get("/")
|
|
def read_root():
|
|
"""
|
|
"""
|
|
return {"message": "CMT API v1"}
|