feat: update project structure and docs

This commit is contained in:
2026-04-25 18:38:07 +03:00
parent 9c3b44b561
commit 9772c3c908
42 changed files with 1342 additions and 6 deletions
+1
View File
@@ -0,0 +1 @@
"""Core module - shared functionality and configuration."""
+20
View File
@@ -0,0 +1,20 @@
"""Application configuration and settings."""
from pydantic_settings import BaseSettings, SettingsConfigDict
class Settings(BaseSettings):
"""Application settings from environment variables."""
app_name: str = "Blog API"
debug: bool = False
host: str = "0.0.0.0"
port: int = 8000
# Database (when added)
database_url: str | None = None
model_config = SettingsConfigDict(env_file=".env")
settings = Settings()
+64
View File
@@ -0,0 +1,64 @@
"""Custom application exceptions."""
class AppException(Exception):
"""Base application exception."""
def __init__(self, message: str, status_code: int = 500):
"""Initialize application exception.
Args:
message: Error message.
status_code: HTTP status code.
"""
self.message = message
self.status_code = status_code
super().__init__(self.message)
class NotFoundError(AppException):
"""Resource not found error."""
def __init__(self, message: str = "Resource not found"):
"""Initialize not found error.
Args:
message: Error message.
"""
super().__init__(message, status_code=404)
class ValidationError(AppException):
"""Validation error."""
def __init__(self, message: str = "Validation failed"):
"""Initialize validation error.
Args:
message: Error message.
"""
super().__init__(message, status_code=400)
class UnauthorizedError(AppException):
"""Authentication required."""
def __init__(self, message: str = "Unauthorized"):
"""Initialize unauthorized error.
Args:
message: Error message.
"""
super().__init__(message, status_code=401)
class ForbiddenError(AppException):
"""Permission denied."""
def __init__(self, message: str = "Forbidden"):
"""Initialize forbidden error.
Args:
message: Error message.
"""
super().__init__(message, status_code=403)