
- Set up project structure and dependencies - Create database models for users, posts, comments, and tags - Set up Alembic for database migrations - Implement user authentication (register, login) - Create CRUD endpoints for blog posts, comments, and tags - Add health check endpoint - Set up proper error handling - Update README with project details and setup instructions
45 lines
872 B
Python
45 lines
872 B
Python
from datetime import datetime
|
|
from typing import Optional
|
|
|
|
from pydantic import BaseModel, EmailStr
|
|
|
|
|
|
# Shared properties
|
|
class UserBase(BaseModel):
|
|
email: Optional[EmailStr] = None
|
|
username: Optional[str] = None
|
|
is_active: Optional[bool] = True
|
|
|
|
|
|
# Properties to receive via API on creation
|
|
class UserCreate(UserBase):
|
|
email: EmailStr
|
|
username: str
|
|
password: str
|
|
|
|
|
|
# Properties to receive via API on update
|
|
class UserUpdate(UserBase):
|
|
password: Optional[str] = None
|
|
|
|
|
|
# Properties shared by models stored in DB
|
|
class UserInDBBase(UserBase):
|
|
id: int
|
|
email: EmailStr
|
|
username: str
|
|
created_at: datetime
|
|
updated_at: datetime
|
|
|
|
class Config:
|
|
from_attributes = True
|
|
|
|
|
|
# Properties to return to client
|
|
class User(UserInDBBase):
|
|
pass
|
|
|
|
|
|
# Properties stored in DB
|
|
class UserInDB(UserInDBBase):
|
|
hashed_password: str |