Files
projects/Dockers/puppeteer-api/app/routes/cache.py
T
Bram 09ecad1e7c
Build and Push Docker Images / build-and-push (push) Successful in 4m10s
add swagger to puppeteer
2026-04-23 15:21:50 +02:00

24 lines
814 B
Python

from fastapi import APIRouter, HTTPException, Header
from typing import Optional
from app.config import API_KEY
from app.services.cache import clear_cache, get_cache_stats
router = APIRouter(tags=["Cache"])
@router.get("/cache/clear")
async def clear_cache_route(x_api_key: Optional[str] = Header(None)):
"""Clear the entire cache database"""
# Validate API key
if not x_api_key or x_api_key != API_KEY:
raise HTTPException(status_code=401, detail="Invalid API key")
return clear_cache()
@router.get("/cache/stats")
async def cache_stats_route(x_api_key: Optional[str] = Header(None)):
"""Get cache statistics"""
# Validate API key
if not x_api_key or x_api_key != API_KEY:
raise HTTPException(status_code=401, detail="Invalid API key")
return get_cache_stats()