
- Create project structure with app organization - Set up FastAPI application with CORS and health endpoint - Implement database models with SQLAlchemy (User, Post, Comment) - Set up Alembic for database migrations - Implement authentication with JWT tokens - Create CRUD operations for all models - Implement REST API endpoints for users, posts, and comments - Add comprehensive documentation in README.md
35 lines
778 B
Python
35 lines
778 B
Python
from datetime import datetime
|
|
from typing import Optional
|
|
from pydantic import BaseModel
|
|
|
|
# Shared properties
|
|
class CommentBase(BaseModel):
|
|
content: Optional[str] = None
|
|
|
|
# Properties to receive on comment creation
|
|
class CommentCreate(CommentBase):
|
|
content: str
|
|
post_id: str
|
|
|
|
# Properties to receive on comment update
|
|
class CommentUpdate(CommentBase):
|
|
pass
|
|
|
|
# Properties shared by models stored in DB
|
|
class CommentInDBBase(CommentBase):
|
|
id: str
|
|
post_id: str
|
|
author_id: str
|
|
created_at: datetime
|
|
updated_at: datetime
|
|
|
|
class Config:
|
|
from_attributes = True
|
|
|
|
# Properties to return to client
|
|
class Comment(CommentInDBBase):
|
|
pass
|
|
|
|
# Properties stored in DB but not returned to the client
|
|
class CommentInDB(CommentInDBBase):
|
|
pass |