
- Implemented user authentication with JWT - Added CRUD operations for users and items - Setup database connection with SQLAlchemy - Added migration scripts for easy database setup - Included health check endpoint for monitoring generated with BackendIM... (backend.im)
40 lines
791 B
Python
40 lines
791 B
Python
from pydantic import BaseModel, EmailStr, Field
|
|
from typing import Optional
|
|
from datetime import datetime
|
|
|
|
|
|
class UserBase(BaseModel):
|
|
email: EmailStr
|
|
username: str
|
|
|
|
|
|
class UserCreate(UserBase):
|
|
password: str = Field(..., min_length=8)
|
|
|
|
|
|
class UserUpdate(BaseModel):
|
|
email: Optional[EmailStr] = None
|
|
username: Optional[str] = None
|
|
password: Optional[str] = None
|
|
is_active: Optional[bool] = None
|
|
|
|
|
|
class UserInDB(UserBase):
|
|
id: int
|
|
is_active: bool
|
|
hashed_password: str
|
|
created_at: datetime
|
|
updated_at: Optional[datetime] = None
|
|
|
|
class Config:
|
|
orm_mode = True
|
|
|
|
|
|
class UserResponse(UserBase):
|
|
id: int
|
|
is_active: bool
|
|
created_at: datetime
|
|
updated_at: Optional[datetime] = None
|
|
|
|
class Config:
|
|
orm_mode = True |