feat(api): Update API to use skill-seekers-configs repository
- Update render.yaml to clone skill-seekers-configs during build - Update main.py to use configs_repo/official directory - Add fallback to local configs/ for development - Update config_analyzer to scan subdirectories recursively - Update download endpoint to search in subdirectories - Add configs_repository link to API root - Add configs_repo/ to .gitignore This separates config storage from main repo to prevent bloating. Configs now live at: https://github.com/yusufkaraaslan/skill-seekers-configs
This commit is contained in:
1
api/.gitignore
vendored
Normal file
1
api/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
configs_repo/
|
||||
@@ -76,8 +76,8 @@ class ConfigAnalyzer:
|
||||
"""
|
||||
configs = []
|
||||
|
||||
# Find all JSON files in configs directory
|
||||
for config_file in sorted(self.config_dir.glob("*.json")):
|
||||
# Find all JSON files recursively in configs directory and subdirectories
|
||||
for config_file in sorted(self.config_dir.rglob("*.json")):
|
||||
try:
|
||||
metadata = self.analyze_config(config_file)
|
||||
if metadata: # Skip invalid configs
|
||||
|
||||
16
api/main.py
16
api/main.py
@@ -31,7 +31,11 @@ app.add_middleware(
|
||||
)
|
||||
|
||||
# Initialize config analyzer
|
||||
CONFIG_DIR = Path(__file__).parent.parent / "configs"
|
||||
# Try configs_repo first (production), fallback to configs (local development)
|
||||
CONFIG_DIR = Path(__file__).parent / "configs_repo" / "official"
|
||||
if not CONFIG_DIR.exists():
|
||||
CONFIG_DIR = Path(__file__).parent.parent / "configs"
|
||||
|
||||
analyzer = ConfigAnalyzer(CONFIG_DIR)
|
||||
|
||||
|
||||
@@ -45,9 +49,11 @@ async def root():
|
||||
"/api/configs": "List all available configs",
|
||||
"/api/configs/{name}": "Get specific config details",
|
||||
"/api/categories": "List all categories",
|
||||
"/api/download/{name}": "Download config file",
|
||||
"/docs": "API documentation",
|
||||
},
|
||||
"repository": "https://github.com/yusufkaraaslan/Skill_Seekers",
|
||||
"configs_repository": "https://github.com/yusufkaraaslan/skill-seekers-configs",
|
||||
"website": "https://api.skillseekersweb.com"
|
||||
}
|
||||
|
||||
@@ -178,9 +184,13 @@ async def download_config(config_name: str):
|
||||
if not config_name.endswith(".json"):
|
||||
config_name = f"{config_name}.json"
|
||||
|
||||
config_path = CONFIG_DIR / config_name
|
||||
# Search recursively in all subdirectories
|
||||
config_path = None
|
||||
for found_path in CONFIG_DIR.rglob(config_name):
|
||||
config_path = found_path
|
||||
break
|
||||
|
||||
if not config_path.exists():
|
||||
if not config_path or not config_path.exists():
|
||||
raise HTTPException(
|
||||
status_code=404,
|
||||
detail=f"Config file '{config_name}' not found"
|
||||
|
||||
Reference in New Issue
Block a user