Refactor: move middleware definition (#6552)

This commit is contained in:
Robert Brennan
2025-01-30 15:32:26 -05:00
committed by GitHub
parent 5dd4810f58
commit 27fdae6ecc
13 changed files with 130 additions and 145 deletions

View File

@@ -2,8 +2,6 @@ from abc import ABC, abstractmethod
from enum import Enum
from typing import ClassVar, Protocol
from fastapi import FastAPI
class AppMode(Enum):
OSS = 'oss'
@@ -16,7 +14,7 @@ class SessionMiddlewareInterface(Protocol):
pass
class OpenhandsConfigInterface(ABC):
class ServerConfigInterface(ABC):
CONFIG_PATH: ClassVar[str | None]
APP_MODE: ClassVar[AppMode]
POSTHOG_CLIENT_KEY: ClassVar[str]
@@ -28,21 +26,11 @@ class OpenhandsConfigInterface(ABC):
"""Verify configuration settings."""
raise NotImplementedError
@abstractmethod
async def verify_github_repo_list(self, installation_id: int | None) -> None:
"""Verify that repo list is being called via user's profile or Github App installations."""
raise NotImplementedError
@abstractmethod
async def get_config(self) -> dict[str, str]:
"""Configure attributes for frontend"""
raise NotImplementedError
@abstractmethod
def attach_middleware(self, api: FastAPI) -> None:
"""Attach required middleware for the current environment"""
raise NotImplementedError
class MissingSettingsError(ValueError):
"""Raised when settings are missing or not found."""