
- Set up FastAPI application with SQLite database - Implement User and Item models with relationships - Add CRUD operations for users and items - Configure Alembic for database migrations - Include API documentation at /docs and /redoc - Add health check endpoint at /health - Enable CORS for all origins - Structure code with proper separation of concerns
25 lines
563 B
Python
25 lines
563 B
Python
from typing import Optional
|
|
from pydantic import BaseModel
|
|
from datetime import datetime
|
|
|
|
class UserBase(BaseModel):
|
|
email: str
|
|
full_name: Optional[str] = None
|
|
is_active: bool = True
|
|
|
|
class UserCreate(UserBase):
|
|
password: str
|
|
|
|
class UserUpdate(BaseModel):
|
|
email: Optional[str] = None
|
|
full_name: Optional[str] = None
|
|
is_active: Optional[bool] = None
|
|
password: Optional[str] = None
|
|
|
|
class User(UserBase):
|
|
id: int
|
|
created_at: datetime
|
|
updated_at: Optional[datetime] = None
|
|
|
|
class Config:
|
|
from_attributes = True |