Files
vpn-control-panel/app/api/v1/tariffs.py
smolkik-code 7c7c88621d Initial commit: VPN Control Panel
- FastAPI REST API with JWT auth
- aiogram 3 Telegram bot with admin middleware
- APScheduler daily tasks (expiry, reminders, revoke, sync)
- SQLAlchemy 2 async ORM with Alembic migrations
- Jinja2 admin panel (Dashboard, Users, Payments, Servers, Tariffs)
- VPN provider abstraction with MockProvider
- Stats service with revenue/subscription analytics
- Docker Compose (PostgreSQL + Redis + app)
- Healthcheck endpoint
2026-07-05 17:50:11 +07:00

33 lines
948 B
Python

from fastapi import APIRouter, Depends, HTTPException
from app.api.deps import get_tariff_repo
from app.repositories.tariff import TariffRepository
from app.schemas.tariff import TariffRead
router = APIRouter(prefix="/tariffs", tags=["Tariffs"])
@router.get("", response_model=list[TariffRead])
async def list_tariffs(
tariff_repo: TariffRepository = Depends(get_tariff_repo),
):
return await tariff_repo.get_active_tariffs()
@router.get("/all", response_model=list[TariffRead])
async def list_all_tariffs(
tariff_repo: TariffRepository = Depends(get_tariff_repo),
):
return await tariff_repo.get_all()
@router.get("/{tariff_id}", response_model=TariffRead)
async def get_tariff(
tariff_id: int,
tariff_repo: TariffRepository = Depends(get_tariff_repo),
):
tariff = await tariff_repo.get(tariff_id)
if tariff is None:
raise HTTPException(status_code=404, detail="Tariff not found")
return tariff