
- Set up project structure with FastAPI, SQLAlchemy, and Alembic - Create database models for User and Item - Implement CRUD operations for all models - Create API endpoints with validation - Add health check endpoint - Configure CORS middleware - Set up database migrations - Add comprehensive documentation in README
42 lines
773 B
Python
42 lines
773 B
Python
from datetime import datetime
|
|
from typing import Optional
|
|
|
|
from pydantic import BaseModel
|
|
|
|
|
|
# Shared properties
|
|
class ItemBase(BaseModel):
|
|
title: Optional[str] = None
|
|
description: Optional[str] = None
|
|
|
|
|
|
# Properties to receive on item creation
|
|
class ItemCreate(ItemBase):
|
|
title: str
|
|
|
|
|
|
# Properties to receive on item update
|
|
class ItemUpdate(ItemBase):
|
|
pass
|
|
|
|
|
|
# Properties shared by models stored in DB
|
|
class ItemInDBBase(ItemBase):
|
|
id: int
|
|
title: str
|
|
owner_id: int
|
|
created_at: datetime
|
|
updated_at: Optional[datetime] = None
|
|
|
|
class Config:
|
|
from_attributes = True
|
|
|
|
|
|
# Properties to return to client
|
|
class Item(ItemInDBBase):
|
|
pass
|
|
|
|
|
|
# Properties stored in DB but not returned to client
|
|
class ItemInDB(ItemInDBBase):
|
|
pass |