Skip to content
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions app/auth/dependencies.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
from fastapi import HTTPException, Depends, Request
from fastapi.security import HTTPBearer, HTTPAuthorizationCredentials
import os
from typing import Optional

from fastapi import Depends, HTTPException, Request
from fastapi.security import HTTPAuthorizationCredentials, HTTPBearer

from ..config import get_settings

# Configuración del esquema de seguridad
Expand Down
17 changes: 9 additions & 8 deletions app/backoffice/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,18 @@
Enterprise-grade admin panel para impresionar reclutadores bancarios
"""

from fastapi import APIRouter, Request, HTTPException
from fastapi.templating import Jinja2Templates
from fastapi.responses import HTMLResponse, JSONResponse
from fastapi.staticfiles import StaticFiles
from datetime import datetime, timedelta
from typing import Dict, List, Any
from pydantic import BaseModel, Field
import random
from decimal import Decimal
import uuid
from datetime import datetime, timedelta
from decimal import Decimal
from enum import Enum
from typing import Any, Dict, List

from fastapi import APIRouter, HTTPException, Request
from fastapi.responses import HTMLResponse, JSONResponse
from fastapi.staticfiles import StaticFiles
from fastapi.templating import Jinja2Templates
from pydantic import BaseModel, Field

# Router configuration
router = APIRouter(prefix="/backoffice", tags=["Backoffice Dashboard"])
Expand Down
17 changes: 9 additions & 8 deletions app/backoffice/router_clean.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,18 @@
Enterprise-grade admin panel para impresionar reclutadores bancarios
"""

from fastapi import APIRouter, Request, HTTPException
from fastapi.templating import Jinja2Templates
from fastapi.responses import HTMLResponse, JSONResponse
from fastapi.staticfiles import StaticFiles
from datetime import datetime, timedelta
from typing import Dict, List, Any
from pydantic import BaseModel, Field
import random
from decimal import Decimal
import uuid
from datetime import datetime, timedelta
from decimal import Decimal
from enum import Enum
from typing import Any, Dict, List

from fastapi import APIRouter, HTTPException, Request
from fastapi.responses import HTMLResponse, JSONResponse
from fastapi.staticfiles import StaticFiles
from fastapi.templating import Jinja2Templates
from pydantic import BaseModel, Field

# Router configuration
router = APIRouter(prefix="/backoffice", tags=["Backoffice Dashboard"])
Expand Down
26 changes: 25 additions & 1 deletion app/config.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import os
import sys
from functools import lru_cache
from pydantic_settings import BaseSettings
from typing import List, Optional

from pydantic_settings import BaseSettings


class Settings(BaseSettings):
"""Configuración de la aplicación optimizada para Railway"""
Expand All @@ -18,9 +19,17 @@ class Settings(BaseSettings):
port: int = int(os.getenv("PORT", 8000))

# Environment Configuration
hotfix/pipeline-isort-formatting-fix
environment: str = os.getenv(
"ENVIRONMENT", "development"
) # Default to development, not production

develop
environment: str = os.getenv("ENVIRONMENT", "production")

environment: str = os.getenv("ENVIRONMENT", "development") # Default to development, not production
Copy link

Copilot AI Jul 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are conflicting environment default values in the code. Line 25 sets default to 'development' while line 28 sets it to 'production'. This creates ambiguity and potential configuration issues.

Suggested change
develop
environment: str = os.getenv("ENVIRONMENT", "production")
environment: str = os.getenv("ENVIRONMENT", "development") # Default to development, not production

Copilot uses AI. Check for mistakes.
main
develop
Copy link

Copilot AI Jul 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Git merge conflict markers are present in the code. This line contains a branch name that should be removed as it will cause syntax errors.

Suggested change
hotfix/pipeline-isort-formatting-fix
environment: str = os.getenv(
"ENVIRONMENT", "development"
) # Default to development, not production
develop
environment: str = os.getenv("ENVIRONMENT", "production")
environment: str = os.getenv("ENVIRONMENT", "development") # Default to development, not production
main
develop
environment: str = os.getenv(
"ENVIRONMENT", "development"
) # Default to development, not production

Copilot uses AI. Check for mistakes.
Copy link

Copilot AI Jul 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Git merge conflict markers are present in the code. This line contains a branch name that should be removed as it will cause syntax errors.

Suggested change
hotfix/pipeline-isort-formatting-fix
environment: str = os.getenv(
"ENVIRONMENT", "development"
) # Default to development, not production
develop
environment: str = os.getenv("ENVIRONMENT", "production")
environment: str = os.getenv("ENVIRONMENT", "development") # Default to development, not production
main
develop
environment: str = os.getenv(
"ENVIRONMENT", "development"
) # Default to development, not production
environment: str = os.getenv("ENVIRONMENT", "production")
environment: str = os.getenv("ENVIRONMENT", "development") # Default to development, not production

Copilot uses AI. Check for mistakes.
Copy link

Copilot AI Jul 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Git merge conflict markers are present in the code. This line contains a branch name that should be removed as it will cause syntax errors.

Suggested change
hotfix/pipeline-isort-formatting-fix
environment: str = os.getenv(
"ENVIRONMENT", "development"
) # Default to development, not production
develop
environment: str = os.getenv("ENVIRONMENT", "production")
environment: str = os.getenv("ENVIRONMENT", "development") # Default to development, not production
main
develop
environment: str = os.getenv(
"ENVIRONMENT", "development"
) # Default to development, not production

Copilot uses AI. Check for mistakes.
Copy link

