133 lines
2.8 KiB
Python
133 lines
2.8 KiB
Python
"""
|
|
Utility modules for the application.
|
|
"""
|
|
from .exceptions import (
|
|
handle_database_errors,
|
|
handle_validation_errors,
|
|
handle_security_errors,
|
|
safe_execute,
|
|
create_error_response,
|
|
ErrorContext,
|
|
APIError,
|
|
DatabaseError,
|
|
BusinessLogicError,
|
|
SecurityError
|
|
)
|
|
|
|
from .logging import (
|
|
StructuredLogger,
|
|
ImportLogger,
|
|
SecurityLogger,
|
|
DatabaseLogger,
|
|
log_function_call,
|
|
app_logger,
|
|
import_logger,
|
|
security_logger,
|
|
database_logger,
|
|
log_info,
|
|
log_warning,
|
|
log_error,
|
|
log_debug
|
|
)
|
|
|
|
from .database import (
|
|
TransactionManager,
|
|
db_transaction,
|
|
transactional,
|
|
BulkOperationManager,
|
|
safe_db_operation,
|
|
execute_with_retry
|
|
)
|
|
|
|
from .security import (
|
|
CredentialValidator,
|
|
PasswordStrengthValidator,
|
|
audit_code_security,
|
|
hash_password_securely,
|
|
verify_password,
|
|
SecurityFinding,
|
|
SecurityLevel
|
|
)
|
|
|
|
from .responses import (
|
|
ErrorCode,
|
|
ErrorDetail,
|
|
ValidationErrorDetail,
|
|
ErrorResponse,
|
|
ValidationErrorResponse,
|
|
SuccessResponse,
|
|
PaginatedResponse,
|
|
BulkOperationResponse,
|
|
create_error_response,
|
|
create_validation_error_response,
|
|
create_success_response,
|
|
create_not_found_response,
|
|
create_conflict_response,
|
|
create_unauthorized_response,
|
|
create_forbidden_response,
|
|
get_status_code_for_error
|
|
)
|
|
|
|
__all__ = [
|
|
# Exception handling
|
|
'handle_database_errors',
|
|
'handle_validation_errors',
|
|
'handle_security_errors',
|
|
'safe_execute',
|
|
'create_error_response',
|
|
'ErrorContext',
|
|
'APIError',
|
|
'DatabaseError',
|
|
'BusinessLogicError',
|
|
'SecurityError',
|
|
|
|
# Logging
|
|
'StructuredLogger',
|
|
'ImportLogger',
|
|
'SecurityLogger',
|
|
'DatabaseLogger',
|
|
'log_function_call',
|
|
'app_logger',
|
|
'import_logger',
|
|
'security_logger',
|
|
'database_logger',
|
|
'log_info',
|
|
'log_warning',
|
|
'log_error',
|
|
'log_debug',
|
|
|
|
# Database utilities
|
|
'TransactionManager',
|
|
'db_transaction',
|
|
'transactional',
|
|
'BulkOperationManager',
|
|
'safe_db_operation',
|
|
'execute_with_retry',
|
|
|
|
# Security utilities
|
|
'CredentialValidator',
|
|
'PasswordStrengthValidator',
|
|
'audit_code_security',
|
|
'hash_password_securely',
|
|
'verify_password',
|
|
'SecurityFinding',
|
|
'SecurityLevel',
|
|
|
|
# Response utilities
|
|
'ErrorCode',
|
|
'ErrorDetail',
|
|
'ValidationErrorDetail',
|
|
'ErrorResponse',
|
|
'ValidationErrorResponse',
|
|
'SuccessResponse',
|
|
'PaginatedResponse',
|
|
'BulkOperationResponse',
|
|
'create_error_response',
|
|
'create_validation_error_response',
|
|
'create_success_response',
|
|
'create_not_found_response',
|
|
'create_conflict_response',
|
|
'create_unauthorized_response',
|
|
'create_forbidden_response',
|
|
'get_status_code_for_error'
|
|
] |