Files
daniel156161 9c731d6e67
Build and Push Docker Container / build-and-push (push) Failing after 51s
feat(logging): add NanoShare wide event instrumentation
- Register quart_common wide-event logging during app setup so every HTTP request emits one canonical structured event.

- Replace the inline security middleware with reusable quart_common security middleware wiring and move skip path configuration into app constants.

- Add NanoShare-specific wide-event context for health checks, auth/error handlers, file list/edit/delete/serve flows and upload outcomes.

- Rename runtime logging/project metadata from simple-picoshare to nanoshare where it is emitted in service context.

- Update my_helpers and quart_common submodules for Convex/wide-event integration and reusable security middleware support.

- Add NanoShare middleware tests covering safe user context, client IP enrichment, missing Convex handling and Convex security lookup failures.
2026-05-13 20:22:43 +02:00

32 lines
895 B
Python

from routes.handeling.errorsAndBots import maybe_a_hacker
from my_modules.app.constens import THE_IP_BOT_MANAGER, SKIP_PATH_PREFIXES, SKIP_PATHS
from my_modules.app.logger import logger
from my_modules.functions import get_ip
from my_modules.app.setup import app
from quart_common.web.security_middleware import register_security_middleware
from quart import session
from datetime import datetime
custom_middleware = register_security_middleware(
app,
logger=logger,
ip_bot_manager=THE_IP_BOT_MANAGER,
get_ip=get_ip,
maybe_hacker_fn=maybe_a_hacker,
skip_paths=SKIP_PATHS,
skip_path_prefixes=SKIP_PATH_PREFIXES,
)
@app.context_processor
async def inject_context_data():
user = session.get("user")
current_year = datetime.now().year
await logger.debug(f"Inject Context Data | User: {user}, Year: {current_year}")
return {
"user": user,
"year": current_year,
}