
- Setup project structure and FastAPI application - Create SQLite database with SQLAlchemy - Implement user authentication with JWT - Create task and user models - Add CRUD operations for tasks and users - Configure Alembic for database migrations - Implement API endpoints for task management - Add error handling and validation - Configure CORS middleware - Create health check endpoint - Add comprehensive documentation
47 lines
949 B
Python
47 lines
949 B
Python
from datetime import datetime
|
|
from typing import Optional
|
|
|
|
from pydantic import BaseModel
|
|
|
|
from app.models.task import TaskPriority, TaskStatus
|
|
|
|
|
|
# Shared properties
|
|
class TaskBase(BaseModel):
|
|
title: Optional[str] = None
|
|
description: Optional[str] = None
|
|
priority: Optional[TaskPriority] = TaskPriority.MEDIUM
|
|
status: Optional[TaskStatus] = TaskStatus.TODO
|
|
due_date: Optional[datetime] = None
|
|
|
|
|
|
# Properties to receive on task creation
|
|
class TaskCreate(TaskBase):
|
|
title: str
|
|
|
|
|
|
# Properties to receive on task update
|
|
class TaskUpdate(TaskBase):
|
|
pass
|
|
|
|
|
|
# Properties shared by models stored in DB
|
|
class TaskInDBBase(TaskBase):
|
|
id: str
|
|
title: str
|
|
user_id: str
|
|
created_at: datetime
|
|
updated_at: Optional[datetime] = None
|
|
|
|
class Config:
|
|
from_attributes = True
|
|
|
|
|
|
# Properties to return to client
|
|
class Task(TaskInDBBase):
|
|
pass
|
|
|
|
|
|
# Properties stored in DB
|
|
class TaskInDB(TaskInDBBase):
|
|
pass |