pryscraper/routers/__init__.py
Rug Munch Media LLC 223c15b2f5
feat(pry): phase 0 — split routers, add tests, apify schema, pry api key
- Split scraping endpoints from api.py into routers/scraping.py
- Split template endpoints into routers/templates.py with POST /v1/templates/batch
- Introduce deps.py for shared singleton instances
- Add e2e tests for scraping, templates, auth, and Apify schema (23 new tests)
- Add reusable Apify actor input/output schema builder (apify_schema.py)
- Add PRY_API_KEY startup warning and deploy key to Talos /srv/pry/.env
- Register /v1/templates/batch as paid x402 operation
2026-07-03 06:28:02 +07:00

49 lines
1.5 KiB
Python

"""Pry API routers.
Each module in this package groups FastAPI endpoints by their `tags` field
(see api.py). The original api.py had 195 endpoints across 52 tags in a
single 4,668-line file. This package splits them so each router is
~50-300 lines (per CONVENTIONS.md, no file over 500 lines).
Pattern for each router file:
from fastapi import APIRouter, Body, Query
from typing import Any
from errors import NotFoundError # if needed
router = APIRouter(tags=["Auth"])
@router.post("/v1/auth/credentials", summary="...")
async def store_credentials(...):
...
Then in api.py:
from routers.auth import router as auth_router
app.include_router(auth_router)
Migration order (one router at a time, each as a separate commit):
1. auth - done
2. health - easy (3 endpoints, no business logic)
3. scraping - core, but well-bounded
4. extraction - similar
5. ... see docs/adr/0003-api-router-split.md for the full plan
The full split is a multi-hour refactor; this package is the
infrastructure for it. The first commit (this file + routers/auth.py)
demonstrates the pattern; subsequent commits can add more routers
without changing the overall structure.
Part of Pry - https://git.rugmunch.io/RugMunchMedia/pryscraper
Licensed under MIT. See LICENSE.
"""
# SPDX-License-Identifier: MIT
# Copyright (c) 2026 Rug Munch Media LLC
#
# Part of Pry - https://git.rugmunch.io/RugMunchMedia/pryscraper
# Licensed under MIT. See LICENSE.
__all__: list[str] = [
"auth_router",
"health_router",
"templates_router",
]