refactor: reorganize the whole project layout
Build and Push to Registry / build (push) Successful in 8s
Build and Push to Registry / build (push) Successful in 8s
This commit is contained in:
@@ -1,15 +1,16 @@
|
|||||||
from datetime import UTC, datetime
|
from datetime import UTC, datetime
|
||||||
from typing import Annotated
|
from typing import Annotated
|
||||||
|
|
||||||
|
from fastapi import APIRouter, Depends, HTTPException, Response, status
|
||||||
|
|
||||||
from core.security import (
|
from core.security import (
|
||||||
AuthContext,
|
AuthContext,
|
||||||
create_access_token,
|
create_access_token,
|
||||||
get_auth_context,
|
get_auth_context,
|
||||||
verify_password,
|
verify_password,
|
||||||
)
|
)
|
||||||
from db.auth import get_user_by_username, revoke_token
|
|
||||||
from fastapi import APIRouter, Depends, HTTPException, Response, status
|
|
||||||
from models.auth import LoginInput, TokenResponse
|
from models.auth import LoginInput, TokenResponse
|
||||||
|
from repositories.auth import get_user_by_username, revoke_token
|
||||||
|
|
||||||
router = APIRouter(
|
router = APIRouter(
|
||||||
prefix="/auth",
|
prefix="/auth",
|
||||||
|
|||||||
@@ -1,16 +1,17 @@
|
|||||||
|
from fastapi import APIRouter, Depends, HTTPException, status
|
||||||
|
|
||||||
from core.security import require_authenticated_user
|
from core.security import require_authenticated_user
|
||||||
from db.proxy import (
|
from models.proxy import ProxyCreateInput, ProxyUpdateInput
|
||||||
|
from repositories.proxy import (
|
||||||
create_proxy,
|
create_proxy,
|
||||||
delete_proxy,
|
delete_proxy,
|
||||||
get_proxy_by_port,
|
get_proxy_by_port,
|
||||||
update_proxy,
|
update_proxy,
|
||||||
)
|
)
|
||||||
from db.proxy import (
|
from repositories.proxy import (
|
||||||
list_proxies as list_proxy_documents,
|
list_proxies as list_proxy_documents,
|
||||||
)
|
)
|
||||||
from fastapi import APIRouter, Depends, HTTPException, status
|
from services.proxy.validator import ProxyCodeValidationError, validate_proxy_code
|
||||||
from models.proxy import ProxyCreateInput, ProxyUpdateInput
|
|
||||||
from utils.proxy.validator import ProxyCodeValidationError, validate_proxy_code
|
|
||||||
|
|
||||||
router = APIRouter(
|
router = APIRouter(
|
||||||
prefix="/proxy",
|
prefix="/proxy",
|
||||||
|
|||||||
@@ -5,13 +5,14 @@ from uuid import uuid4
|
|||||||
|
|
||||||
from authlib.jose import jwt # type: ignore
|
from authlib.jose import jwt # type: ignore
|
||||||
from authlib.jose.errors import JoseError # type: ignore
|
from authlib.jose.errors import JoseError # type: ignore
|
||||||
from core.config import settings
|
|
||||||
from db.auth import get_user_by_username, is_token_revoked
|
|
||||||
from fastapi import Depends, HTTPException, status
|
from fastapi import Depends, HTTPException, status
|
||||||
from fastapi.security import HTTPAuthorizationCredentials, HTTPBearer
|
from fastapi.security import HTTPAuthorizationCredentials, HTTPBearer
|
||||||
from models.auth import AccessTokenPayload, AuthUserDocument
|
|
||||||
from passlib.context import CryptContext
|
from passlib.context import CryptContext
|
||||||
|
|
||||||
|
from core.config import settings
|
||||||
|
from models.auth import AccessTokenPayload, AuthUserDocument
|
||||||
|
from repositories.auth import get_user_by_username, is_token_revoked
|
||||||
|
|
||||||
pwd_context = CryptContext(schemes=["bcrypt"], deprecated="auto")
|
pwd_context = CryptContext(schemes=["bcrypt"], deprecated="auto")
|
||||||
bearer_scheme = HTTPBearer(auto_error=False)
|
bearer_scheme = HTTPBearer(auto_error=False)
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
from utils.docker.compose import (
|
from integrations.docker.compose import (
|
||||||
find_docker_compose,
|
find_docker_compose,
|
||||||
get_all_services,
|
get_all_services,
|
||||||
get_services,
|
get_services,
|
||||||
get_visible_folders,
|
get_visible_folders,
|
||||||
)
|
)
|
||||||
from utils.docker.editor import change_port
|
from integrations.docker.editor import change_port
|
||||||
from utils.docker.models import DockerService
|
from integrations.docker.models import DockerService
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
"DockerService",
|
"DockerService",
|
||||||
@@ -2,8 +2,8 @@ from pathlib import Path
|
|||||||
|
|
||||||
import yaml
|
import yaml
|
||||||
|
|
||||||
from utils.docker.models import DockerService
|
from integrations.docker.models import DockerService
|
||||||
from utils.docker.ports import _get_service_port
|
from integrations.docker.ports import _get_service_port
|
||||||
|
|
||||||
COMPOSE_NAMES = (
|
COMPOSE_NAMES = (
|
||||||
"compose.yml",
|
"compose.yml",
|
||||||
@@ -2,8 +2,8 @@ from pathlib import Path
|
|||||||
|
|
||||||
import yaml
|
import yaml
|
||||||
|
|
||||||
from utils.docker.compose import find_docker_compose
|
from integrations.docker.compose import find_docker_compose
|
||||||
from utils.docker.ports import _get_port_index, _replace_port_in_mapping
|
from integrations.docker.ports import _get_port_index, _replace_port_in_mapping
|
||||||
|
|
||||||
|
|
||||||
def _backup_path_for(compose_path: Path) -> Path:
|
def _backup_path_for(compose_path: Path) -> Path:
|
||||||
+4
-3
@@ -1,14 +1,15 @@
|
|||||||
from contextlib import asynccontextmanager
|
from contextlib import asynccontextmanager
|
||||||
|
|
||||||
|
from fastapi import FastAPI
|
||||||
|
|
||||||
from api.auth.router import router as auth_router
|
from api.auth.router import router as auth_router
|
||||||
from api.proxy.router import router as proxy_router
|
from api.proxy.router import router as proxy_router
|
||||||
from core.config import settings
|
from core.config import settings
|
||||||
from core.mongodb import close_mongodb, init_mongodb
|
from core.mongodb import close_mongodb, init_mongodb
|
||||||
from core.redis import close_redis, init_redis
|
from core.redis import close_redis, init_redis
|
||||||
from core.security import hash_password
|
from core.security import hash_password
|
||||||
from db.auth import ensure_auth_indexes, ensure_single_account
|
from repositories.auth import ensure_auth_indexes, ensure_single_account
|
||||||
from db.proxy import ensure_proxy_indexes
|
from repositories.proxy import ensure_proxy_indexes
|
||||||
from fastapi import FastAPI
|
|
||||||
|
|
||||||
|
|
||||||
@asynccontextmanager
|
@asynccontextmanager
|
||||||
|
|||||||
@@ -2,9 +2,10 @@ from collections.abc import Mapping
|
|||||||
from datetime import UTC, datetime
|
from datetime import UTC, datetime
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
|
from motor.motor_asyncio import AsyncIOMotorCollection
|
||||||
|
|
||||||
from core.mongodb import get_database
|
from core.mongodb import get_database
|
||||||
from models.auth import AuthUserDocument
|
from models.auth import AuthUserDocument
|
||||||
from motor.motor_asyncio import AsyncIOMotorCollection
|
|
||||||
|
|
||||||
USERS_COLLECTION_NAME = "auth_users"
|
USERS_COLLECTION_NAME = "auth_users"
|
||||||
REVOKED_COLLECTION_NAME = "revoked_tokens"
|
REVOKED_COLLECTION_NAME = "revoked_tokens"
|
||||||
@@ -2,12 +2,13 @@ from collections.abc import Mapping
|
|||||||
from datetime import UTC, datetime
|
from datetime import UTC, datetime
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
|
from motor.motor_asyncio import AsyncIOMotorCollection
|
||||||
|
from pymongo import ReturnDocument
|
||||||
|
from services.proxy.models import ServiceConfig
|
||||||
|
|
||||||
from core.mongodb import get_database
|
from core.mongodb import get_database
|
||||||
from models.proxy import ProxyDocument, ProxyUpdateInput
|
from models.proxy import ProxyDocument, ProxyUpdateInput
|
||||||
from models.service import ServiceEndpointDocument
|
from models.service import ServiceEndpointDocument
|
||||||
from motor.motor_asyncio import AsyncIOMotorCollection
|
|
||||||
from pymongo import ReturnDocument
|
|
||||||
from utils.proxy.types import ServiceConfig
|
|
||||||
|
|
||||||
COLLECTION_NAME = "proxies"
|
COLLECTION_NAME = "proxies"
|
||||||
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
from utils.proxy.types import ServiceConfig
|
from services.proxy.models import ServiceConfig
|
||||||
|
|
||||||
|
|
||||||
async def create_proxy(
|
async def create_proxy(
|
||||||
@@ -3,7 +3,7 @@ import importlib
|
|||||||
from core.security import get_auth_context, require_authenticated_user
|
from core.security import get_auth_context, require_authenticated_user
|
||||||
from models.proxy import ProxyDocument
|
from models.proxy import ProxyDocument
|
||||||
from models.service import ServiceEndpointDocument
|
from models.service import ServiceEndpointDocument
|
||||||
from utils.proxy.validator import ProxyCodeValidationError
|
from services.proxy.validator import ProxyCodeValidationError
|
||||||
|
|
||||||
proxy_router_module = importlib.import_module("api.proxy.router")
|
proxy_router_module = importlib.import_module("api.proxy.router")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user