Copilot AI Jul 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Git merge conflict markers are present in the code. This line contains a branch name that should be removed as it will cause syntax errors.

Suggested change
hotfix/pipeline-isort-formatting-fix
environment: str = os.getenv(
"ENVIRONMENT", "development"
) # Default to development, not production
develop
environment: str = os.getenv("ENVIRONMENT", "production")
environment: str = os.getenv("ENVIRONMENT", "development") # Default to development, not production
main
develop
environment: str = os.getenv(
"ENVIRONMENT", "development"
) # Default to development, not production

Copilot uses AI. Check for mistakes.
debug: bool = os.getenv("DEBUG", "false").lower() == "true"

# CORS Configuration - usando el dominio privado de Railway
Expand Down Expand Up @@ -66,6 +75,20 @@ def __init__(self, **kwargs):
super().__init__(**kwargs)
# Configurar CORS origins después de la inicialización
self.cors_origins = self._get_cors_origins()
hotfix/pipeline-isort-formatting-fix

develop
Copy link

Copilot AI Jul 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Git merge conflict markers are present in the code. This line contains a branch name that should be removed as it will cause syntax errors.

Suggested change
hotfix/pipeline-isort-formatting-fix
develop

Copilot uses AI. Check for mistakes.
Copy link

Copilot AI Jul 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Git merge conflict markers are present in the code. This line contains a branch name that should be removed as it will cause syntax errors.

Suggested change
hotfix/pipeline-isort-formatting-fix
develop

Copilot uses AI. Check for mistakes.
# Detectar si estamos en modo test
is_testing = bool(os.getenv("PYTEST_CURRENT_TEST")) or "pytest" in os.getenv("_", "")

# Validación de configuración crítica solo en producción (no en tests)
if self.environment == "production" and not is_testing and not self.api_key:
raise ValueError("API_KEY environment variable is required in production")

# Si estamos en tests y no hay API_KEY, usar una de prueba
if is_testing and not self.api_key:
self.api_key = "test_secure_key_for_testing_only_not_production"
develop

Copy link

Copilot AI Jul 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Git merge conflict markers are present in the code. This line contains a branch name that should be removed as it will cause syntax errors.

Suggested change
hotfix/pipeline-isort-formatting-fix
develop
# Detectar si estamos en modo test
is_testing = bool(os.getenv("PYTEST_CURRENT_TEST")) or "pytest" in os.getenv("_", "")
# Validación de configuración crítica solo en producción (no en tests)
if self.environment == "production" and not is_testing and not self.api_key:
raise ValueError("API_KEY environment variable is required in production")
# Si estamos en tests y no hay API_KEY, usar una de prueba
if is_testing and not self.api_key:
self.api_key = "test_secure_key_for_testing_only_not_production"
develop

Copilot uses AI. Check for mistakes.
# Detectar si estamos en modo test de manera más robusta
is_testing = (
Expand All @@ -89,6 +112,7 @@ def __init__(self, **kwargs):
# Validación de configuración crítica solo en producción real (no testing)
if self.environment == "production" and not is_testing and not self.api_key:
raise ValueError("API_KEY environment variable is required in production")
main
Copy link

Copilot AI Jul 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Git merge conflict markers are present in the code. This line contains a branch name that should be removed as it will cause syntax errors.

Suggested change
main

Copilot uses AI. Check for mistakes.


@lru_cache()
Expand Down
10 changes: 6 additions & 4 deletions app/main.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import datetime
import logging
import os

from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from fastapi.responses import JSONResponse
import logging
import datetime
import os
from .routers import operator

from .backoffice import router as backoffice_router
from .routers import operator
from .utils.logging import setup_logging

# Configuración constantes
Expand Down
10 changes: 6 additions & 4 deletions app/routers/operator.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
from fastapi import APIRouter, Depends, HTTPException, status, Path
from pydantic import BaseModel, Field
from typing import List
from ..services.order_service import get_order_status
from ..services.invoice_service import generate_invoice

from fastapi import APIRouter, Depends, HTTPException, Path, status
from pydantic import BaseModel, Field

from ..auth.dependencies import verify_api_key
from ..services.invoice_service import generate_invoice
from ..services.order_service import get_order_status

# Router con documentación mejorada
router = APIRouter(
Expand Down
4 changes: 2 additions & 2 deletions app/security.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Security Configuration for Production
import secrets
import logging
import os
from typing import Dict, Any
import secrets
from typing import Any, Dict


# Configure logging for production
Expand Down
3 changes: 2 additions & 1 deletion app/tests/test_main.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import pytest
from httpx import AsyncClient, ASGITransport
from httpx import ASGITransport, AsyncClient

from app.main import app


Expand Down
8 changes: 5 additions & 3 deletions app/tests/test_operator.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import pytest
import os
from httpx import AsyncClient, ASGITransport
from app.main import app

import pytest
from httpx import ASGITransport, AsyncClient

from app.config import get_settings
from app.main import app

# Obtener API key del sistema de configuración
settings = get_settings()
Expand Down
1 change: 1 addition & 0 deletions app/utils/logging.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import logging
import sys

from pythonjsonlogger import jsonlogger


Expand Down
1 change: 1 addition & 0 deletions lambda_function.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from mangum import Mangum

from app.main import app

# Handler para AWS Lambda
Expand Down
5 changes: 3 additions & 2 deletions start_clean_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
Script simple para probar el servidor FastAPI
"""

import uvicorn
import sys
import os
import sys

import uvicorn

# Añadir el directorio actual al PATH
sys.path.insert(0, os.getcwd())
Expand Down