Automated Action 606cda0912 Implement Blogging API with FastAPI and SQLite
- 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
2025-06-02 22:34:58 +00:00

36 lines
796 B
Python

from datetime import datetime
from typing import Optional
from pydantic import BaseModel
# Shared properties
class PostBase(BaseModel):
title: Optional[str] = None
content: Optional[str] = None
is_published: Optional[bool] = True
# Properties to receive on post creation
class PostCreate(PostBase):
title: str
content: str
# Properties to receive on post update
class PostUpdate(PostBase):
pass
# Properties shared by models stored in DB
class PostInDBBase(PostBase):
id: str
author_id: str
created_at: datetime
updated_at: datetime
class Config:
from_attributes = True
# Properties to return to client
class Post(PostInDBBase):
pass
# Properties stored in DB but not returned to the API client
class PostInDB(PostInDBBase):
pass