""" `issue serve` — launch the issue-core REST API. Requires the [api] extra: `pip install issue-core[api]`. """ import click @click.command("serve") @click.option("--host", default="127.0.0.1", show_default=True, help="Bind address.") @click.option("--port", default=8765, show_default=True, type=int, help="Bind port.") @click.option("--reload", is_flag=True, default=False, help="Auto-reload on code change (dev only).") @click.option("--log-level", default="info", show_default=True, help="Uvicorn log level.") def serve_command(host: str, port: int, reload: bool, log_level: str) -> None: """Launch the issue-core REST API (POST /issues/ ingestion endpoint). Requires ISSUE_CORE_API_KEY to be set in the environment. """ try: import uvicorn # noqa: F401 except ImportError: raise click.ClickException( "The 'api' extra is not installed. Run: pip install 'issue-core[api]'" ) from ..api.auth import AuthConfigError, get_configured_api_key try: get_configured_api_key() except AuthConfigError as exc: raise click.ClickException(str(exc)) import uvicorn uvicorn.run( "issue_core.api.app:create_app", host=host, port=port, reload=reload, log_level=log_level, factory=True, )