
- Set up project structure and dependencies - Create task model and schema - Implement Alembic migrations - Add CRUD API endpoints for task management - Add health endpoint with database connectivity check - Add comprehensive error handling - Add tests for API endpoints - Update README with API documentation
42 lines
1.4 KiB
Python
42 lines
1.4 KiB
Python
from datetime import datetime
|
|
from typing import Optional
|
|
|
|
from pydantic import BaseModel, Field
|
|
|
|
|
|
# Shared properties
|
|
class TaskBase(BaseModel):
|
|
title: str = Field(..., min_length=1, max_length=255, description="Task title")
|
|
description: Optional[str] = Field(None, description="Task description")
|
|
completed: Optional[bool] = Field(False, description="Task completion status")
|
|
priority: Optional[int] = Field(1, ge=1, le=3, description="Task priority: 1-Low, 2-Medium, 3-High")
|
|
due_date: Optional[datetime] = Field(None, description="Task due date")
|
|
|
|
|
|
# Properties to receive on task creation
|
|
class TaskCreate(TaskBase):
|
|
pass
|
|
|
|
|
|
# Properties to receive on task update
|
|
class TaskUpdate(BaseModel):
|
|
title: Optional[str] = Field(None, min_length=1, max_length=255, description="Task title")
|
|
description: Optional[str] = Field(None, description="Task description")
|
|
completed: Optional[bool] = Field(None, description="Task completion status")
|
|
priority: Optional[int] = Field(None, ge=1, le=3, description="Task priority: 1-Low, 2-Medium, 3-High")
|
|
due_date: Optional[datetime] = Field(None, description="Task due date")
|
|
|
|
|
|
# Properties shared by models stored in DB
|
|
class TaskInDBBase(TaskBase):
|
|
id: int
|
|
created_at: datetime
|
|
updated_at: datetime
|
|
|
|
class Config:
|
|
from_attributes = True
|
|
|
|
|
|
# Properties to return to client
|
|
class Task(TaskInDBBase):
|
|
pass |