Files
please-pay-me/context/2026-09-13_10-25-00_bot-via-api.md
T
2026-09-21 04:06:43 +03:00

19 lines
923 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 2026-09-13 — Бот ходит в БД только через API
## Цель
Единый путь записи/чтения: web и Telegram-бот → FastAPI → SQLite.
Бот больше не монтирует `./data` и не открывает `budget.db`.
## API
- `POST /api/auth/internal` + `X-API-Token` / `API_TOKEN` → JWT как у web
- Бот вызывает те же `/api/me/budget`, `/api/me/expenses`, undo, upsert
- `GET /api/me/expenses?spent_at=YYYY-MM-DD` — траты за день (для /today, /day)
## Bot
- `bot/clients/budget_api.py``BudgetApiClient` (aiohttp)
- `bot/config.py`: `API_BASE_URL`, `API_TOKEN` (обязателен)
- Compose: bot без volume data; `API_BASE_URL=http://127.0.0.1:51291` при host network
## Деплой
Пересобрать `api` + `bot`, убедиться что `API_TOKEN` одинаковый в обоих сервисах.