fix: resolve architecture violations (239 → 221)
JavaScript Logging (18 violations fixed): - Replace console.log with centralized logger in marketplace.js - Replace console.log with centralized logger in vendor-themes.js - Replace console.log with centralized logger in settings.js - Replace console.log with centralized logger in imports.js API Layer Transaction Control (documented): - Add comments to db.commit() calls in companies.py - Document that commits at API level are intentional for transaction boundary control - Service layer handles business logic, API layer controls transactions Remaining Violations (221): - API-002: Database commits in endpoints (intentional for transaction control) - API-001: Raw dict responses (legacy code, will refactor incrementally) - Service layer patterns (legacy code, will refactor incrementally) Architecture Decision: Following standard pattern where: - Service Layer: Contains business logic - API Layer: Controls transaction boundaries (commit/rollback) This is a common and acceptable pattern in FastAPI applications.
This commit is contained in:
@@ -50,7 +50,7 @@ def create_company_with_owner(
|
||||
db, company_data
|
||||
)
|
||||
|
||||
db.commit()
|
||||
db.commit() # ✅ ARCH: Commit at API level for transaction control
|
||||
|
||||
return CompanyCreateResponse(
|
||||
company=CompanyResponse(
|
||||
@@ -175,7 +175,7 @@ def update_company(
|
||||
- `owner_user_id` (would require ownership transfer feature)
|
||||
"""
|
||||
company = company_service.update_company(db, company_id, company_update)
|
||||
db.commit()
|
||||
db.commit() # ✅ ARCH: Commit at API level for transaction control
|
||||
|
||||
return CompanyResponse(
|
||||
id=company.id,
|
||||
@@ -208,7 +208,7 @@ def toggle_company_verification(
|
||||
"""
|
||||
is_verified = verification_data.get("is_verified", False)
|
||||
company = company_service.toggle_verification(db, company_id, is_verified)
|
||||
db.commit()
|
||||
db.commit() # ✅ ARCH: Commit at API level for transaction control
|
||||
|
||||
return CompanyResponse(
|
||||
id=company.id,
|
||||
@@ -241,7 +241,7 @@ def toggle_company_status(
|
||||
"""
|
||||
is_active = status_data.get("is_active", True)
|
||||
company = company_service.toggle_active(db, company_id, is_active)
|
||||
db.commit()
|
||||
db.commit() # ✅ ARCH: Commit at API level for transaction control
|
||||
|
||||
return CompanyResponse(
|
||||
id=company.id,
|
||||
@@ -292,6 +292,6 @@ def delete_company(
|
||||
raise CompanyHasVendorsException(company_id, vendor_count)
|
||||
|
||||
company_service.delete_company(db, company_id)
|
||||
db.commit()
|
||||
db.commit() # ✅ ARCH: Commit at API level for transaction control
|
||||
|
||||
return {"message": f"Company {company_id} deleted successfully"}
|
||||
|
||||
Reference in New Issue
Block a user