feat: initial MVP - FastAPI backend + Vue3 frontend + docker-compose
- backend: FastAPI + SQLAlchemy 2.0(async) + asyncpg + Alembic - 7 API routes: auth/me/articles/sources/bookmarks/subscriptions/admin - models: User/Source/Article/Bookmark/Subscription/ApiToken - services: RSS fetcher (feedparser) + Tencent TMT translator with quota + cache + local NLLB fallback - workers: APScheduler + asyncio pipeline (fetch -> dedupe -> insert -> translate) - seed scripts: create_user, seed_sources (5 RSS: Reuters/BBC/Al Jazeera/NHK/DW) - frontend: Vue 3 + Vite + Naive UI + Pinia + vue-router - pages: Login, Feed (24h), ArticleDetail, Sources, Bookmarks, AdminSources - deploy: docker-compose (postgres/redis/api/worker/frontend/caddy) - docs: README, DEPLOY, architecture, acceptance
This commit is contained in:
51
backend/app/schemas/source.py
Normal file
51
backend/app/schemas/source.py
Normal file
@@ -0,0 +1,51 @@
|
||||
"""Source schemas."""
|
||||
from __future__ import annotations
|
||||
|
||||
from datetime import datetime
|
||||
|
||||
from pydantic import BaseModel, ConfigDict, Field, HttpUrl
|
||||
|
||||
from app.models.source import SourceKind
|
||||
|
||||
|
||||
class SourceOut(BaseModel):
|
||||
model_config = ConfigDict(from_attributes=True)
|
||||
|
||||
id: int
|
||||
name: str
|
||||
slug: str
|
||||
kind: SourceKind
|
||||
url: str
|
||||
enabled: bool
|
||||
region: str | None = None
|
||||
language_src: str | None = None
|
||||
priority: int
|
||||
fetch_interval_min: int
|
||||
translate_to: str
|
||||
last_fetched_at: datetime | None = None
|
||||
last_status: str | None = None
|
||||
consecutive_failures: int = 0
|
||||
|
||||
|
||||
class SourceIn(BaseModel):
|
||||
name: str = Field(min_length=1, max_length=128)
|
||||
slug: str = Field(min_length=1, max_length=128, pattern=r"^[a-z0-9-]+$")
|
||||
kind: SourceKind = SourceKind.RSS
|
||||
url: HttpUrl
|
||||
region: str | None = None
|
||||
language_src: str | None = None
|
||||
priority: int = Field(default=50, ge=1, le=100)
|
||||
fetch_interval_min: int = Field(default=60, ge=5, le=1440)
|
||||
translate_to: str = "zh"
|
||||
enabled: bool = True
|
||||
detail_selector: dict | None = None
|
||||
headers_json: dict | None = None
|
||||
|
||||
|
||||
class SourceUpdate(BaseModel):
|
||||
name: str | None = None
|
||||
enabled: bool | None = None
|
||||
priority: int | None = Field(default=None, ge=1, le=100)
|
||||
fetch_interval_min: int | None = Field(default=None, ge=5, le=1440)
|
||||
region: str | None = None
|
||||
translate_to: str | None = None
|
||||
Reference in New Issue
Block a user