Compare commits
96 Commits
afd9658005
...
develop
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9094f5e278 | ||
|
|
bb987b1f8b | ||
|
|
3fcaefba1b | ||
|
|
5a375d67c7 | ||
|
|
81446e56f5 | ||
|
|
e14450f373 | ||
|
|
0eca2b1e68 | ||
| 2c3e6578e9 | |||
|
|
69db666a4b | ||
| a4cffbed23 | |||
| d4a18b0759 | |||
|
|
b63e6cc3a8 | ||
| 55833665a8 | |||
| bc4a443f9f | |||
|
|
78623924ef | ||
|
|
7f8d8373a9 | ||
| 33a41ad066 | |||
| 8d6225f136 | |||
|
|
18b3e318ab | ||
|
|
482e8571af | ||
|
|
51f8a125e9 | ||
|
|
a96ef069cc | ||
|
|
ea8fa90a31 | ||
| bbefe7d28a | |||
| 74f17c3f3f | |||
|
|
0cbed8f5ec | ||
| 38ff90b13f | |||
| f22a8049f7 | |||
|
|
de2735eb16 | ||
| 534203b47e | |||
| 5d8b271da2 | |||
|
|
af84137f31 | ||
| d145ff537a | |||
| 3241413d0d | |||
|
|
48029ac276 | ||
| 6f550882f7 | |||
| 1fdfb05f6d | |||
|
|
fd236962b1 | ||
|
|
8b7b732a24 | ||
|
|
2b794f97a3 | ||
|
|
4712604171 | ||
|
|
7e4dbd7e56 | ||
|
|
05a8f0cbc7 | ||
|
|
9ec570688c | ||
|
|
3bf3e2a233 | ||
|
|
c2d5178b33 | ||
|
|
2c198e56eb | ||
|
|
15cf6cca8a | ||
|
|
d9cf0ade7f | ||
| 48bcbe6f06 | |||
| bce5ad2f9a | |||
|
|
3066ceb751 | ||
|
|
809879971a | ||
| 2c228c0312 | |||
| 7464828e07 | |||
|
|
045d329a1e | ||
|
|
54436e9cba | ||
|
|
0804e4e80a | ||
|
|
4a5c42ca06 | ||
|
|
a58e0f4451 | ||
|
|
7822da7e5c | ||
|
|
53d8760912 | ||
|
|
c62dd7f421 | ||
| ce5e355c08 | |||
| fac6c1a1b1 | |||
|
|
26216a25f7 | ||
|
|
37fc9a36b4 | ||
|
|
01b6ab746e | ||
| 63c6c2a45c | |||
|
|
83cf741f4e | ||
|
|
fb98f2d127 | ||
|
|
9b9d45e0a6 | ||
|
|
44406b02d3 | ||
|
|
440b836d54 | ||
|
|
d98f7080eb | ||
|
|
254673f2d8 | ||
|
|
503f18d976 | ||
|
|
5560cf9699 | ||
|
|
a56fe30f83 | ||
| c2bceaf479 | |||
|
|
251b5abf85 | ||
|
|
d5b16a1254 | ||
|
|
a476eab111 | ||
|
|
b7685b2ab7 | ||
|
|
43005c132c | ||
|
|
521e9bfe06 | ||
|
|
01eab6213a | ||
|
|
ba7b7eb763 | ||
| a99a4cf870 | |||
|
|
bf4b4748cb | ||
|
|
68fba12f47 | ||
|
|
3f61ff7b4a | ||
|
|
e6c1626862 | ||
|
|
c31081e0f3 | ||
|
|
fd217625a0 | ||
|
|
94aae8e3ec |
60
.gitea/workflows/cd-back.yml
Normal file
60
.gitea/workflows/cd-back.yml
Normal file
@@ -0,0 +1,60 @@
|
||||
name: Backend deploy
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
deploy-backend:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Import Secrets
|
||||
id: import-secrets
|
||||
uses: hashicorp/vault-action@v3.4.0
|
||||
with:
|
||||
url: https://vault.d3m0k1d.ru
|
||||
token: ${{ secrets.VAULT }}
|
||||
secrets: |
|
||||
secrets/site/prod/data/gitea TOKEN | GITEA_TOKEN ;
|
||||
secrets/site/prod/data/server SSH_KEY | SSH_KEY ;
|
||||
secrets/site/prod/data/server USER | SERVER_USER ;
|
||||
secrets/site/prod/data/server HOST | SERVER_HOST ;
|
||||
secrets/site/prod/data/server PORT | SERVER_PORT ;
|
||||
secrets/site/prod/data/auth GITHUB_CLIENT_ID | GITHUB_CLIENT_ID ;
|
||||
secrets/site/prod/data/auth GITHUB_CLIENT_SECRET | GITHUB_CLIENT_SECRET ;
|
||||
secrets/site/prod/data/auth JWT_SECRET | JWT_SECRET
|
||||
|
||||
- name: Login to registry
|
||||
run: echo "${{ steps.import-secrets.outputs.GITEA_TOKEN }}" | docker login gitea.d3m0k1d.ru -u d3m0k1d --password-stdin
|
||||
|
||||
- name: Build and push
|
||||
run: |
|
||||
docker build -t gitea.d3m0k1d.ru/d3m0k1d/backend:latest ./backend
|
||||
docker push gitea.d3m0k1d.ru/d3m0k1d/backend:latest
|
||||
|
||||
- name: Deploy at server
|
||||
uses: appleboy/ssh-action@v1.2.0
|
||||
with:
|
||||
host: ${{ steps.import-secrets.outputs.SERVER_HOST }}
|
||||
port: ${{ steps.import-secrets.outputs.SERVER_PORT }}
|
||||
username: ${{ steps.import-secrets.outputs.SERVER_USER }}
|
||||
key: ${{ steps.import-secrets.outputs.SSH_KEY }}
|
||||
script: |
|
||||
mkdir -p /opt/d3m0k1d/data
|
||||
docker login -u d3m0k1d -p ${{ steps.import-secrets.outputs.GITEA_TOKEN }} gitea.d3m0k1d.ru
|
||||
docker pull gitea.d3m0k1d.ru/d3m0k1d/backend:latest
|
||||
docker rm -f d3m0k1d-backend || true
|
||||
docker run --name d3m0k1d-backend -d -p 8080:8080 \
|
||||
--network d3m0k1d-network \
|
||||
-v /opt/d3m0k1d/data:/data \
|
||||
-e DB_PATH="/data/d3m0k1d.db" \
|
||||
-e JWT_SECRET="${{ steps.import-secrets.outputs.JWT_SECRET }}" \
|
||||
-e GITHUB_CLIENT_ID="${{ steps.import-secrets.outputs.GITHUB_CLIENT_ID }}" \
|
||||
-e GITHUB_CLIENT_SECRET="${{ steps.import-secrets.outputs.GITHUB_CLIENT_SECRET }}" \
|
||||
-e REDIRECT_URL="https://d3m0k1d.ru/api/v1/callback/github" \
|
||||
--restart unless-stopped \
|
||||
gitea.d3m0k1d.ru/d3m0k1d/backend:latest
|
||||
47
.gitea/workflows/cd-front.yml
Normal file
47
.gitea/workflows/cd-front.yml
Normal file
@@ -0,0 +1,47 @@
|
||||
name: Frontend deploy
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
deploy-frontend:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Import Secrets
|
||||
id: import-secrets
|
||||
uses: hashicorp/vault-action@v3.4.0
|
||||
with:
|
||||
url: https://vault.d3m0k1d.ru
|
||||
token: ${{ secrets.VAULT }}
|
||||
secrets: |
|
||||
secrets/site/prod/data/gitea TOKEN | GITEA_TOKEN ;
|
||||
secrets/site/prod/data/server SSH_KEY | SSH_KEY ;
|
||||
secrets/site/prod/data/server USER | SERVER_USER ;
|
||||
secrets/site/prod/data/server HOST | SERVER_HOST ;
|
||||
secrets/site/prod/data/server PORT | SERVER_PORT
|
||||
|
||||
- name: Login to registry
|
||||
run: echo "${{ steps.import-secrets.outputs.GITEA_TOKEN }}" | docker login gitea.d3m0k1d.ru -u d3m0k1d --password-stdin
|
||||
|
||||
- name: Build and push
|
||||
run: |
|
||||
docker build -t gitea.d3m0k1d.ru/d3m0k1d/frontend:latest ./frontend
|
||||
docker push gitea.d3m0k1d.ru/d3m0k1d/frontend:latest
|
||||
|
||||
- name: Deploy at server
|
||||
uses: appleboy/ssh-action@v1.2.0
|
||||
with:
|
||||
host: ${{ steps.import-secrets.outputs.SERVER_HOST }}
|
||||
port: ${{ steps.import-secrets.outputs.SERVER_PORT }}
|
||||
username: ${{ steps.import-secrets.outputs.SERVER_USER }}
|
||||
key: ${{ steps.import-secrets.outputs.SSH_KEY }}
|
||||
script: |
|
||||
docker login -u d3m0k1d -p ${{ steps.import-secrets.outputs.GITEA_TOKEN }} gitea.d3m0k1d.ru
|
||||
docker pull gitea.d3m0k1d.ru/d3m0k1d/frontend:latest
|
||||
docker rm -f d3m0k1d-frontend || true
|
||||
docker run --name d3m0k1d-frontend -d -p 80:80 --restart unless-stopped --network d3m0k1d-network gitea.d3m0k1d.ru/d3m0k1d/frontend:latest
|
||||
@@ -1,40 +0,0 @@
|
||||
name: Deploy
|
||||
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
|
||||
|
||||
|
||||
jobs:
|
||||
deploy-frontend:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Login to registry
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: gitea.d3m0k1d.ru
|
||||
username: d3m0k1d
|
||||
password: ${{ secrets.TOKEN }}
|
||||
|
||||
- name: Download QEMU
|
||||
uses: docker/setup-qemu-action@v3
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Build and push
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: ./frontend
|
||||
file: ./frontend/Dockerfile
|
||||
push: true
|
||||
tags: gitea.d3m0k1d.ru/d3m0k1d/frontend:latest
|
||||
- name: Deploy at server
|
||||
uses: appleboy/ssh-action@v1.2.5
|
||||
with:
|
||||
|
||||
|
||||
|
||||
36
.gitea/workflows/ci-back.yml
Normal file
36
.gitea/workflows/ci-back.yml
Normal file
@@ -0,0 +1,36 @@
|
||||
name: Backend ci
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches:
|
||||
- master
|
||||
defaults:
|
||||
run:
|
||||
working-directory: backend
|
||||
|
||||
|
||||
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v6
|
||||
- name: Go setup
|
||||
uses: actions/setup-go@v6
|
||||
with:
|
||||
go-version: '1.25.6'
|
||||
cache: false
|
||||
- name: Install deps
|
||||
run: go mod tidy
|
||||
- name: Golangci-lint
|
||||
uses: golangci/golangci-lint-action@v9.2.0
|
||||
with:
|
||||
working-directory: backend
|
||||
args: --timeout=5m
|
||||
skip-cache: true
|
||||
- name: Run tests
|
||||
run: go test ./...
|
||||
- name: Build
|
||||
run: go build -o backend ./cmd/main.go
|
||||
6
backend/.dockerignore
Normal file
6
backend/.dockerignore
Normal file
@@ -0,0 +1,6 @@
|
||||
.git
|
||||
docker-compose.yml
|
||||
data/
|
||||
Makefile
|
||||
.env
|
||||
docs/
|
||||
3
backend/.gitignore
vendored
Normal file
3
backend/.gitignore
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
/bin
|
||||
/data
|
||||
.env
|
||||
21
backend/.golangci.yml
Normal file
21
backend/.golangci.yml
Normal file
@@ -0,0 +1,21 @@
|
||||
version: "2"
|
||||
run:
|
||||
timeout: 5m
|
||||
tests: false
|
||||
build-tags:
|
||||
- integration
|
||||
|
||||
linters:
|
||||
enable:
|
||||
- errcheck
|
||||
- errname
|
||||
- govet
|
||||
- staticcheck
|
||||
- gosec
|
||||
- nilerr
|
||||
|
||||
formatters:
|
||||
enable:
|
||||
- gofmt
|
||||
- goimports
|
||||
- golines
|
||||
23
backend/Dockerfile
Normal file
23
backend/Dockerfile
Normal file
@@ -0,0 +1,23 @@
|
||||
FROM golang:1.25.6 AS builder
|
||||
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
ENV CGO_ENABLED=0
|
||||
ENV GIN_MODE=release
|
||||
|
||||
COPY go.mod go.sum ./
|
||||
RUN go mod download
|
||||
|
||||
COPY . .
|
||||
RUN go build -ldflags "-s -w" -o backend ./cmd/main.go
|
||||
|
||||
|
||||
FROM alpine:3.23.0
|
||||
RUN adduser -D appuser && apk add --no-cache curl
|
||||
COPY --from=builder /app/backend .
|
||||
RUN chown appuser:appuser ./backend
|
||||
USER appuser
|
||||
EXPOSE 8080
|
||||
HEALTHCHECK CMD curl --fail http://localhost:8080/health || exit 1
|
||||
CMD ["./backend"]
|
||||
37
backend/Makefile
Normal file
37
backend/Makefile
Normal file
@@ -0,0 +1,37 @@
|
||||
.PHONY: test build clean lint dev run-docker docs-upd docker docker-run
|
||||
|
||||
|
||||
test:
|
||||
go test -cover ./...
|
||||
|
||||
|
||||
build:
|
||||
go build -o bin/d3m0k1d.ru backend/main.go
|
||||
|
||||
|
||||
clean:
|
||||
rm -f bin/d3m0k1d.ru
|
||||
|
||||
|
||||
lint:
|
||||
golangci-lint run --fix
|
||||
|
||||
dev:
|
||||
swag init -g ./cmd/main.go --parseDependency --parseInternal
|
||||
go run ./cmd/main.go
|
||||
|
||||
|
||||
docs-upd:
|
||||
swag init -g ./cmd/main.go --parseDependency --parseInternal
|
||||
|
||||
|
||||
docker:
|
||||
swag init -g ./cmd/main.go --parseDependency --parseInternal
|
||||
docker build -t backend .
|
||||
|
||||
docker-run:
|
||||
docker run --rm -p 8080:8080 --env-file .env --network host -v /opt/d3m0k1d.ru/data:/data backend:latest
|
||||
|
||||
run-docker:
|
||||
docker build -t backend .
|
||||
docker run --rm -p 8080:8080 --env-file .env backend:latest
|
||||
@@ -1,5 +0,0 @@
|
||||
POSTGRES_USER=
|
||||
POSTGRES_PASSWORD=
|
||||
POSTGRES_DB=
|
||||
POSTGRES_HOST=
|
||||
POSTGRES_PORT=
|
||||
@@ -1,91 +0,0 @@
|
||||
from typing import Optional, Sequence
|
||||
from fastapi import APIRouter, Depends, HTTPException, Query
|
||||
from sqlalchemy import select, delete
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
from app.schemas.posts import PostCreate, PostRead
|
||||
from app.db_engine import get_async_session
|
||||
from app.models.posts import Post
|
||||
|
||||
|
||||
router = APIRouter(
|
||||
prefix="/posts",
|
||||
tags=["posts"],
|
||||
responses={404: {"description": "Not found"}},
|
||||
)
|
||||
|
||||
|
||||
@router.get("/")
|
||||
async def get_posts(
|
||||
page: int = Query(1, ge=1),
|
||||
page_size: int = Query(10, ge=1, le=100),
|
||||
db: AsyncSession = Depends(get_async_session),
|
||||
):
|
||||
offset = (page - 1) * page_size
|
||||
|
||||
stmt = select(Post).order_by(Post.id).offset(offset).limit(page_size)
|
||||
|
||||
result = await db.execute(stmt)
|
||||
posts: Sequence[Post] = result.scalars().all()
|
||||
|
||||
return posts
|
||||
|
||||
|
||||
@router.get("/{id}", response_model=PostRead)
|
||||
async def get_post(id: int, db: AsyncSession = Depends(get_async_session)):
|
||||
post = await db.get(Post, id)
|
||||
if post is None:
|
||||
raise HTTPException(status_code=404, detail="Post not found")
|
||||
else:
|
||||
return post
|
||||
|
||||
|
||||
@router.post("/", response_model=PostRead)
|
||||
async def create_post(
|
||||
title: str,
|
||||
content: str,
|
||||
images: Optional[str] = None,
|
||||
db: AsyncSession = Depends(get_async_session),
|
||||
) -> Post:
|
||||
try:
|
||||
post = PostCreate(title=title, content=content, images=images)
|
||||
except ValueError as e:
|
||||
raise HTTPException(status_code=422, detail=str(e))
|
||||
new_post = Post(title=post.title, content=post.content, images=post.images)
|
||||
db.add(new_post)
|
||||
await db.commit()
|
||||
await db.refresh(new_post)
|
||||
return new_post
|
||||
|
||||
|
||||
@router.put("/{id}")
|
||||
async def update_post(
|
||||
id: int,
|
||||
db: AsyncSession = Depends(get_async_session),
|
||||
title: Optional[str] = None,
|
||||
content: Optional[str] = None,
|
||||
images: Optional[str] = None,
|
||||
):
|
||||
s = select(Post).where(Post.id == id)
|
||||
result = await db.execute(s)
|
||||
post = result.scalars().first()
|
||||
|
||||
if post is None:
|
||||
raise HTTPException(status_code=404, detail="Post not found")
|
||||
|
||||
if title is not None:
|
||||
post.title = title # type: ignore
|
||||
if content is not None:
|
||||
post.content = content # type: ignore
|
||||
if images is not None:
|
||||
post.images = images # type: ignore
|
||||
|
||||
await db.commit()
|
||||
return post
|
||||
|
||||
|
||||
@router.delete("/{id}")
|
||||
async def delete_post(id: int, db: AsyncSession = Depends(get_async_session)):
|
||||
s = delete(Post).where(Post.id == id)
|
||||
await db.execute(s)
|
||||
await db.commit()
|
||||
return {"message": "Post deleted"}
|
||||
@@ -1,42 +0,0 @@
|
||||
from sqlalchemy.ext.asyncio import AsyncSession, create_async_engine, async_sessionmaker
|
||||
from sqlalchemy.orm import DeclarativeBase
|
||||
import dotenv
|
||||
import os
|
||||
|
||||
dotenv.load_dotenv()
|
||||
|
||||
PG_USER = dotenv.get_key(".env", "POSTGRES_USER")
|
||||
PG_PASSWORD = dotenv.get_key(".env", "POSTGRES_PASSWORD")
|
||||
PG_HOST = dotenv.get_key(".env", "POSTGRES_HOST")
|
||||
PG_PORT = dotenv.get_key(".env", "POSTGRES_PORT")
|
||||
PG_DB = dotenv.get_key(".env", "POSTGRES_DB")
|
||||
|
||||
DATABASE_URL = (
|
||||
f"postgresql+asyncpg://{PG_USER}:{PG_PASSWORD}@{PG_HOST}:{PG_PORT}/{PG_DB}"
|
||||
)
|
||||
|
||||
engine = create_async_engine(
|
||||
DATABASE_URL,
|
||||
echo=False,
|
||||
future=True,
|
||||
)
|
||||
|
||||
async_session_maker = async_sessionmaker(
|
||||
engine,
|
||||
class_=AsyncSession,
|
||||
expire_on_commit=False,
|
||||
)
|
||||
|
||||
|
||||
class Base(DeclarativeBase):
|
||||
pass
|
||||
|
||||
|
||||
async def get_async_session():
|
||||
async with async_session_maker() as session:
|
||||
yield session
|
||||
|
||||
|
||||
async def init_db():
|
||||
async with engine.begin() as conn:
|
||||
await conn.run_sync(Base.metadata.create_all)
|
||||
@@ -1,9 +0,0 @@
|
||||
from app.db_engine import init_db
|
||||
|
||||
from app.models.posts import Post
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
import asyncio
|
||||
|
||||
asyncio.run(init_db())
|
||||
@@ -1,12 +0,0 @@
|
||||
import fastapi
|
||||
import uvicorn
|
||||
|
||||
#Import routes
|
||||
from app.api.v1.posts import router as post_router
|
||||
|
||||
app = fastapi.FastAPI()
|
||||
|
||||
#Include routes
|
||||
app.include_router(post_router)
|
||||
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
from sqlalchemy import Column, Integer, String, ForeignKey, DateTime
|
||||
from sqlalchemy.orm import relationship
|
||||
|
||||
from app.db_engine import Base
|
||||
|
||||
|
||||
class Post(Base):
|
||||
__tablename__ = "posts"
|
||||
|
||||
id = Column(Integer, primary_key=True, index=True, autoincrement=True, nullable=False)
|
||||
title = Column(String, index=True, nullable=False)
|
||||
content = Column(String, index=True, nullable=False)
|
||||
images = Column(String, index=True)
|
||||
updated_at = Column(DateTime, index=True)
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
from pydantic import BaseModel, Field
|
||||
from typing import Optional
|
||||
|
||||
|
||||
class PostCreate(BaseModel):
|
||||
title: str = Field(min_length=3, max_length=150)
|
||||
content: str = Field(min_length=10)
|
||||
images: Optional[str] = Field(min_length=0)
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
||||
|
||||
|
||||
class PostRead(BaseModel):
|
||||
id: int = Field()
|
||||
title: str = Field(min_length=3, max_length=150)
|
||||
content: str = Field(min_length=10)
|
||||
images: str = Field()
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
||||
|
||||
|
||||
class PostUpdate(BaseModel):
|
||||
title: str = Field(min_length=3, max_length=150)
|
||||
content: str = Field(min_length=10)
|
||||
images: Optional[str] = Field(default=None)
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
||||
53
backend/cmd/main.go
Normal file
53
backend/cmd/main.go
Normal file
@@ -0,0 +1,53 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"gitea.d3m0k1d.ru/d3m0k1d/d3m0k1d.ru/backend/docs"
|
||||
"gitea.d3m0k1d.ru/d3m0k1d/d3m0k1d.ru/backend/internal/handlers"
|
||||
"gitea.d3m0k1d.ru/d3m0k1d/d3m0k1d.ru/backend/internal/logger"
|
||||
"gitea.d3m0k1d.ru/d3m0k1d/d3m0k1d.ru/backend/internal/storage"
|
||||
"github.com/gin-gonic/gin"
|
||||
swaggerFiles "github.com/swaggo/files"
|
||||
ginSwagger "github.com/swaggo/gin-swagger"
|
||||
)
|
||||
|
||||
// @securityDefinitions.apikey Bearer
|
||||
// @in header
|
||||
// @name Authorization
|
||||
// @description Type "Bearer" followed by a space and the JWT token.
|
||||
func main() {
|
||||
log := logger.New(false)
|
||||
|
||||
db, err := storage.OpenSession()
|
||||
if err != nil {
|
||||
log.Error("Failed to open database", "error", err)
|
||||
panic(err)
|
||||
}
|
||||
defer func() {
|
||||
err := db.Close()
|
||||
if err != nil {
|
||||
log.Error("Failed to close database", "error", err)
|
||||
}
|
||||
}()
|
||||
if err := storage.CreateTables(db); err != nil {
|
||||
log.Error("Failed to create tables", "error", err)
|
||||
panic(err)
|
||||
}
|
||||
|
||||
router := gin.Default()
|
||||
|
||||
// Swagger config
|
||||
docs.SwaggerInfo.BasePath = "/api/v1"
|
||||
docs.SwaggerInfo.Title = "d3m0k1d.ru API"
|
||||
docs.SwaggerInfo.Version = "1.0"
|
||||
docs.SwaggerInfo.Description = "API for d3m0k1d.ru"
|
||||
docs.SwaggerInfo.Schemes = []string{"http"}
|
||||
router.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))
|
||||
|
||||
handlers.Register(router, db)
|
||||
|
||||
log.Info("Starting server on :8080...")
|
||||
if err := router.Run(":8080"); err != nil {
|
||||
log.Error("Error starting server", "error", err)
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
@@ -1,37 +1,12 @@
|
||||
services:
|
||||
postgres:
|
||||
image: postgres:18-alpine3.22
|
||||
restart: always
|
||||
ports:
|
||||
- "5432:5432"
|
||||
environment:
|
||||
POSTGRES_USER: ${POSTGRES_USER}
|
||||
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
|
||||
POSTGRES_DB: ${POSTGRES_DB}
|
||||
volumes:
|
||||
- postgres:/var/lib/postgresql/data
|
||||
networks:
|
||||
- backend
|
||||
|
||||
backend:
|
||||
build: .
|
||||
image: backend:latest
|
||||
env_file:
|
||||
- .env
|
||||
ports:
|
||||
- "8000:8000"
|
||||
environment:
|
||||
- POSTGRES_USER=${POSTGRES_USER}
|
||||
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
|
||||
- POSTGRES_DB=${POSTGRES_DB}
|
||||
- POSTGRES_HOST=${POSTGRES_HOST}
|
||||
- POSTGRES_PORT=${POSTGRES_PORT}
|
||||
depends_on:
|
||||
- postgres
|
||||
networks:
|
||||
- backend
|
||||
- 8080:8080
|
||||
volumes:
|
||||
- db-data:/var/lib/backend/data
|
||||
|
||||
volumes:
|
||||
postgres:
|
||||
driver: local
|
||||
|
||||
networks:
|
||||
backend:
|
||||
driver: bridge
|
||||
db-data:
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
FROM python:3.13-slim-trixie
|
||||
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
|
||||
|
||||
|
||||
WORKDIR /app
|
||||
COPY pyproject.toml uv.lock ./
|
||||
|
||||
RUN uv sync
|
||||
|
||||
COPY . .
|
||||
|
||||
EXPOSE 8000
|
||||
|
||||
|
||||
CMD ["uv", "run", "uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]
|
||||
667
backend/docs/docs.go
Normal file
667
backend/docs/docs.go
Normal file
@@ -0,0 +1,667 @@
|
||||
// Package docs Code generated by swaggo/swag. DO NOT EDIT
|
||||
package docs
|
||||
|
||||
import "github.com/swaggo/swag"
|
||||
|
||||
const docTemplate = `{
|
||||
"schemes": {{ marshal .Schemes }},
|
||||
"swagger": "2.0",
|
||||
"info": {
|
||||
"description": "{{escape .Description}}",
|
||||
"title": "{{.Title}}",
|
||||
"contact": {},
|
||||
"version": "{{.Version}}"
|
||||
},
|
||||
"host": "{{.Host}}",
|
||||
"basePath": "{{.BasePath}}",
|
||||
"paths": {
|
||||
"/admin/posts": {
|
||||
"get": {
|
||||
"security": [
|
||||
{
|
||||
"Bearer": []
|
||||
}
|
||||
],
|
||||
"description": "Get all posts",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"admin"
|
||||
],
|
||||
"summary": "Get all posts",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/definitions/gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_models.SuccessResponse"
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"data": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_storage.PostReq"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Invalid ID format",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_models.ErrorResponse"
|
||||
}
|
||||
},
|
||||
"404": {
|
||||
"description": "No Post found",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_models.ErrorResponse"
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "Internal server error",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_models.ErrorResponse"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/auth/github": {
|
||||
"get": {
|
||||
"description": "Redirects to GitHub authorization",
|
||||
"tags": [
|
||||
"auth"
|
||||
],
|
||||
"summary": "Start GitHub OAuth login",
|
||||
"responses": {
|
||||
"302": {
|
||||
"description": "Found"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/callback/github": {
|
||||
"get": {
|
||||
"description": "Exchanges authorization code for access token",
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"auth"
|
||||
],
|
||||
"summary": "GitHub OAuth callback",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Authorization code",
|
||||
"name": "code",
|
||||
"in": "query",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "Access token",
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"additionalProperties": true
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Missing code",
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "Exchange failed",
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/posts": {
|
||||
"get": {
|
||||
"description": "Get all posts",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"posts"
|
||||
],
|
||||
"summary": "Get all published posts",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/definitions/gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_models.SuccessResponse"
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"data": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_storage.PostReq"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Invalid ID format",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_models.ErrorResponse"
|
||||
}
|
||||
},
|
||||
"404": {
|
||||
"description": "No Post found",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_models.ErrorResponse"
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "Internal server error",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_models.ErrorResponse"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"post": {
|
||||
"security": [
|
||||
{
|
||||
"Bearer": []
|
||||
}
|
||||
],
|
||||
"description": "Create new post",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"posts"
|
||||
],
|
||||
"summary": "Create post",
|
||||
"parameters": [
|
||||
{
|
||||
"description": "Post data",
|
||||
"name": "post",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_storage.PostCreate"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/definitions/gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_models.SuccessResponse"
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"data": {
|
||||
"$ref": "#/definitions/gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_storage.Post"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Invalid request",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_models.ErrorResponse"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/posts/{id}": {
|
||||
"get": {
|
||||
"description": "Get post by id",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"posts"
|
||||
],
|
||||
"summary": "Get post by id",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "Post ID",
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/definitions/gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_models.SuccessResponse"
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"data": {
|
||||
"$ref": "#/definitions/gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_storage.PostReq"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Invalid ID format",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_models.ErrorResponse"
|
||||
}
|
||||
},
|
||||
"404": {
|
||||
"description": "Post not found",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_models.ErrorResponse"
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "Internal server error",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_models.ErrorResponse"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"put": {
|
||||
"security": [
|
||||
{
|
||||
"Bearer": []
|
||||
}
|
||||
],
|
||||
"description": "Update post",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"posts"
|
||||
],
|
||||
"summary": "Update post",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "Post ID",
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"description": "Post data",
|
||||
"name": "post",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_storage.PostCreate"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/definitions/gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_models.SuccessResponse"
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"data": {
|
||||
"$ref": "#/definitions/gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_storage.PostCreate"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Invalid ID format",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_models.ErrorResponse"
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "Internal server error",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_models.ErrorResponse"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"delete": {
|
||||
"security": [
|
||||
{
|
||||
"Bearer": []
|
||||
}
|
||||
],
|
||||
"description": "Delete post",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"posts"
|
||||
],
|
||||
"summary": "Delete post",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "Post ID",
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/definitions/gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_models.SuccessResponse"
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"data": {
|
||||
"$ref": "#/definitions/gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_storage.Post"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Invalid ID format",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_models.ErrorResponse"
|
||||
}
|
||||
},
|
||||
"404": {
|
||||
"description": "Post not found",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_models.ErrorResponse"
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "Internal server error",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_models.ErrorResponse"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/session": {
|
||||
"get": {
|
||||
"description": "Returns user session data",
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"auth"
|
||||
],
|
||||
"summary": "Get user session",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "Session data",
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"additionalProperties": true
|
||||
}
|
||||
},
|
||||
"401": {
|
||||
"description": "Unauthorized",
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/upload": {
|
||||
"post": {
|
||||
"description": "Upload static content to the server",
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"static"
|
||||
],
|
||||
"summary": "Upload static content",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_models.SuccessResponse"
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "Internal server error",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_models.ErrorResponse"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/upload/{file}": {
|
||||
"get": {
|
||||
"description": "Get static content",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"static"
|
||||
],
|
||||
"summary": "Get static content",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "File name",
|
||||
"name": "file",
|
||||
"in": "path",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "Static content",
|
||||
"schema": {
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/definitions/gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_models.SuccessResponse"
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"data": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"404": {
|
||||
"description": "File not found",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_models.ErrorResponse"
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "Internal server error",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_models.ErrorResponse"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"definitions": {
|
||||
"gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_models.ErrorDetail": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"code": {
|
||||
"type": "integer"
|
||||
},
|
||||
"detail": {
|
||||
"type": "string"
|
||||
},
|
||||
"message": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_models.ErrorResponse": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"error": {
|
||||
"$ref": "#/definitions/gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_models.ErrorDetail"
|
||||
}
|
||||
}
|
||||
},
|
||||
"gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_models.SuccessResponse": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"data": {}
|
||||
}
|
||||
},
|
||||
"gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_storage.Post": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"content": {
|
||||
"type": "string"
|
||||
},
|
||||
"created_at": {
|
||||
"type": "string"
|
||||
},
|
||||
"id": {
|
||||
"type": "integer"
|
||||
},
|
||||
"published": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"title": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_storage.PostCreate": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"content": {
|
||||
"type": "string"
|
||||
},
|
||||
"published": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"title": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_storage.PostReq": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"content": {
|
||||
"type": "string"
|
||||
},
|
||||
"created_at": {
|
||||
"type": "string"
|
||||
},
|
||||
"id": {
|
||||
"type": "integer"
|
||||
},
|
||||
"title": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"securityDefinitions": {
|
||||
"Bearer": {
|
||||
"description": "Type \"Bearer\" followed by a space and the JWT token.",
|
||||
"type": "apiKey",
|
||||
"name": "Authorization",
|
||||
"in": "header"
|
||||
}
|
||||
}
|
||||
}`
|
||||
|
||||
// SwaggerInfo holds exported Swagger Info so clients can modify it
|
||||
var SwaggerInfo = &swag.Spec{
|
||||
Version: "",
|
||||
Host: "",
|
||||
BasePath: "",
|
||||
Schemes: []string{},
|
||||
Title: "",
|
||||
Description: "",
|
||||
InfoInstanceName: "swagger",
|
||||
SwaggerTemplate: docTemplate,
|
||||
LeftDelim: "{{",
|
||||
RightDelim: "}}",
|
||||
}
|
||||
|
||||
func init() {
|
||||
swag.Register(SwaggerInfo.InstanceName(), SwaggerInfo)
|
||||
}
|
||||
638
backend/docs/swagger.json
Normal file
638
backend/docs/swagger.json
Normal file
@@ -0,0 +1,638 @@
|
||||
{
|
||||
"swagger": "2.0",
|
||||
"info": {
|
||||
"contact": {}
|
||||
},
|
||||
"paths": {
|
||||
"/admin/posts": {
|
||||
"get": {
|
||||
"security": [
|
||||
{
|
||||
"Bearer": []
|
||||
}
|
||||
],
|
||||
"description": "Get all posts",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"admin"
|
||||
],
|
||||
"summary": "Get all posts",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/definitions/gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_models.SuccessResponse"
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"data": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_storage.PostReq"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Invalid ID format",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_models.ErrorResponse"
|
||||
}
|
||||
},
|
||||
"404": {
|
||||
"description": "No Post found",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_models.ErrorResponse"
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "Internal server error",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_models.ErrorResponse"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/auth/github": {
|
||||
"get": {
|
||||
"description": "Redirects to GitHub authorization",
|
||||
"tags": [
|
||||
"auth"
|
||||
],
|
||||
"summary": "Start GitHub OAuth login",
|
||||
"responses": {
|
||||
"302": {
|
||||
"description": "Found"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/callback/github": {
|
||||
"get": {
|
||||
"description": "Exchanges authorization code for access token",
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"auth"
|
||||
],
|
||||
"summary": "GitHub OAuth callback",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Authorization code",
|
||||
"name": "code",
|
||||
"in": "query",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "Access token",
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"additionalProperties": true
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Missing code",
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "Exchange failed",
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/posts": {
|
||||
"get": {
|
||||
"description": "Get all posts",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"posts"
|
||||
],
|
||||
"summary": "Get all published posts",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/definitions/gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_models.SuccessResponse"
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"data": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_storage.PostReq"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Invalid ID format",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_models.ErrorResponse"
|
||||
}
|
||||
},
|
||||
"404": {
|
||||
"description": "No Post found",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_models.ErrorResponse"
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "Internal server error",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_models.ErrorResponse"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"post": {
|
||||
"security": [
|
||||
{
|
||||
"Bearer": []
|
||||
}
|
||||
],
|
||||
"description": "Create new post",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"posts"
|
||||
],
|
||||
"summary": "Create post",
|
||||
"parameters": [
|
||||
{
|
||||
"description": "Post data",
|
||||
"name": "post",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_storage.PostCreate"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/definitions/gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_models.SuccessResponse"
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"data": {
|
||||
"$ref": "#/definitions/gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_storage.Post"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Invalid request",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_models.ErrorResponse"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/posts/{id}": {
|
||||
"get": {
|
||||
"description": "Get post by id",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"posts"
|
||||
],
|
||||
"summary": "Get post by id",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "Post ID",
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/definitions/gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_models.SuccessResponse"
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"data": {
|
||||
"$ref": "#/definitions/gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_storage.PostReq"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Invalid ID format",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_models.ErrorResponse"
|
||||
}
|
||||
},
|
||||
"404": {
|
||||
"description": "Post not found",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_models.ErrorResponse"
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "Internal server error",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_models.ErrorResponse"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"put": {
|
||||
"security": [
|
||||
{
|
||||
"Bearer": []
|
||||
}
|
||||
],
|
||||
"description": "Update post",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"posts"
|
||||
],
|
||||
"summary": "Update post",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "Post ID",
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"description": "Post data",
|
||||
"name": "post",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_storage.PostCreate"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/definitions/gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_models.SuccessResponse"
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"data": {
|
||||
"$ref": "#/definitions/gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_storage.PostCreate"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Invalid ID format",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_models.ErrorResponse"
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "Internal server error",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_models.ErrorResponse"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"delete": {
|
||||
"security": [
|
||||
{
|
||||
"Bearer": []
|
||||
}
|
||||
],
|
||||
"description": "Delete post",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"posts"
|
||||
],
|
||||
"summary": "Delete post",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "Post ID",
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/definitions/gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_models.SuccessResponse"
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"data": {
|
||||
"$ref": "#/definitions/gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_storage.Post"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Invalid ID format",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_models.ErrorResponse"
|
||||
}
|
||||
},
|
||||
"404": {
|
||||
"description": "Post not found",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_models.ErrorResponse"
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "Internal server error",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_models.ErrorResponse"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/session": {
|
||||
"get": {
|
||||
"description": "Returns user session data",
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"auth"
|
||||
],
|
||||
"summary": "Get user session",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "Session data",
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"additionalProperties": true
|
||||
}
|
||||
},
|
||||
"401": {
|
||||
"description": "Unauthorized",
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/upload": {
|
||||
"post": {
|
||||
"description": "Upload static content to the server",
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"static"
|
||||
],
|
||||
"summary": "Upload static content",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_models.SuccessResponse"
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "Internal server error",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_models.ErrorResponse"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/upload/{file}": {
|
||||
"get": {
|
||||
"description": "Get static content",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"static"
|
||||
],
|
||||
"summary": "Get static content",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "File name",
|
||||
"name": "file",
|
||||
"in": "path",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "Static content",
|
||||
"schema": {
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/definitions/gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_models.SuccessResponse"
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"data": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"404": {
|
||||
"description": "File not found",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_models.ErrorResponse"
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "Internal server error",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_models.ErrorResponse"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"definitions": {
|
||||
"gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_models.ErrorDetail": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"code": {
|
||||
"type": "integer"
|
||||
},
|
||||
"detail": {
|
||||
"type": "string"
|
||||
},
|
||||
"message": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_models.ErrorResponse": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"error": {
|
||||
"$ref": "#/definitions/gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_models.ErrorDetail"
|
||||
}
|
||||
}
|
||||
},
|
||||
"gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_models.SuccessResponse": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"data": {}
|
||||
}
|
||||
},
|
||||
"gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_storage.Post": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"content": {
|
||||
"type": "string"
|
||||
},
|
||||
"created_at": {
|
||||
"type": "string"
|
||||
},
|
||||
"id": {
|
||||
"type": "integer"
|
||||
},
|
||||
"published": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"title": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_storage.PostCreate": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"content": {
|
||||
"type": "string"
|
||||
},
|
||||
"published": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"title": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_storage.PostReq": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"content": {
|
||||
"type": "string"
|
||||
},
|
||||
"created_at": {
|
||||
"type": "string"
|
||||
},
|
||||
"id": {
|
||||
"type": "integer"
|
||||
},
|
||||
"title": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"securityDefinitions": {
|
||||
"Bearer": {
|
||||
"description": "Type \"Bearer\" followed by a space and the JWT token.",
|
||||
"type": "apiKey",
|
||||
"name": "Authorization",
|
||||
"in": "header"
|
||||
}
|
||||
}
|
||||
}
|
||||
394
backend/docs/swagger.yaml
Normal file
394
backend/docs/swagger.yaml
Normal file
@@ -0,0 +1,394 @@
|
||||
definitions:
|
||||
gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_models.ErrorDetail:
|
||||
properties:
|
||||
code:
|
||||
type: integer
|
||||
detail:
|
||||
type: string
|
||||
message:
|
||||
type: string
|
||||
type: object
|
||||
gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_models.ErrorResponse:
|
||||
properties:
|
||||
error:
|
||||
$ref: '#/definitions/gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_models.ErrorDetail'
|
||||
type: object
|
||||
gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_models.SuccessResponse:
|
||||
properties:
|
||||
data: {}
|
||||
type: object
|
||||
gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_storage.Post:
|
||||
properties:
|
||||
content:
|
||||
type: string
|
||||
created_at:
|
||||
type: string
|
||||
id:
|
||||
type: integer
|
||||
published:
|
||||
type: boolean
|
||||
title:
|
||||
type: string
|
||||
type: object
|
||||
gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_storage.PostCreate:
|
||||
properties:
|
||||
content:
|
||||
type: string
|
||||
published:
|
||||
type: boolean
|
||||
title:
|
||||
type: string
|
||||
type: object
|
||||
gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_storage.PostReq:
|
||||
properties:
|
||||
content:
|
||||
type: string
|
||||
created_at:
|
||||
type: string
|
||||
id:
|
||||
type: integer
|
||||
title:
|
||||
type: string
|
||||
type: object
|
||||
info:
|
||||
contact: {}
|
||||
paths:
|
||||
/admin/posts:
|
||||
get:
|
||||
consumes:
|
||||
- application/json
|
||||
description: Get all posts
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
schema:
|
||||
allOf:
|
||||
- $ref: '#/definitions/gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_models.SuccessResponse'
|
||||
- properties:
|
||||
data:
|
||||
items:
|
||||
$ref: '#/definitions/gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_storage.PostReq'
|
||||
type: array
|
||||
type: object
|
||||
"400":
|
||||
description: Invalid ID format
|
||||
schema:
|
||||
$ref: '#/definitions/gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_models.ErrorResponse'
|
||||
"404":
|
||||
description: No Post found
|
||||
schema:
|
||||
$ref: '#/definitions/gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_models.ErrorResponse'
|
||||
"500":
|
||||
description: Internal server error
|
||||
schema:
|
||||
$ref: '#/definitions/gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_models.ErrorResponse'
|
||||
security:
|
||||
- Bearer: []
|
||||
summary: Get all posts
|
||||
tags:
|
||||
- admin
|
||||
/auth/github:
|
||||
get:
|
||||
description: Redirects to GitHub authorization
|
||||
responses:
|
||||
"302":
|
||||
description: Found
|
||||
summary: Start GitHub OAuth login
|
||||
tags:
|
||||
- auth
|
||||
/callback/github:
|
||||
get:
|
||||
description: Exchanges authorization code for access token
|
||||
parameters:
|
||||
- description: Authorization code
|
||||
in: query
|
||||
name: code
|
||||
required: true
|
||||
type: string
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: Access token
|
||||
schema:
|
||||
additionalProperties: true
|
||||
type: object
|
||||
"400":
|
||||
description: Missing code
|
||||
schema:
|
||||
additionalProperties:
|
||||
type: string
|
||||
type: object
|
||||
"500":
|
||||
description: Exchange failed
|
||||
schema:
|
||||
additionalProperties:
|
||||
type: string
|
||||
type: object
|
||||
summary: GitHub OAuth callback
|
||||
tags:
|
||||
- auth
|
||||
/posts:
|
||||
get:
|
||||
consumes:
|
||||
- application/json
|
||||
description: Get all posts
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
schema:
|
||||
allOf:
|
||||
- $ref: '#/definitions/gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_models.SuccessResponse'
|
||||
- properties:
|
||||
data:
|
||||
items:
|
||||
$ref: '#/definitions/gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_storage.PostReq'
|
||||
type: array
|
||||
type: object
|
||||
"400":
|
||||
description: Invalid ID format
|
||||
schema:
|
||||
$ref: '#/definitions/gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_models.ErrorResponse'
|
||||
"404":
|
||||
description: No Post found
|
||||
schema:
|
||||
$ref: '#/definitions/gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_models.ErrorResponse'
|
||||
"500":
|
||||
description: Internal server error
|
||||
schema:
|
||||
$ref: '#/definitions/gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_models.ErrorResponse'
|
||||
summary: Get all published posts
|
||||
tags:
|
||||
- posts
|
||||
post:
|
||||
consumes:
|
||||
- application/json
|
||||
description: Create new post
|
||||
parameters:
|
||||
- description: Post data
|
||||
in: body
|
||||
name: post
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/definitions/gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_storage.PostCreate'
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
schema:
|
||||
allOf:
|
||||
- $ref: '#/definitions/gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_models.SuccessResponse'
|
||||
- properties:
|
||||
data:
|
||||
$ref: '#/definitions/gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_storage.Post'
|
||||
type: object
|
||||
"400":
|
||||
description: Invalid request
|
||||
schema:
|
||||
$ref: '#/definitions/gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_models.ErrorResponse'
|
||||
security:
|
||||
- Bearer: []
|
||||
summary: Create post
|
||||
tags:
|
||||
- posts
|
||||
/posts/{id}:
|
||||
delete:
|
||||
consumes:
|
||||
- application/json
|
||||
description: Delete post
|
||||
parameters:
|
||||
- description: Post ID
|
||||
in: path
|
||||
name: id
|
||||
required: true
|
||||
type: integer
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
schema:
|
||||
allOf:
|
||||
- $ref: '#/definitions/gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_models.SuccessResponse'
|
||||
- properties:
|
||||
data:
|
||||
$ref: '#/definitions/gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_storage.Post'
|
||||
type: object
|
||||
"400":
|
||||
description: Invalid ID format
|
||||
schema:
|
||||
$ref: '#/definitions/gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_models.ErrorResponse'
|
||||
"404":
|
||||
description: Post not found
|
||||
schema:
|
||||
$ref: '#/definitions/gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_models.ErrorResponse'
|
||||
"500":
|
||||
description: Internal server error
|
||||
schema:
|
||||
$ref: '#/definitions/gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_models.ErrorResponse'
|
||||
security:
|
||||
- Bearer: []
|
||||
summary: Delete post
|
||||
tags:
|
||||
- posts
|
||||
get:
|
||||
consumes:
|
||||
- application/json
|
||||
description: Get post by id
|
||||
parameters:
|
||||
- description: Post ID
|
||||
in: path
|
||||
name: id
|
||||
required: true
|
||||
type: integer
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
schema:
|
||||
allOf:
|
||||
- $ref: '#/definitions/gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_models.SuccessResponse'
|
||||
- properties:
|
||||
data:
|
||||
$ref: '#/definitions/gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_storage.PostReq'
|
||||
type: object
|
||||
"400":
|
||||
description: Invalid ID format
|
||||
schema:
|
||||
$ref: '#/definitions/gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_models.ErrorResponse'
|
||||
"404":
|
||||
description: Post not found
|
||||
schema:
|
||||
$ref: '#/definitions/gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_models.ErrorResponse'
|
||||
"500":
|
||||
description: Internal server error
|
||||
schema:
|
||||
$ref: '#/definitions/gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_models.ErrorResponse'
|
||||
summary: Get post by id
|
||||
tags:
|
||||
- posts
|
||||
put:
|
||||
consumes:
|
||||
- application/json
|
||||
description: Update post
|
||||
parameters:
|
||||
- description: Post ID
|
||||
in: path
|
||||
name: id
|
||||
required: true
|
||||
type: integer
|
||||
- description: Post data
|
||||
in: body
|
||||
name: post
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/definitions/gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_storage.PostCreate'
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
schema:
|
||||
allOf:
|
||||
- $ref: '#/definitions/gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_models.SuccessResponse'
|
||||
- properties:
|
||||
data:
|
||||
$ref: '#/definitions/gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_storage.PostCreate'
|
||||
type: object
|
||||
"400":
|
||||
description: Invalid ID format
|
||||
schema:
|
||||
$ref: '#/definitions/gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_models.ErrorResponse'
|
||||
"500":
|
||||
description: Internal server error
|
||||
schema:
|
||||
$ref: '#/definitions/gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_models.ErrorResponse'
|
||||
security:
|
||||
- Bearer: []
|
||||
summary: Update post
|
||||
tags:
|
||||
- posts
|
||||
/session:
|
||||
get:
|
||||
description: Returns user session data
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: Session data
|
||||
schema:
|
||||
additionalProperties: true
|
||||
type: object
|
||||
"401":
|
||||
description: Unauthorized
|
||||
schema:
|
||||
additionalProperties:
|
||||
type: string
|
||||
type: object
|
||||
summary: Get user session
|
||||
tags:
|
||||
- auth
|
||||
/upload:
|
||||
post:
|
||||
description: Upload static content to the server
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
schema:
|
||||
$ref: '#/definitions/gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_models.SuccessResponse'
|
||||
"500":
|
||||
description: Internal server error
|
||||
schema:
|
||||
$ref: '#/definitions/gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_models.ErrorResponse'
|
||||
summary: Upload static content
|
||||
tags:
|
||||
- static
|
||||
/upload/{file}:
|
||||
get:
|
||||
consumes:
|
||||
- application/json
|
||||
description: Get static content
|
||||
parameters:
|
||||
- description: File name
|
||||
in: path
|
||||
name: file
|
||||
required: true
|
||||
type: string
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: Static content
|
||||
schema:
|
||||
allOf:
|
||||
- $ref: '#/definitions/gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_models.SuccessResponse'
|
||||
- properties:
|
||||
data:
|
||||
type: string
|
||||
type: object
|
||||
"404":
|
||||
description: File not found
|
||||
schema:
|
||||
$ref: '#/definitions/gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_models.ErrorResponse'
|
||||
"500":
|
||||
description: Internal server error
|
||||
schema:
|
||||
$ref: '#/definitions/gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_models.ErrorResponse'
|
||||
summary: Get static content
|
||||
tags:
|
||||
- static
|
||||
securityDefinitions:
|
||||
Bearer:
|
||||
description: Type "Bearer" followed by a space and the JWT token.
|
||||
in: header
|
||||
name: Authorization
|
||||
type: apiKey
|
||||
swagger: "2.0"
|
||||
70
backend/go.mod
Normal file
70
backend/go.mod
Normal file
@@ -0,0 +1,70 @@
|
||||
module gitea.d3m0k1d.ru/d3m0k1d/d3m0k1d.ru/backend
|
||||
|
||||
go 1.25.6
|
||||
|
||||
require (
|
||||
github.com/gin-gonic/gin v1.11.0
|
||||
github.com/golang-jwt/jwt/v5 v5.3.1
|
||||
github.com/swaggo/files v1.0.1
|
||||
github.com/swaggo/gin-swagger v1.6.1
|
||||
github.com/swaggo/swag v1.16.6
|
||||
golang.org/x/oauth2 v0.35.0
|
||||
gopkg.in/natefinch/lumberjack.v2 v2.2.1
|
||||
modernc.org/sqlite v1.44.3
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/KyleBanks/depth v1.2.1 // indirect
|
||||
github.com/bytedance/gopkg v0.1.3 // indirect
|
||||
github.com/bytedance/sonic v1.15.0 // indirect
|
||||
github.com/bytedance/sonic/loader v0.5.0 // indirect
|
||||
github.com/cloudwego/base64x v0.1.6 // indirect
|
||||
github.com/dustin/go-humanize v1.0.1 // indirect
|
||||
github.com/gabriel-vasile/mimetype v1.4.13 // indirect
|
||||
github.com/gin-contrib/sse v1.1.0 // indirect
|
||||
github.com/go-openapi/jsonpointer v0.22.4 // indirect
|
||||
github.com/go-openapi/jsonreference v0.21.4 // indirect
|
||||
github.com/go-openapi/spec v0.22.3 // indirect
|
||||
github.com/go-openapi/swag/conv v0.25.4 // indirect
|
||||
github.com/go-openapi/swag/jsonname v0.25.4 // indirect
|
||||
github.com/go-openapi/swag/jsonutils v0.25.4 // indirect
|
||||
github.com/go-openapi/swag/loading v0.25.4 // indirect
|
||||
github.com/go-openapi/swag/stringutils v0.25.4 // indirect
|
||||
github.com/go-openapi/swag/typeutils v0.25.4 // indirect
|
||||
github.com/go-openapi/swag/yamlutils v0.25.4 // indirect
|
||||
github.com/go-playground/locales v0.14.1 // indirect
|
||||
github.com/go-playground/universal-translator v0.18.1 // indirect
|
||||
github.com/go-playground/validator/v10 v10.30.1 // indirect
|
||||
github.com/goccy/go-json v0.10.5 // indirect
|
||||
github.com/goccy/go-yaml v1.19.2 // indirect
|
||||
github.com/google/uuid v1.6.0 // indirect
|
||||
github.com/json-iterator/go v1.1.12 // indirect
|
||||
github.com/klauspost/cpuid/v2 v2.3.0 // indirect
|
||||
github.com/kr/text v0.2.0 // indirect
|
||||
github.com/leodido/go-urn v1.4.0 // indirect
|
||||
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
||||
github.com/modern-go/reflect2 v1.0.2 // indirect
|
||||
github.com/ncruces/go-strftime v1.0.0 // indirect
|
||||
github.com/pelletier/go-toml/v2 v2.2.4 // indirect
|
||||
github.com/quic-go/qpack v0.6.0 // indirect
|
||||
github.com/quic-go/quic-go v0.59.0 // indirect
|
||||
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
|
||||
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
|
||||
github.com/ugorji/go/codec v1.3.1 // indirect
|
||||
go.uber.org/mock v0.6.0 // indirect
|
||||
go.yaml.in/yaml/v3 v3.0.4 // indirect
|
||||
golang.org/x/arch v0.23.0 // indirect
|
||||
golang.org/x/crypto v0.47.0 // indirect
|
||||
golang.org/x/exp v0.0.0-20251023183803-a4bb9ffd2546 // indirect
|
||||
golang.org/x/mod v0.32.0 // indirect
|
||||
golang.org/x/net v0.49.0 // indirect
|
||||
golang.org/x/sync v0.19.0 // indirect
|
||||
golang.org/x/sys v0.40.0 // indirect
|
||||
golang.org/x/text v0.33.0 // indirect
|
||||
golang.org/x/tools v0.41.0 // indirect
|
||||
google.golang.org/protobuf v1.36.11 // indirect
|
||||
modernc.org/libc v1.67.6 // indirect
|
||||
modernc.org/mathutil v1.7.1 // indirect
|
||||
modernc.org/memory v1.11.0 // indirect
|
||||
)
|
||||
216
backend/go.sum
Normal file
216
backend/go.sum
Normal file
@@ -0,0 +1,216 @@
|
||||
github.com/KyleBanks/depth v1.2.1 h1:5h8fQADFrWtarTdtDudMmGsC7GPbOAu6RVB3ffsVFHc=
|
||||
github.com/KyleBanks/depth v1.2.1/go.mod h1:jzSb9d0L43HxTQfT+oSA1EEp2q+ne2uh6XgeJcm8brE=
|
||||
github.com/bytedance/gopkg v0.1.3 h1:TPBSwH8RsouGCBcMBktLt1AymVo2TVsBVCY4b6TnZ/M=
|
||||
github.com/bytedance/gopkg v0.1.3/go.mod h1:576VvJ+eJgyCzdjS+c4+77QF3p7ubbtiKARP3TxducM=
|
||||
github.com/bytedance/sonic v1.15.0 h1:/PXeWFaR5ElNcVE84U0dOHjiMHQOwNIx3K4ymzh/uSE=
|
||||
github.com/bytedance/sonic v1.15.0/go.mod h1:tFkWrPz0/CUCLEF4ri4UkHekCIcdnkqXw9VduqpJh0k=
|
||||
github.com/bytedance/sonic/loader v0.5.0 h1:gXH3KVnatgY7loH5/TkeVyXPfESoqSBSBEiDd5VjlgE=
|
||||
github.com/bytedance/sonic/loader v0.5.0/go.mod h1:AR4NYCk5DdzZizZ5djGqQ92eEhCCcdf5x77udYiSJRo=
|
||||
github.com/cloudwego/base64x v0.1.6 h1:t11wG9AECkCDk5fMSoxmufanudBtJ+/HemLstXDLI2M=
|
||||
github.com/cloudwego/base64x v0.1.6/go.mod h1:OFcloc187FXDaYHvrNIjxSe8ncn0OOM8gEHfghB2IPU=
|
||||
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
|
||||
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
|
||||
github.com/gabriel-vasile/mimetype v1.4.13 h1:46nXokslUBsAJE/wMsp5gtO500a4F3Nkz9Ufpk2AcUM=
|
||||
github.com/gabriel-vasile/mimetype v1.4.13/go.mod h1:d+9Oxyo1wTzWdyVUPMmXFvp4F9tea18J8ufA774AB3s=
|
||||
github.com/gin-contrib/gzip v0.0.6 h1:NjcunTcGAj5CO1gn4N8jHOSIeRFHIbn51z6K+xaN4d4=
|
||||
github.com/gin-contrib/gzip v0.0.6/go.mod h1:QOJlmV2xmayAjkNS2Y8NQsMneuRShOU/kjovCXNuzzk=
|
||||
github.com/gin-contrib/sse v1.1.0 h1:n0w2GMuUpWDVp7qSpvze6fAu9iRxJY4Hmj6AmBOU05w=
|
||||
github.com/gin-contrib/sse v1.1.0/go.mod h1:hxRZ5gVpWMT7Z0B0gSNYqqsSCNIJMjzvm6fqCz9vjwM=
|
||||
github.com/gin-gonic/gin v1.11.0 h1:OW/6PLjyusp2PPXtyxKHU0RbX6I/l28FTdDlae5ueWk=
|
||||
github.com/gin-gonic/gin v1.11.0/go.mod h1:+iq/FyxlGzII0KHiBGjuNn4UNENUlKbGlNmc+W50Dls=
|
||||
github.com/go-openapi/jsonpointer v0.22.4 h1:dZtK82WlNpVLDW2jlA1YCiVJFVqkED1MegOUy9kR5T4=
|
||||
github.com/go-openapi/jsonpointer v0.22.4/go.mod h1:elX9+UgznpFhgBuaMQ7iu4lvvX1nvNsesQ3oxmYTw80=
|
||||
github.com/go-openapi/jsonreference v0.21.4 h1:24qaE2y9bx/q3uRK/qN+TDwbok1NhbSmGjjySRCHtC8=
|
||||
github.com/go-openapi/jsonreference v0.21.4/go.mod h1:rIENPTjDbLpzQmQWCj5kKj3ZlmEh+EFVbz3RTUh30/4=
|
||||
github.com/go-openapi/spec v0.22.3 h1:qRSmj6Smz2rEBxMnLRBMeBWxbbOvuOoElvSvObIgwQc=
|
||||
github.com/go-openapi/spec v0.22.3/go.mod h1:iIImLODL2loCh3Vnox8TY2YWYJZjMAKYyLH2Mu8lOZs=
|
||||
github.com/go-openapi/swag v0.19.15 h1:D2NRCBzS9/pEY3gP9Nl8aDqGUcPFrwG2p+CNFrLyrCM=
|
||||
github.com/go-openapi/swag/conv v0.25.4 h1:/Dd7p0LZXczgUcC/Ikm1+YqVzkEeCc9LnOWjfkpkfe4=
|
||||
github.com/go-openapi/swag/conv v0.25.4/go.mod h1:3LXfie/lwoAv0NHoEuY1hjoFAYkvlqI/Bn5EQDD3PPU=
|
||||
github.com/go-openapi/swag/jsonname v0.25.4 h1:bZH0+MsS03MbnwBXYhuTttMOqk+5KcQ9869Vye1bNHI=
|
||||
github.com/go-openapi/swag/jsonname v0.25.4/go.mod h1:GPVEk9CWVhNvWhZgrnvRA6utbAltopbKwDu8mXNUMag=
|
||||
github.com/go-openapi/swag/jsonutils v0.25.4 h1:VSchfbGhD4UTf4vCdR2F4TLBdLwHyUDTd1/q4i+jGZA=
|
||||
github.com/go-openapi/swag/jsonutils v0.25.4/go.mod h1:7OYGXpvVFPn4PpaSdPHJBtF0iGnbEaTk8AvBkoWnaAY=
|
||||
github.com/go-openapi/swag/jsonutils/fixtures_test v0.25.4 h1:IACsSvBhiNJwlDix7wq39SS2Fh7lUOCJRmx/4SN4sVo=
|
||||
github.com/go-openapi/swag/jsonutils/fixtures_test v0.25.4/go.mod h1:Mt0Ost9l3cUzVv4OEZG+WSeoHwjWLnarzMePNDAOBiM=
|
||||
github.com/go-openapi/swag/loading v0.25.4 h1:jN4MvLj0X6yhCDduRsxDDw1aHe+ZWoLjW+9ZQWIKn2s=
|
||||
github.com/go-openapi/swag/loading v0.25.4/go.mod h1:rpUM1ZiyEP9+mNLIQUdMiD7dCETXvkkC30z53i+ftTE=
|
||||
github.com/go-openapi/swag/stringutils v0.25.4 h1:O6dU1Rd8bej4HPA3/CLPciNBBDwZj9HiEpdVsb8B5A8=
|
||||
github.com/go-openapi/swag/stringutils v0.25.4/go.mod h1:GTsRvhJW5xM5gkgiFe0fV3PUlFm0dr8vki6/VSRaZK0=
|
||||
github.com/go-openapi/swag/typeutils v0.25.4 h1:1/fbZOUN472NTc39zpa+YGHn3jzHWhv42wAJSN91wRw=
|
||||
github.com/go-openapi/swag/typeutils v0.25.4/go.mod h1:Ou7g//Wx8tTLS9vG0UmzfCsjZjKhpjxayRKTHXf2pTE=
|
||||
github.com/go-openapi/swag/yamlutils v0.25.4 h1:6jdaeSItEUb7ioS9lFoCZ65Cne1/RZtPBZ9A56h92Sw=
|
||||
github.com/go-openapi/swag/yamlutils v0.25.4/go.mod h1:MNzq1ulQu+yd8Kl7wPOut/YHAAU/H6hL91fF+E2RFwc=
|
||||
github.com/go-openapi/testify/enable/yaml/v2 v2.0.2 h1:0+Y41Pz1NkbTHz8NngxTuAXxEodtNSI1WG1c/m5Akw4=
|
||||
github.com/go-openapi/testify/enable/yaml/v2 v2.0.2/go.mod h1:kme83333GCtJQHXQ8UKX3IBZu6z8T5Dvy5+CW3NLUUg=
|
||||
github.com/go-openapi/testify/v2 v2.0.2 h1:X999g3jeLcoY8qctY/c/Z8iBHTbwLz7R2WXd6Ub6wls=
|
||||
github.com/go-openapi/testify/v2 v2.0.2/go.mod h1:HCPmvFFnheKK2BuwSA0TbbdxJ3I16pjwMkYkP4Ywn54=
|
||||
github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s=
|
||||
github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
|
||||
github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA=
|
||||
github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
|
||||
github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY=
|
||||
github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
|
||||
github.com/go-playground/validator/v10 v10.30.1 h1:f3zDSN/zOma+w6+1Wswgd9fLkdwy06ntQJp0BBvFG0w=
|
||||
github.com/go-playground/validator/v10 v10.30.1/go.mod h1:oSuBIQzuJxL//3MelwSLD5hc2Tu889bF0Idm9Dg26cM=
|
||||
github.com/goccy/go-json v0.10.5 h1:Fq85nIqj+gXn/S5ahsiTlK3TmC85qgirsdTP/+DeaC4=
|
||||
github.com/goccy/go-json v0.10.5/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M=
|
||||
github.com/goccy/go-yaml v1.19.2 h1:PmFC1S6h8ljIz6gMRBopkjP1TVT7xuwrButHID66PoM=
|
||||
github.com/goccy/go-yaml v1.19.2/go.mod h1:XBurs7gK8ATbW4ZPGKgcbrY1Br56PdM69F7LkFRi1kA=
|
||||
github.com/golang-jwt/jwt/v5 v5.3.1 h1:kYf81DTWFe7t+1VvL7eS+jKFVWaUnK9cB1qbwn63YCY=
|
||||
github.com/golang-jwt/jwt/v5 v5.3.1/go.mod h1:fxCRLWMO43lRc8nhHWY6LGqRcf+1gQWArsqaEUEa5bE=
|
||||
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
|
||||
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
|
||||
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||
github.com/google/pprof v0.0.0-20250317173921-a4b03ec1a45e h1:ijClszYn+mADRFY17kjQEVQ1XRhq2/JR1M3sGqeJoxs=
|
||||
github.com/google/pprof v0.0.0-20250317173921-a4b03ec1a45e/go.mod h1:boTsfXsheKC2y+lKOCMpSfarhxDeIzfZG1jqGcPl3cA=
|
||||
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
||||
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/hashicorp/golang-lru/v2 v2.0.7 h1:a+bsQ5rvGLjzHuww6tVxozPZFVghXaHOwFs4luLUK2k=
|
||||
github.com/hashicorp/golang-lru/v2 v2.0.7/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM=
|
||||
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
|
||||
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
|
||||
github.com/klauspost/cpuid/v2 v2.3.0 h1:S4CRMLnYUhGeDFDqkGriYKdfoFlDnMtqTiI/sFzhA9Y=
|
||||
github.com/klauspost/cpuid/v2 v2.3.0/go.mod h1:hqwkgyIinND0mEev00jJYCxPNVRVXFQeu1XKlok6oO0=
|
||||
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
|
||||
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
|
||||
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
||||
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
||||
github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ=
|
||||
github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI=
|
||||
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
|
||||
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
||||
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
|
||||
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
|
||||
github.com/ncruces/go-strftime v1.0.0 h1:HMFp8mLCTPp341M/ZnA4qaf7ZlsbTc+miZjCLOFAw7w=
|
||||
github.com/ncruces/go-strftime v1.0.0/go.mod h1:Fwc5htZGVVkseilnfgOVb9mKy6w1naJmn9CehxcKcls=
|
||||
github.com/pelletier/go-toml/v2 v2.2.4 h1:mye9XuhQ6gvn5h28+VilKrrPoQVanw5PMw/TB0t5Ec4=
|
||||
github.com/pelletier/go-toml/v2 v2.2.4/go.mod h1:2gIqNv+qfxSVS7cM2xJQKtLSTLUE9V8t9Stt+h56mCY=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/quic-go/qpack v0.6.0 h1:g7W+BMYynC1LbYLSqRt8PBg5Tgwxn214ZZR34VIOjz8=
|
||||
github.com/quic-go/qpack v0.6.0/go.mod h1:lUpLKChi8njB4ty2bFLX2x4gzDqXwUpaO1DP9qMDZII=
|
||||
github.com/quic-go/quic-go v0.59.0 h1:OLJkp1Mlm/aS7dpKgTc6cnpynnD2Xg7C1pwL6vy/SAw=
|
||||
github.com/quic-go/quic-go v0.59.0/go.mod h1:upnsH4Ju1YkqpLXC305eW3yDZ4NfnNbmQRCMWS58IKU=
|
||||
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE=
|
||||
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
|
||||
github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ=
|
||||
github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
||||
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
|
||||
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
|
||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
||||
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
|
||||
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
|
||||
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
|
||||
github.com/swaggo/files v1.0.1 h1:J1bVJ4XHZNq0I46UU90611i9/YzdrF7x92oX1ig5IdE=
|
||||
github.com/swaggo/files v1.0.1/go.mod h1:0qXmMNH6sXNf+73t65aKeB+ApmgxdnkQzVTAj2uaMUg=
|
||||
github.com/swaggo/gin-swagger v1.6.1 h1:Ri06G4gc9N4t4k8hekMigJ9zKTFSlqj/9paAQCQs7cY=
|
||||
github.com/swaggo/gin-swagger v1.6.1/go.mod h1:LQ+hJStHakCWRiK/YNYtJOu4mR2FP+pxLnILT/qNiTw=
|
||||
github.com/swaggo/swag v1.16.6 h1:qBNcx53ZaX+M5dxVyTrgQ0PJ/ACK+NzhwcbieTt+9yI=
|
||||
github.com/swaggo/swag v1.16.6/go.mod h1:ngP2etMK5a0P3QBizic5MEwpRmluJZPHjXcMoj4Xesg=
|
||||
github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI=
|
||||
github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=
|
||||
github.com/ugorji/go/codec v1.3.1 h1:waO7eEiFDwidsBN6agj1vJQ4AG7lh2yqXyOXqhgQuyY=
|
||||
github.com/ugorji/go/codec v1.3.1/go.mod h1:pRBVtBSKl77K30Bv8R2P+cLSGaTtex6fsA2Wjqmfxj4=
|
||||
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
|
||||
go.uber.org/mock v0.6.0 h1:hyF9dfmbgIX5EfOdasqLsWD6xqpNZlXblLB/Dbnwv3Y=
|
||||
go.uber.org/mock v0.6.0/go.mod h1:KiVJ4BqZJaMj4svdfmHM0AUx4NJYO8ZNpPnZn1Z+BBU=
|
||||
go.yaml.in/yaml/v3 v3.0.4 h1:tfq32ie2Jv2UxXFdLJdh3jXuOzWiL1fo0bu/FbuKpbc=
|
||||
go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg=
|
||||
golang.org/x/arch v0.23.0 h1:lKF64A2jF6Zd8L0knGltUnegD62JMFBiCPBmQpToHhg=
|
||||
golang.org/x/arch v0.23.0/go.mod h1:dNHoOeKiyja7GTvF9NJS1l3Z2yntpQNzgrjh1cU103A=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||
golang.org/x/crypto v0.47.0 h1:V6e3FRj+n4dbpw86FJ8Fv7XVOql7TEwpHapKoMJ/GO8=
|
||||
golang.org/x/crypto v0.47.0/go.mod h1:ff3Y9VzzKbwSSEzWqJsJVBnWmRwRSHt/6Op5n9bQc4A=
|
||||
golang.org/x/exp v0.0.0-20251023183803-a4bb9ffd2546 h1:mgKeJMpvi0yx/sU5GsxQ7p6s2wtOnGAHZWCHUM4KGzY=
|
||||
golang.org/x/exp v0.0.0-20251023183803-a4bb9ffd2546/go.mod h1:j/pmGrbnkbPtQfxEe5D0VQhZC6qKbfKifgD0oM7sR70=
|
||||
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
|
||||
golang.org/x/mod v0.32.0 h1:9F4d3PHLljb6x//jOyokMv3eX+YDeepZSEo3mFJy93c=
|
||||
golang.org/x/mod v0.32.0/go.mod h1:SgipZ/3h2Ci89DlEtEXWUk/HteuRin+HHhN+WbNhguU=
|
||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
|
||||
golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
|
||||
golang.org/x/net v0.49.0 h1:eeHFmOGUTtaaPSGNmjBKpbng9MulQsJURQUAfUwY++o=
|
||||
golang.org/x/net v0.49.0/go.mod h1:/ysNB2EvaqvesRkuLAyjI1ycPZlQHM3q01F02UY/MV8=
|
||||
golang.org/x/oauth2 v0.35.0 h1:Mv2mzuHuZuY2+bkyWXIHMfhNdJAdwW3FuWeCPYN5GVQ=
|
||||
golang.org/x/oauth2 v0.35.0/go.mod h1:lzm5WQJQwKZ3nwavOZ3IS5Aulzxi68dUSgRHujetwEA=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.19.0 h1:vV+1eWNmZ5geRlYjzm2adRgW2/mcpevXNg50YZtPCE4=
|
||||
golang.org/x/sync v0.19.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.40.0 h1:DBZZqJ2Rkml6QMQsZywtnjnnGvHza6BTfYFWY9kjEWQ=
|
||||
golang.org/x/sys v0.40.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
||||
golang.org/x/text v0.33.0 h1:B3njUFyqtHDUI5jMn1YIr5B0IE2U0qck04r6d4KPAxE=
|
||||
golang.org/x/text v0.33.0/go.mod h1:LuMebE6+rBincTi9+xWTY8TztLzKHc/9C1uBCG27+q8=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
|
||||
golang.org/x/tools v0.41.0 h1:a9b8iMweWG+S0OBnlU36rzLp20z1Rp10w+IY2czHTQc=
|
||||
golang.org/x/tools v0.41.0/go.mod h1:XSY6eDqxVNiYgezAVqqCeihT4j1U2CCsqvH3WhQpnlg=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
google.golang.org/protobuf v1.36.11 h1:fV6ZwhNocDyBLK0dj+fg8ektcVegBBuEolpbTQyBNVE=
|
||||
google.golang.org/protobuf v1.36.11/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
|
||||
gopkg.in/natefinch/lumberjack.v2 v2.2.1 h1:bBRl1b0OH9s/DuPhuXpNl+VtCaJXFZ5/uEFST95x9zc=
|
||||
gopkg.in/natefinch/lumberjack.v2 v2.2.1/go.mod h1:YD8tP3GAjkrDg1eZH7EGmyESg/lsYskCTPBJVb9jqSc=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
modernc.org/cc/v4 v4.27.1 h1:9W30zRlYrefrDV2JE2O8VDtJ1yPGownxciz5rrbQZis=
|
||||
modernc.org/cc/v4 v4.27.1/go.mod h1:uVtb5OGqUKpoLWhqwNQo/8LwvoiEBLvZXIQ/SmO6mL0=
|
||||
modernc.org/ccgo/v4 v4.30.1 h1:4r4U1J6Fhj98NKfSjnPUN7Ze2c6MnAdL0hWw6+LrJpc=
|
||||
modernc.org/ccgo/v4 v4.30.1/go.mod h1:bIOeI1JL54Utlxn+LwrFyjCx2n2RDiYEaJVSrgdrRfM=
|
||||
modernc.org/fileutil v1.3.40 h1:ZGMswMNc9JOCrcrakF1HrvmergNLAmxOPjizirpfqBA=
|
||||
modernc.org/fileutil v1.3.40/go.mod h1:HxmghZSZVAz/LXcMNwZPA/DRrQZEVP9VX0V4LQGQFOc=
|
||||
modernc.org/gc/v2 v2.6.5 h1:nyqdV8q46KvTpZlsw66kWqwXRHdjIlJOhG6kxiV/9xI=
|
||||
modernc.org/gc/v2 v2.6.5/go.mod h1:YgIahr1ypgfe7chRuJi2gD7DBQiKSLMPgBQe9oIiito=
|
||||
modernc.org/gc/v3 v3.1.1 h1:k8T3gkXWY9sEiytKhcgyiZ2L0DTyCQ/nvX+LoCljoRE=
|
||||
modernc.org/gc/v3 v3.1.1/go.mod h1:HFK/6AGESC7Ex+EZJhJ2Gni6cTaYpSMmU/cT9RmlfYY=
|
||||
modernc.org/goabi0 v0.2.0 h1:HvEowk7LxcPd0eq6mVOAEMai46V+i7Jrj13t4AzuNks=
|
||||
modernc.org/goabi0 v0.2.0/go.mod h1:CEFRnnJhKvWT1c1JTI3Avm+tgOWbkOu5oPA8eH8LnMI=
|
||||
modernc.org/libc v1.67.6 h1:eVOQvpModVLKOdT+LvBPjdQqfrZq+pC39BygcT+E7OI=
|
||||
modernc.org/libc v1.67.6/go.mod h1:JAhxUVlolfYDErnwiqaLvUqc8nfb2r6S6slAgZOnaiE=
|
||||
modernc.org/mathutil v1.7.1 h1:GCZVGXdaN8gTqB1Mf/usp1Y/hSqgI2vAGGP4jZMCxOU=
|
||||
modernc.org/mathutil v1.7.1/go.mod h1:4p5IwJITfppl0G4sUEDtCr4DthTaT47/N3aT6MhfgJg=
|
||||
modernc.org/memory v1.11.0 h1:o4QC8aMQzmcwCK3t3Ux/ZHmwFPzE6hf2Y5LbkRs+hbI=
|
||||
modernc.org/memory v1.11.0/go.mod h1:/JP4VbVC+K5sU2wZi9bHoq2MAkCnrt2r98UGeSK7Mjw=
|
||||
modernc.org/opt v0.1.4 h1:2kNGMRiUjrp4LcaPuLY2PzUfqM/w9N23quVwhKt5Qm8=
|
||||
modernc.org/opt v0.1.4/go.mod h1:03fq9lsNfvkYSfxrfUhZCWPk1lm4cq4N+Bh//bEtgns=
|
||||
modernc.org/sortutil v1.2.1 h1:+xyoGf15mM3NMlPDnFqrteY07klSFxLElE2PVuWIJ7w=
|
||||
modernc.org/sortutil v1.2.1/go.mod h1:7ZI3a3REbai7gzCLcotuw9AC4VZVpYMjDzETGsSMqJE=
|
||||
modernc.org/sqlite v1.44.3 h1:+39JvV/HWMcYslAwRxHb8067w+2zowvFOUrOWIy9PjY=
|
||||
modernc.org/sqlite v1.44.3/go.mod h1:CzbrU2lSB1DKUusvwGz7rqEKIq+NUd8GWuBBZDs9/nA=
|
||||
modernc.org/strutil v1.2.1 h1:UneZBkQA+DX2Rp35KcM69cSsNES9ly8mQWD71HKlOA0=
|
||||
modernc.org/strutil v1.2.1/go.mod h1:EHkiggD70koQxjVdSBM3JKM7k6L0FbGE5eymy9i3B9A=
|
||||
modernc.org/token v1.1.0 h1:Xl7Ap9dKaEs5kLoOQeQmPWevfnk/DM5qcLcYlA8ys6Y=
|
||||
modernc.org/token v1.1.0/go.mod h1:UGzOrNV1mAFSEB63lOFHIpNRUVMvYTc6yu1SMY/XTDM=
|
||||
174
backend/internal/auth/jwt.go
Normal file
174
backend/internal/auth/jwt.go
Normal file
@@ -0,0 +1,174 @@
|
||||
package auth
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"gitea.d3m0k1d.ru/d3m0k1d/d3m0k1d.ru/backend/internal/storage"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/golang-jwt/jwt/v5"
|
||||
)
|
||||
|
||||
var jwtSecret = []byte(os.Getenv("JWT_SECRET"))
|
||||
|
||||
func GenerateJWT(user storage.User) (string, error) {
|
||||
token := jwt.NewWithClaims(jwt.SigningMethodHS512, jwt.MapClaims{
|
||||
"id": user.ID,
|
||||
"email": user.Email,
|
||||
"login": user.GithubLogin,
|
||||
"github_id": user.GithubID,
|
||||
"avatar_url": user.AvatarURL,
|
||||
"exp": time.Now().Add(30 * 24 * time.Hour).Unix(), // 30 дней
|
||||
"iat": time.Now().Unix(),
|
||||
})
|
||||
tokenString, err := token.SignedString(jwtSecret)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return tokenString, nil
|
||||
}
|
||||
|
||||
func JWTMiddleware() gin.HandlerFunc {
|
||||
return func(c *gin.Context) {
|
||||
auth := c.GetHeader("Authorization")
|
||||
if !strings.HasPrefix(auth, "Bearer ") {
|
||||
c.AbortWithStatusJSON(401, gin.H{"error": "Bearer required"})
|
||||
return
|
||||
}
|
||||
|
||||
tokenString := strings.TrimPrefix(auth, "Bearer ")
|
||||
token, err := jwt.Parse(tokenString, func(token *jwt.Token) (interface{}, error) {
|
||||
if _, ok := token.Method.(*jwt.SigningMethodHMAC); !ok {
|
||||
return nil, fmt.Errorf("unexpected signing method: %v", token.Header["alg"])
|
||||
}
|
||||
return jwtSecret, nil
|
||||
})
|
||||
|
||||
if err != nil || !token.Valid {
|
||||
c.AbortWithStatusJSON(401, gin.H{"error": "invalid token"})
|
||||
return
|
||||
}
|
||||
|
||||
claims, ok := token.Claims.(jwt.MapClaims)
|
||||
if !ok {
|
||||
c.AbortWithStatusJSON(401, gin.H{"error": "invalid claims"})
|
||||
return
|
||||
}
|
||||
|
||||
idValue, idExists := claims["id"]
|
||||
if !idExists {
|
||||
c.AbortWithStatusJSON(401, gin.H{"error": "missing id in token"})
|
||||
return
|
||||
}
|
||||
|
||||
idFloat, ok := idValue.(float64)
|
||||
if !ok {
|
||||
c.AbortWithStatusJSON(401, gin.H{"error": "invalid id type in token"})
|
||||
return
|
||||
}
|
||||
|
||||
githubIDValue, githubExists := claims["github_id"]
|
||||
if !githubExists {
|
||||
c.AbortWithStatusJSON(401, gin.H{"error": "missing github_id in token"})
|
||||
return
|
||||
}
|
||||
|
||||
githubIDFloat, ok := githubIDValue.(float64)
|
||||
if !ok {
|
||||
c.AbortWithStatusJSON(401, gin.H{"error": "invalid github_id type in token"})
|
||||
return
|
||||
}
|
||||
|
||||
loginValue, loginExists := claims["login"]
|
||||
if !loginExists {
|
||||
c.AbortWithStatusJSON(401, gin.H{"error": "missing login in token"})
|
||||
return
|
||||
}
|
||||
|
||||
login, ok := loginValue.(string)
|
||||
if !ok {
|
||||
c.AbortWithStatusJSON(401, gin.H{"error": "invalid login type in token"})
|
||||
return
|
||||
}
|
||||
|
||||
c.Set("user_id", int(idFloat))
|
||||
c.Set("github_id", int(githubIDFloat))
|
||||
c.Set("login", login)
|
||||
c.Next()
|
||||
}
|
||||
}
|
||||
|
||||
func RequireAdmin() gin.HandlerFunc {
|
||||
return func(c *gin.Context) {
|
||||
githubID, exists := c.Get("github_id")
|
||||
if !exists {
|
||||
c.AbortWithStatusJSON(401, gin.H{"error": "unauthorized"})
|
||||
return
|
||||
}
|
||||
|
||||
id := githubID.(int)
|
||||
if id != 173489813 {
|
||||
c.AbortWithStatusJSON(403, gin.H{"error": "access denied"})
|
||||
return
|
||||
}
|
||||
|
||||
c.Next()
|
||||
}
|
||||
}
|
||||
|
||||
func ValidateJWT(tokenString string) (*storage.User, error) {
|
||||
token, err := jwt.Parse(tokenString, func(token *jwt.Token) (interface{}, error) {
|
||||
if _, ok := token.Method.(*jwt.SigningMethodHMAC); !ok {
|
||||
return nil, fmt.Errorf("unexpected signing method: %v", token.Header["alg"])
|
||||
}
|
||||
return jwtSecret, nil
|
||||
})
|
||||
|
||||
if err != nil || !token.Valid {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
claims, ok := token.Claims.(jwt.MapClaims)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("invalid claims")
|
||||
}
|
||||
|
||||
if exp, ok := claims["exp"].(float64); ok {
|
||||
if time.Now().Unix() > int64(exp) {
|
||||
return nil, fmt.Errorf("token expired")
|
||||
}
|
||||
}
|
||||
idFloat, ok := claims["id"].(float64)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("invalid id in token")
|
||||
}
|
||||
|
||||
githubIDFloat, ok := claims["github_id"].(float64)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("invalid github_id in token")
|
||||
}
|
||||
|
||||
login, ok := claims["login"].(string)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("invalid login in token")
|
||||
}
|
||||
|
||||
email, ok := claims["email"].(string)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("invalid email in token")
|
||||
}
|
||||
|
||||
avatarURL, _ := claims["avatar_url"].(string)
|
||||
|
||||
user := &storage.User{
|
||||
ID: int(idFloat),
|
||||
GithubID: int(githubIDFloat),
|
||||
GithubLogin: login,
|
||||
Email: email,
|
||||
AvatarURL: avatarURL,
|
||||
}
|
||||
|
||||
return user, nil
|
||||
}
|
||||
195
backend/internal/handlers/auth_handlers.go
Normal file
195
backend/internal/handlers/auth_handlers.go
Normal file
@@ -0,0 +1,195 @@
|
||||
package handlers
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"gitea.d3m0k1d.ru/d3m0k1d/d3m0k1d.ru/backend/internal/auth"
|
||||
"gitea.d3m0k1d.ru/d3m0k1d/d3m0k1d.ru/backend/internal/logger"
|
||||
"gitea.d3m0k1d.ru/d3m0k1d/d3m0k1d.ru/backend/internal/repositories"
|
||||
"gitea.d3m0k1d.ru/d3m0k1d/d3m0k1d.ru/backend/internal/storage"
|
||||
"github.com/gin-gonic/gin"
|
||||
"golang.org/x/oauth2"
|
||||
"golang.org/x/oauth2/endpoints"
|
||||
)
|
||||
|
||||
type AuthHandlers struct {
|
||||
repo repositories.AuthRepository
|
||||
logger *logger.Logger
|
||||
config *oauth2.Config
|
||||
frontendURL string
|
||||
}
|
||||
|
||||
func NewAuthHandlers(repo repositories.AuthRepository) *AuthHandlers {
|
||||
clientID := os.Getenv("GITHUB_CLIENT_ID")
|
||||
clientSecret := os.Getenv("GITHUB_CLIENT_SECRET")
|
||||
redirectURL := os.Getenv("REDIRECT_URL")
|
||||
frontendURL := os.Getenv("FRONTEND_URL")
|
||||
|
||||
if clientID == "" || clientSecret == "" {
|
||||
panic("GITHUB_CLIENT_ID and GITHUB_CLIENT_SECRET must be set")
|
||||
}
|
||||
if redirectURL == "" {
|
||||
redirectURL = "http://localhost:8080/api/v1/callback/github"
|
||||
}
|
||||
if frontendURL == "" {
|
||||
frontendURL = "https://d3m0k1d.ru"
|
||||
}
|
||||
|
||||
return &AuthHandlers{
|
||||
repo: repo,
|
||||
logger: logger.New(false),
|
||||
frontendURL: frontendURL,
|
||||
config: &oauth2.Config{
|
||||
ClientID: clientID,
|
||||
ClientSecret: clientSecret,
|
||||
RedirectURL: redirectURL,
|
||||
Scopes: []string{"user:email"},
|
||||
Endpoint: endpoints.GitHub,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// LoginGithub godoc
|
||||
// @Summary Start GitHub OAuth login
|
||||
// @Description Redirects to GitHub authorization
|
||||
// @Tags auth
|
||||
// @Success 302
|
||||
// @Router /auth/github [get]
|
||||
func (h *AuthHandlers) LoginGithub(c *gin.Context) {
|
||||
url := h.config.AuthCodeURL("state", oauth2.AccessTypeOnline)
|
||||
h.logger.Info("Redirect to GitHub: " + url)
|
||||
c.Redirect(302, url)
|
||||
}
|
||||
|
||||
// CallbackGithub godoc
|
||||
// @Summary GitHub OAuth callback
|
||||
// @Description Exchanges authorization code for access token
|
||||
// @Tags auth
|
||||
// @Param code query string true "Authorization code"
|
||||
// @Produce json
|
||||
// @Success 200 {object} map[string]interface{} "Access token"
|
||||
// @Failure 400 {object} map[string]string "Missing code"
|
||||
// @Failure 500 {object} map[string]string "Exchange failed"
|
||||
// @Router /callback/github [get]
|
||||
func (h *AuthHandlers) CallbackGithub(c *gin.Context) {
|
||||
var id int
|
||||
h.logger.Info("CallbackGithub called")
|
||||
|
||||
code := c.Query("code")
|
||||
if code == "" {
|
||||
h.logger.Error("missing code")
|
||||
c.Redirect(302, h.frontendURL+"/login?error=missing_code")
|
||||
return
|
||||
}
|
||||
|
||||
h.logger.Info("Processing code: " + code[:10] + "...")
|
||||
|
||||
token, err := h.config.Exchange(c.Request.Context(), code)
|
||||
if err != nil {
|
||||
h.logger.Error("Exchange failed: " + err.Error())
|
||||
c.Redirect(302, h.frontendURL+"/login?error=auth_failed")
|
||||
return
|
||||
}
|
||||
|
||||
client := h.config.Client(c.Request.Context(), token)
|
||||
resp, err := client.Get("https://api.github.com/user")
|
||||
if err != nil {
|
||||
h.logger.Error("Get failed: " + err.Error())
|
||||
c.Redirect(302, h.frontendURL+"/login?error=github_api_failed")
|
||||
return
|
||||
}
|
||||
|
||||
var ghUser storage.UserReg
|
||||
err = json.NewDecoder(resp.Body).Decode(&ghUser)
|
||||
if err != nil {
|
||||
h.logger.Error("Decode failed: " + err.Error())
|
||||
c.Redirect(302, h.frontendURL+"/login?error=decode_failed")
|
||||
return
|
||||
}
|
||||
|
||||
isreg, err := h.repo.IsRegistered(c.Request.Context(), ghUser.GithubID)
|
||||
if err != nil {
|
||||
h.logger.Error("Database check failed: " + err.Error())
|
||||
c.Redirect(302, h.frontendURL+"/login?error=database_error")
|
||||
return
|
||||
}
|
||||
|
||||
if !isreg {
|
||||
h.logger.Info("New user, registering: " + ghUser.GithubLogin)
|
||||
id, err = h.repo.Register(c.Request.Context(), ghUser)
|
||||
if err != nil {
|
||||
h.logger.Error("Registration failed: " + err.Error())
|
||||
c.Redirect(302, h.frontendURL+"/login?error=registration_failed")
|
||||
return
|
||||
}
|
||||
} else {
|
||||
h.logger.Info("Existing user, fetching data: " + ghUser.GithubLogin)
|
||||
user, err := h.repo.GetUserByGithubID(c.Request.Context(), ghUser.GithubID)
|
||||
if err != nil {
|
||||
h.logger.Error("Failed to fetch user: " + err.Error())
|
||||
c.Redirect(302, h.frontendURL+"/login?error=user_fetch_failed")
|
||||
return
|
||||
}
|
||||
id = user.ID
|
||||
ghUser.GithubLogin = user.GithubLogin
|
||||
ghUser.Email = user.Email
|
||||
ghUser.AvatarURL = user.AvatarURL
|
||||
}
|
||||
|
||||
user := storage.User{
|
||||
ID: id,
|
||||
GithubID: ghUser.GithubID,
|
||||
GithubLogin: ghUser.GithubLogin,
|
||||
Email: ghUser.Email,
|
||||
AvatarURL: ghUser.AvatarURL,
|
||||
}
|
||||
|
||||
jwtToken, err := auth.GenerateJWT(user)
|
||||
if err != nil {
|
||||
h.logger.Error("JWT generation failed: " + err.Error())
|
||||
c.Redirect(302, h.frontendURL+"/login?error=token_failed")
|
||||
return
|
||||
}
|
||||
|
||||
h.logger.Info("Authentication successful for user: " + ghUser.GithubLogin)
|
||||
|
||||
c.Redirect(302, h.frontendURL+"/auth/callback#token="+jwtToken)
|
||||
}
|
||||
|
||||
// GetSession godoc
|
||||
// @Summary Get user session
|
||||
// @Description Returns user session data
|
||||
// @Tags auth
|
||||
// @Produce json
|
||||
// @Success 200 {object} map[string]interface{} "Session data"
|
||||
// @Failure 401 {object} map[string]string "Unauthorized"
|
||||
// @Router /session [get]
|
||||
func (h *AuthHandlers) GetSession(c *gin.Context) {
|
||||
authHeader := c.GetHeader("Authorization")
|
||||
if authHeader == "" {
|
||||
c.JSON(401, gin.H{"error": "unauthorized"})
|
||||
return
|
||||
}
|
||||
|
||||
tokenString := strings.TrimPrefix(authHeader, "Bearer ")
|
||||
if tokenString == authHeader {
|
||||
c.JSON(401, gin.H{"error": "invalid authorization header"})
|
||||
return
|
||||
}
|
||||
|
||||
user, err := auth.ValidateJWT(tokenString)
|
||||
if err != nil {
|
||||
c.JSON(401, gin.H{"error": "invalid token"})
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(200, gin.H{
|
||||
"user": gin.H{
|
||||
"name": user.GithubLogin,
|
||||
"email": user.Email,
|
||||
"avatar": user.AvatarURL,
|
||||
},
|
||||
})
|
||||
}
|
||||
72
backend/internal/handlers/comments_handlers.go
Normal file
72
backend/internal/handlers/comments_handlers.go
Normal file
@@ -0,0 +1,72 @@
|
||||
package handlers
|
||||
|
||||
import (
|
||||
"gitea.d3m0k1d.ru/d3m0k1d/d3m0k1d.ru/backend/internal/logger"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type CommentsHandlers struct {
|
||||
logger *logger.Logger
|
||||
}
|
||||
|
||||
func NewCommentsHandlers() *CommentsHandlers {
|
||||
return &CommentsHandlers{logger: logger.New(false)}
|
||||
}
|
||||
|
||||
// GetAllComments godoc
|
||||
// @Summary Get all comments
|
||||
// @Description Get all comments
|
||||
// @Tags comments
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Success 200 {object} models.SuccessResponse{data=[]storage.Comment}
|
||||
// @Failure 404 {object} models.ErrorResponse "No Comment found"
|
||||
// @Failure 500 {object} models.ErrorResponse "Internal server error"
|
||||
// @Router /comments [get]
|
||||
func (h *CommentsHandlers) GetAllComments(c *gin.Context) {
|
||||
}
|
||||
|
||||
// GetCommentsOfPost godoc
|
||||
// @Summary Get comments of post
|
||||
// @Description Get comments of post
|
||||
// @Tags comments
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path int true "Post ID"
|
||||
// @Success 200 {object} models.SuccessResponse{data=[]storage.Comment}
|
||||
// @Failure 404 {object} models.ErrorResponse "No Comment found"
|
||||
// @Failure 500 {object} models.ErrorResponse "Internal server error"
|
||||
// @Router /posts/{id}/comments [get]
|
||||
func (h *CommentsHandlers) GetCommentsOfPost(c *gin.Context) {
|
||||
}
|
||||
|
||||
// CreateComment godoc
|
||||
// @Summary Create comment
|
||||
// @Description Create new comment
|
||||
// @Tags comments
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param comment body storage.CommentCreate true "Comment data"
|
||||
// @Security Bearer
|
||||
// @Success 200 {object} models.SuccessResponse{data=storage.Comment}
|
||||
// @Failure 400 {object} models.ErrorResponse "Invalid request"
|
||||
// @Failure 500 {object} models.ErrorResponse "Internal server error"
|
||||
// @Router /comments [post]
|
||||
func (h *CommentsHandlers) CreateComment(c *gin.Context) {
|
||||
}
|
||||
|
||||
// DeleteComment godoc
|
||||
// @Summary Delete comment
|
||||
// @Description Delete comment
|
||||
// @Tags admin
|
||||
// @Security Bearer
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path int true "Comment ID"
|
||||
// @Success 200 {object} models.SuccessResponse{data=storage.Comment}
|
||||
// @Failure 400 {object} models.ErrorResponse "Invalid ID format"
|
||||
// @Failure 404 {object} models.ErrorResponse "Comment not found"
|
||||
// @Failure 500 {object} models.ErrorResponse "Internal server error"
|
||||
// @Router admin/comments/{id} [delete]
|
||||
func (h *CommentsHandlers) DeleteComment(c *gin.Context) {
|
||||
}
|
||||
224
backend/internal/handlers/post_handlers.go
Normal file
224
backend/internal/handlers/post_handlers.go
Normal file
@@ -0,0 +1,224 @@
|
||||
package handlers
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
|
||||
"gitea.d3m0k1d.ru/d3m0k1d/d3m0k1d.ru/backend/internal/logger"
|
||||
"gitea.d3m0k1d.ru/d3m0k1d/d3m0k1d.ru/backend/internal/models"
|
||||
"gitea.d3m0k1d.ru/d3m0k1d/d3m0k1d.ru/backend/internal/repositories"
|
||||
"gitea.d3m0k1d.ru/d3m0k1d/d3m0k1d.ru/backend/internal/storage"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type PostHandlers struct {
|
||||
repo repositories.PostRepository
|
||||
logger *logger.Logger
|
||||
}
|
||||
|
||||
func NewPostHandlers(repo repositories.PostRepository) *PostHandlers {
|
||||
return &PostHandlers{repo: repo, logger: logger.New(false)}
|
||||
}
|
||||
|
||||
// GetPosts godoc
|
||||
// @Summary Get all published posts
|
||||
// @Description Get all posts
|
||||
// @Tags posts
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Success 200 {object} models.SuccessResponse{data=[]storage.PostReq}
|
||||
// @Failure 404 {object} models.ErrorResponse "No Post found"
|
||||
// @Failure 500 {object} models.ErrorResponse "Internal server error"
|
||||
// @Failure 400 {object} models.ErrorResponse "Invalid ID format"
|
||||
// @Router /posts [get]
|
||||
func (h *PostHandlers) GetPosts(c *gin.Context) {
|
||||
var result []storage.PostReq
|
||||
result, err := h.repo.GetAll(c.Request.Context())
|
||||
if err != nil {
|
||||
h.logger.Error("error request: " + err.Error())
|
||||
models.Error(c, 500, "Internal server error", err.Error())
|
||||
return
|
||||
}
|
||||
if result == nil {
|
||||
models.Error(c, 404, "No Post found", "")
|
||||
return
|
||||
}
|
||||
h.logger.Info("200 OK GET /posts")
|
||||
models.Success(c, result)
|
||||
}
|
||||
|
||||
// GetPost godoc
|
||||
// @Summary Get post by id
|
||||
// @Description Get post by id
|
||||
// @Tags posts
|
||||
// @Accept json
|
||||
// @Param id path int true "Post ID"
|
||||
// @Produce json
|
||||
// @Success 200 {object} models.SuccessResponse{data=storage.PostReq}
|
||||
// @Failure 400 {object} models.ErrorResponse "Invalid ID format"
|
||||
// @Failure 404 {object} models.ErrorResponse "Post not found"
|
||||
// @Failure 500 {object} models.ErrorResponse "Internal server error"
|
||||
// @Router /posts/{id} [get]
|
||||
func (h *PostHandlers) GetPost(c *gin.Context) {
|
||||
var result storage.PostReq
|
||||
last_id, err := h.repo.GetLastID(c.Request.Context())
|
||||
if err != nil {
|
||||
h.logger.Error("error request: " + err.Error())
|
||||
models.Error(c, 500, "Internal server error", err.Error())
|
||||
return
|
||||
}
|
||||
id_p := c.Param("id")
|
||||
id, err := strconv.Atoi(id_p)
|
||||
if err != nil {
|
||||
h.logger.Error("error request: " + err.Error())
|
||||
models.Error(c, 400, "Invalid ID format", err.Error())
|
||||
return
|
||||
}
|
||||
if id > last_id {
|
||||
models.Error(c, 404, "Post not found", "")
|
||||
return
|
||||
}
|
||||
result, err = h.repo.GetByID(c.Request.Context(), id)
|
||||
if err != nil {
|
||||
h.logger.Error("error request: " + err.Error())
|
||||
models.Error(c, 500, "Internal server error", err.Error())
|
||||
return
|
||||
}
|
||||
h.logger.Info("200 OK GET /posts/" + id_p)
|
||||
models.Success(c, result)
|
||||
|
||||
}
|
||||
|
||||
// CreatePost godoc
|
||||
// @Summary Create post
|
||||
// @Description Create new post
|
||||
// @Tags posts
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param post body storage.PostCreate true "Post data"
|
||||
// @Security Bearer
|
||||
// @Success 200 {object} models.SuccessResponse{data=storage.Post}
|
||||
// @Failure 400 {object} models.ErrorResponse "Invalid request"
|
||||
// @Router /posts [post]
|
||||
func (h *PostHandlers) CreatePost(c *gin.Context) {
|
||||
var req storage.PostCreate
|
||||
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
models.Error(c, 400, "Invalid request", err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
post := storage.Post{
|
||||
Title: req.Title,
|
||||
Content: req.Content,
|
||||
Tags: req.Tags,
|
||||
}
|
||||
|
||||
if err := h.repo.Create(c.Request.Context(), post); err != nil {
|
||||
models.Error(c, 500, "Internal server error", err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
models.Success(c, post)
|
||||
}
|
||||
|
||||
// UpdatePost godoc
|
||||
// @Summary Update post
|
||||
// @Description Update post
|
||||
// @Tags posts
|
||||
// @Accept json
|
||||
// @Param id path int true "Post ID"
|
||||
// @Param post body storage.PostCreate true "Post data"
|
||||
// @Produce json
|
||||
// @Security Bearer
|
||||
// @Success 200 {object} models.SuccessResponse{data=storage.PostCreate}
|
||||
// @Failure 400 {object} models.ErrorResponse "Invalid ID format"
|
||||
// @Failure 500 {object} models.ErrorResponse "Internal server error"
|
||||
// Failure 404 {object} models.ErrorResponse "Post not found"
|
||||
// @Router /posts/{id} [put]
|
||||
func (h *PostHandlers) UpdatePost(c *gin.Context) {
|
||||
id_p := c.Param("id")
|
||||
id, err := strconv.Atoi(id_p)
|
||||
if err != nil {
|
||||
h.logger.Error("error request: " + err.Error())
|
||||
models.Error(c, 500, "Internal server error", err.Error())
|
||||
return
|
||||
}
|
||||
var req storage.Post
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
models.Error(c, 400, "Invalid request", err.Error())
|
||||
return
|
||||
}
|
||||
err = h.repo.Update(c.Request.Context(), id, req)
|
||||
if err != nil {
|
||||
models.Error(c, 500, "Internal server error", err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
models.Success(c, req)
|
||||
h.logger.Info("200 OK PUT /posts/" + id_p)
|
||||
}
|
||||
|
||||
// DeletePost godoc
|
||||
// @Summary Delete post
|
||||
// @Description Delete post
|
||||
// @Tags posts
|
||||
// @Param id path int true "Post ID"
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Security Bearer
|
||||
// @Failure 404 {object} models.ErrorResponse "Post not found"
|
||||
// @Failure 400 {object} models.ErrorResponse "Invalid ID format"
|
||||
// @Failure 500 {object} models.ErrorResponse "Internal server error"
|
||||
// @Success 200 {object} models.SuccessResponse{data=storage.Post}
|
||||
// @Router /posts/{id} [delete]
|
||||
func (h *PostHandlers) DeletePost(c *gin.Context) {
|
||||
id_p := c.Param("id")
|
||||
id, err := strconv.Atoi(id_p)
|
||||
if err != nil {
|
||||
h.logger.Error("error request: " + err.Error())
|
||||
models.Error(c, 400, "Invalid ID format", err.Error())
|
||||
return
|
||||
}
|
||||
exsist := h.repo.IsExist(c.Request.Context(), id)
|
||||
if !exsist {
|
||||
models.Error(c, 404, "Post not found", "")
|
||||
return
|
||||
}
|
||||
err = h.repo.Delete(c.Request.Context(), id)
|
||||
if err != nil {
|
||||
models.Error(c, 500, "Internal server error", err.Error())
|
||||
return
|
||||
}
|
||||
h.logger.Info("200 OK DELETE /posts/" + id_p)
|
||||
models.Success(c, "Post deleted")
|
||||
|
||||
}
|
||||
|
||||
// GetPosts godoc
|
||||
// @Summary Get all posts
|
||||
// @Description Get all posts
|
||||
// @Tags admin
|
||||
// @Security Bearer
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Success 200 {object} models.SuccessResponse{data=[]storage.PostReq}
|
||||
// @Failure 404 {object} models.ErrorResponse "No Post found"
|
||||
// @Failure 500 {object} models.ErrorResponse "Internal server error"
|
||||
// @Failure 400 {object} models.ErrorResponse "Invalid ID format"
|
||||
// @Router /admin/posts [get]
|
||||
func (h *PostHandlers) AdminGetAll(c *gin.Context) {
|
||||
var result []storage.PostReq
|
||||
result, err := h.repo.GetAllAdmin(c.Request.Context())
|
||||
if err != nil {
|
||||
h.logger.Error("error request: " + err.Error())
|
||||
models.Error(c, 500, "Internal server error", err.Error())
|
||||
return
|
||||
}
|
||||
if result == nil {
|
||||
models.Error(c, 404, "No Post found", "")
|
||||
return
|
||||
}
|
||||
h.logger.Info("200 OK GET /posts")
|
||||
models.Success(c, result)
|
||||
|
||||
}
|
||||
1
backend/internal/handlers/posts_test.go
Normal file
1
backend/internal/handlers/posts_test.go
Normal file
@@ -0,0 +1 @@
|
||||
package handlers
|
||||
36
backend/internal/handlers/registry_handlers.go
Normal file
36
backend/internal/handlers/registry_handlers.go
Normal file
@@ -0,0 +1,36 @@
|
||||
package handlers
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
|
||||
"gitea.d3m0k1d.ru/d3m0k1d/d3m0k1d.ru/backend/internal/auth"
|
||||
"gitea.d3m0k1d.ru/d3m0k1d/d3m0k1d.ru/backend/internal/repositories"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func Register(router *gin.Engine, db *sql.DB) {
|
||||
handler_posts := NewPostHandlers(repositories.NewPostRepository(db))
|
||||
handler_auth := NewAuthHandlers(repositories.NewAuthRepository(db))
|
||||
handler_static := NewStaticHandlers()
|
||||
router.GET("/health", func(c *gin.Context) { c.Status(200) })
|
||||
v1 := router.Group("api/v1")
|
||||
admin := v1.Group("admin")
|
||||
{
|
||||
admin.GET("/posts", auth.JWTMiddleware(), auth.RequireAdmin(), handler_posts.AdminGetAll)
|
||||
}
|
||||
v1.Static("/uploads", "/data/uploads")
|
||||
v1.POST("/upload", auth.JWTMiddleware(), auth.RequireAdmin(), handler_static.PostStatic)
|
||||
v1.GET("/upload/:file", handler_static.GetStatic)
|
||||
v1.GET("/callback/github", handler_auth.CallbackGithub)
|
||||
v1.GET("/auth/github", handler_auth.LoginGithub)
|
||||
v1.GET("/session", auth.JWTMiddleware(), handler_auth.GetSession)
|
||||
posts := v1.Group("posts")
|
||||
{
|
||||
|
||||
posts.GET("/", handler_posts.GetPosts)
|
||||
posts.GET("/:id", handler_posts.GetPost)
|
||||
posts.POST("/", auth.JWTMiddleware(), auth.RequireAdmin(), handler_posts.CreatePost)
|
||||
posts.PUT("/:id", auth.JWTMiddleware(), auth.RequireAdmin(), handler_posts.UpdatePost)
|
||||
posts.DELETE("/:id", auth.JWTMiddleware(), auth.RequireAdmin(), handler_posts.DeletePost)
|
||||
}
|
||||
}
|
||||
91
backend/internal/handlers/static_handlers.go
Normal file
91
backend/internal/handlers/static_handlers.go
Normal file
@@ -0,0 +1,91 @@
|
||||
package handlers
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"gitea.d3m0k1d.ru/d3m0k1d/d3m0k1d.ru/backend/internal/logger"
|
||||
"gitea.d3m0k1d.ru/d3m0k1d/d3m0k1d.ru/backend/internal/models"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type StaticHandlers struct {
|
||||
logger *logger.Logger
|
||||
}
|
||||
|
||||
func NewStaticHandlers() *StaticHandlers {
|
||||
return &StaticHandlers{
|
||||
logger: logger.New(false),
|
||||
}
|
||||
}
|
||||
|
||||
// PostStatic godoc
|
||||
// @Summary Upload static content
|
||||
// @Description Upload static content to the server
|
||||
// @Tags static
|
||||
// @Produce json
|
||||
// @Success 200 {object} models.SuccessResponse(data=string) "Static content"
|
||||
// @Failure 500 {object} models.ErrorResponse "Internal server error"
|
||||
// @Router /upload [post]
|
||||
func (h *StaticHandlers) PostStatic(c *gin.Context) {
|
||||
content, err := c.FormFile("file")
|
||||
if err != nil {
|
||||
h.logger.Error("error request: " + err.Error())
|
||||
models.Error(c, 500, "Internal server error", err.Error())
|
||||
return
|
||||
}
|
||||
dst := "/data/upload/" + content.Filename
|
||||
if err = c.SaveUploadedFile(content, dst); err != nil {
|
||||
h.logger.Error("error request: " + err.Error())
|
||||
models.Error(c, 500, "Internal server error", err.Error())
|
||||
return
|
||||
}
|
||||
models.Success(c, "Static content saved")
|
||||
}
|
||||
|
||||
// GetStatic godoc
|
||||
// @Summary Get static content
|
||||
// @Description Get static content
|
||||
// @Tags static
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param file path string true "File name"
|
||||
// @Success 200 {object} models.SuccessResponse{data=string} "Static content"
|
||||
// @Failure 500 {object} models.ErrorResponse "Internal server error"
|
||||
// @Failure 404 {object} models.ErrorResponse "File not found"
|
||||
// @Router /upload/{file} [get]
|
||||
func (h *StaticHandlers) GetStatic(c *gin.Context) {
|
||||
|
||||
filename := c.Param("file")
|
||||
if filename == "" {
|
||||
models.Error(c, 404, "File not found", "")
|
||||
return
|
||||
}
|
||||
|
||||
filename = filepath.Clean(filename)
|
||||
|
||||
if strings.Contains(filename, "..") {
|
||||
models.Error(c, 400, "Invalid file path", "")
|
||||
return
|
||||
}
|
||||
|
||||
if filepath.IsAbs(filename) {
|
||||
models.Error(c, 400, "Invalid file path", "")
|
||||
return
|
||||
}
|
||||
|
||||
baseDir := "/data/upload/"
|
||||
fullPath := filepath.Join(baseDir, filename)
|
||||
if !strings.HasPrefix(fullPath, baseDir) {
|
||||
models.Error(c, 400, "Invalid file path", "")
|
||||
return
|
||||
}
|
||||
|
||||
if _, err := os.Stat(fullPath); os.IsNotExist(err) {
|
||||
models.Error(c, 404, "File not found", "")
|
||||
return
|
||||
}
|
||||
|
||||
c.File(fullPath)
|
||||
}
|
||||
45
backend/internal/logger/logger.go
Normal file
45
backend/internal/logger/logger.go
Normal file
@@ -0,0 +1,45 @@
|
||||
package logger
|
||||
|
||||
import (
|
||||
"io"
|
||||
"log/slog"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"gopkg.in/natefinch/lumberjack.v2"
|
||||
)
|
||||
|
||||
type Logger struct {
|
||||
*slog.Logger
|
||||
}
|
||||
|
||||
func New(debug bool) *Logger {
|
||||
logDir := "/var/log/backend"
|
||||
if err := os.MkdirAll(logDir, 0750); err != nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
fileWriter := &lumberjack.Logger{
|
||||
Filename: filepath.Join(logDir, "backend.log"),
|
||||
MaxSize: 500,
|
||||
MaxBackups: 3,
|
||||
MaxAge: 28,
|
||||
Compress: true,
|
||||
}
|
||||
|
||||
var level slog.Level
|
||||
if debug {
|
||||
level = slog.LevelDebug
|
||||
} else {
|
||||
level = slog.LevelInfo
|
||||
}
|
||||
multiWriter := io.MultiWriter(fileWriter, os.Stdout)
|
||||
|
||||
handler := slog.NewTextHandler(multiWriter, &slog.HandlerOptions{
|
||||
Level: level,
|
||||
})
|
||||
|
||||
return &Logger{
|
||||
Logger: slog.New(handler),
|
||||
}
|
||||
}
|
||||
27
backend/internal/models/responses.go
Normal file
27
backend/internal/models/responses.go
Normal file
@@ -0,0 +1,27 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type SuccessResponse struct {
|
||||
Data interface{} `json:"data"`
|
||||
}
|
||||
|
||||
type ErrorResponse struct {
|
||||
Error ErrorDetail `json:"error"`
|
||||
}
|
||||
|
||||
type ErrorDetail struct {
|
||||
Code int `json:"code"`
|
||||
Message string `json:"message"`
|
||||
Detail string `json:"detail"`
|
||||
}
|
||||
|
||||
func Success(c *gin.Context, data interface{}) {
|
||||
c.JSON(200, SuccessResponse{Data: data})
|
||||
}
|
||||
|
||||
func Error(c *gin.Context, code int, message string, detail string) {
|
||||
c.JSON(code, ErrorResponse{Error: ErrorDetail{Code: code, Message: message, Detail: detail}})
|
||||
}
|
||||
77
backend/internal/repositories/auth_repository.go
Normal file
77
backend/internal/repositories/auth_repository.go
Normal file
@@ -0,0 +1,77 @@
|
||||
package repositories
|
||||
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
|
||||
"gitea.d3m0k1d.ru/d3m0k1d/d3m0k1d.ru/backend/internal/logger"
|
||||
"gitea.d3m0k1d.ru/d3m0k1d/d3m0k1d.ru/backend/internal/storage"
|
||||
)
|
||||
|
||||
type authRepository struct {
|
||||
db *sql.DB
|
||||
logger *logger.Logger
|
||||
}
|
||||
|
||||
func NewAuthRepository(db *sql.DB) AuthRepository {
|
||||
return &authRepository{
|
||||
db: db,
|
||||
logger: logger.New(false),
|
||||
}
|
||||
}
|
||||
|
||||
func (a *authRepository) Register(ctx context.Context, user storage.UserReg) (int, error) {
|
||||
var id int
|
||||
_, err := a.db.ExecContext(ctx,
|
||||
"INSERT INTO users(email, github_id, github_login, avatar_url) VALUES(?, ?, ?, ?)",
|
||||
user.Email, user.GithubID, user.GithubLogin, user.AvatarURL,
|
||||
)
|
||||
if err != nil {
|
||||
a.logger.Error("error insert: " + err.Error())
|
||||
return 0, err
|
||||
}
|
||||
|
||||
row := a.db.QueryRowContext(ctx, "SELECT id FROM users WHERE github_id = ?", user.GithubID)
|
||||
err = row.Scan(&id)
|
||||
if err != nil {
|
||||
a.logger.Error("error scan: " + err.Error())
|
||||
return 0, err
|
||||
}
|
||||
|
||||
a.logger.Info("User registered: " + user.Email)
|
||||
return id, nil
|
||||
}
|
||||
|
||||
func (a *authRepository) IsRegistered(ctx context.Context, github_id int) (bool, error) {
|
||||
var id int
|
||||
err := a.db.QueryRowContext(ctx, "SELECT id FROM users WHERE github_id = ?", github_id).
|
||||
Scan(&id)
|
||||
if err != nil {
|
||||
if err == sql.ErrNoRows {
|
||||
return false, nil
|
||||
}
|
||||
return false, err
|
||||
}
|
||||
return true, nil
|
||||
}
|
||||
|
||||
func (r *authRepository) GetUserByGithubID(
|
||||
ctx context.Context,
|
||||
githubID int,
|
||||
) (*storage.User, error) {
|
||||
var user storage.User
|
||||
query := `SELECT id, github_id, github_login, email, avatar_url FROM users WHERE github_id = ?`
|
||||
|
||||
err := r.db.QueryRowContext(ctx, query, githubID).Scan(
|
||||
&user.ID,
|
||||
&user.GithubID,
|
||||
&user.GithubLogin,
|
||||
&user.Email,
|
||||
&user.AvatarURL,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &user, nil
|
||||
}
|
||||
86
backend/internal/repositories/comments_repository.go
Normal file
86
backend/internal/repositories/comments_repository.go
Normal file
@@ -0,0 +1,86 @@
|
||||
package repositories
|
||||
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
|
||||
"gitea.d3m0k1d.ru/d3m0k1d/d3m0k1d.ru/backend/internal/logger"
|
||||
|
||||
"gitea.d3m0k1d.ru/d3m0k1d/d3m0k1d.ru/backend/internal/storage"
|
||||
)
|
||||
|
||||
type commentsRepository struct {
|
||||
db *sql.DB
|
||||
logger *logger.Logger
|
||||
}
|
||||
|
||||
func NewCommentsRepository(db *sql.DB) CommentRepository {
|
||||
return &commentsRepository{
|
||||
db: db,
|
||||
logger: logger.New(false),
|
||||
}
|
||||
}
|
||||
|
||||
func (c *commentsRepository) CreateComment(
|
||||
ctx context.Context,
|
||||
comment *storage.CommentCreate,
|
||||
) error {
|
||||
_, err := c.db.Exec(
|
||||
"INSERT INTO comments(content, post_id) VALUES(?, ?, ?)",
|
||||
comment.Content,
|
||||
comment.PostID,
|
||||
comment.UserID,
|
||||
)
|
||||
if err != nil {
|
||||
c.logger.Error("error insert: " + err.Error())
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *commentsRepository) GetAllComments(ctx context.Context) ([]storage.Comment, error) {
|
||||
var result []storage.Comment
|
||||
rows, err := c.db.Query("SELECT id, content, post_id, user_id, created_at FROM comments")
|
||||
if err != nil {
|
||||
c.logger.Error("error scan " + err.Error())
|
||||
return nil, err
|
||||
}
|
||||
for rows.Next() {
|
||||
var id int
|
||||
var content string
|
||||
var postID int
|
||||
var userID int
|
||||
var createdAt string
|
||||
err := rows.Scan(&id, &content, &postID, &userID, &createdAt)
|
||||
if err != nil {
|
||||
c.logger.Error("error scan: " + err.Error())
|
||||
}
|
||||
result = append(result, storage.Comment{
|
||||
ID: id,
|
||||
Content: content,
|
||||
PostID: postID,
|
||||
UserID: userID,
|
||||
CreatedAt: createdAt,
|
||||
})
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (c *commentsRepository) GetCommentsOfPost(
|
||||
ctx context.Context,
|
||||
id int,
|
||||
) ([]storage.Comment, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (c *commentsRepository) DeleteComment(ctx context.Context, id int) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *commentsRepository) UpdateComment(
|
||||
ctx context.Context,
|
||||
id int,
|
||||
comment *storage.Comment,
|
||||
) error {
|
||||
return nil
|
||||
}
|
||||
32
backend/internal/repositories/interface.go
Normal file
32
backend/internal/repositories/interface.go
Normal file
@@ -0,0 +1,32 @@
|
||||
package repositories
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"gitea.d3m0k1d.ru/d3m0k1d/d3m0k1d.ru/backend/internal/storage"
|
||||
)
|
||||
|
||||
type PostRepository interface {
|
||||
GetAll(ctx context.Context) ([]storage.PostReq, error)
|
||||
GetAllAdmin(ctx context.Context) ([]storage.PostReq, error)
|
||||
GetByID(ctx context.Context, id int) (storage.PostReq, error)
|
||||
GetLastID(ctx context.Context) (int, error)
|
||||
IsExist(ctx context.Context, id int) bool
|
||||
Create(ctx context.Context, post storage.Post) error
|
||||
Update(ctx context.Context, id int, post storage.Post) error
|
||||
Delete(ctx context.Context, id int) error
|
||||
}
|
||||
|
||||
type AuthRepository interface {
|
||||
Register(ctx context.Context, user storage.UserReg) (int, error)
|
||||
IsRegistered(ctx context.Context, github_id int) (bool, error)
|
||||
GetUserByGithubID(ctx context.Context, githubID int) (*storage.User, error)
|
||||
}
|
||||
|
||||
type CommentRepository interface {
|
||||
CreateComment(ctx context.Context, comment *storage.CommentCreate) error
|
||||
GetAllComments(ctx context.Context) ([]storage.Comment, error)
|
||||
GetCommentsOfPost(ctx context.Context, id int) ([]storage.Comment, error)
|
||||
DeleteComment(ctx context.Context, id int) error
|
||||
UpdateComment(ctx context.Context, id int, comment *storage.Comment) error
|
||||
}
|
||||
176
backend/internal/repositories/post_repository.go
Normal file
176
backend/internal/repositories/post_repository.go
Normal file
@@ -0,0 +1,176 @@
|
||||
package repositories
|
||||
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"strings"
|
||||
|
||||
"gitea.d3m0k1d.ru/d3m0k1d/d3m0k1d.ru/backend/internal/logger"
|
||||
"gitea.d3m0k1d.ru/d3m0k1d/d3m0k1d.ru/backend/internal/storage"
|
||||
)
|
||||
|
||||
type postRepository struct {
|
||||
db *sql.DB
|
||||
logger *logger.Logger
|
||||
}
|
||||
|
||||
func NewPostRepository(db *sql.DB) PostRepository {
|
||||
return &postRepository{
|
||||
db: db,
|
||||
logger: logger.New(false),
|
||||
}
|
||||
}
|
||||
func (p *postRepository) GetAll(ctx context.Context) ([]storage.PostReq, error) {
|
||||
var result []storage.PostReq
|
||||
rows, err := p.db.Query("SELECT id, title, content, CREATED_AT FROM posts WHERE published = 1")
|
||||
if err != nil {
|
||||
p.logger.Error(err.Error())
|
||||
return nil, err
|
||||
}
|
||||
for rows.Next() {
|
||||
var title string
|
||||
var content string
|
||||
var id int
|
||||
var createdAt string
|
||||
err := rows.Scan(&id, &title, &content, &createdAt)
|
||||
if err != nil {
|
||||
p.logger.Error("error scan: " + err.Error())
|
||||
}
|
||||
result = append(result, storage.PostReq{
|
||||
ID: id,
|
||||
Title: title,
|
||||
Content: content,
|
||||
CreatedAt: createdAt,
|
||||
})
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (p *postRepository) GetByID(ctx context.Context, id int) (storage.PostReq, error) {
|
||||
var result storage.PostReq
|
||||
row := p.db.QueryRow(
|
||||
"SELECT title, content, CREATED_AT FROM posts WHERE id = ? AND published = 1",
|
||||
id,
|
||||
)
|
||||
var title string
|
||||
var content string
|
||||
var createdAt string
|
||||
err := row.Scan(&title, &content, &createdAt)
|
||||
if err != nil {
|
||||
p.logger.Error("error scan: " + err.Error())
|
||||
}
|
||||
result = storage.PostReq{
|
||||
ID: id,
|
||||
Title: title,
|
||||
Content: content,
|
||||
CreatedAt: createdAt,
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (p *postRepository) Create(ctx context.Context, post storage.Post) error {
|
||||
query, err := p.db.Exec(
|
||||
"INSERT INTO posts(title, content) VALUES(?, ?, ?)",
|
||||
post.Title,
|
||||
post.Content,
|
||||
post.Tags,
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
id, err := query.LastInsertId()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
p.logger.Info("Post created:", "id", id)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *postRepository) Update(ctx context.Context, id int, post storage.Post) error {
|
||||
query := "UPDATE posts SET "
|
||||
args := []interface{}{}
|
||||
updates := []string{}
|
||||
|
||||
if post.Title != "" {
|
||||
updates = append(updates, "title = ?")
|
||||
args = append(args, post.Title)
|
||||
}
|
||||
if post.Tags != "" {
|
||||
updates = append(updates, "tags = ?")
|
||||
args = append(args, post.Tags)
|
||||
}
|
||||
if post.Content != "" {
|
||||
updates = append(updates, "content = ?")
|
||||
args = append(args, post.Content)
|
||||
}
|
||||
|
||||
updates = append(updates, "published = ?")
|
||||
args = append(args, post.Published)
|
||||
updates = append(updates, "updated_at = CURRENT_TIMESTAMP")
|
||||
query += strings.Join(updates, ", ")
|
||||
query += " WHERE id = ?"
|
||||
args = append(args, id)
|
||||
|
||||
_, err := p.db.ExecContext(ctx, query, args...)
|
||||
return err
|
||||
}
|
||||
|
||||
func (p *postRepository) Delete(ctx context.Context, id int) error {
|
||||
_, err := p.db.Exec("DELETE FROM posts WHERE id = ?", id)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
p.logger.Info("Post deleted:", "id", id)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *postRepository) GetLastID(ctx context.Context) (int, error) {
|
||||
var id int
|
||||
row := p.db.QueryRow("SELECT id FROM posts ORDER BY id DESC LIMIT 1")
|
||||
err := row.Scan(&id)
|
||||
if err != nil {
|
||||
p.logger.Error("error scan: " + err.Error())
|
||||
}
|
||||
return id, nil
|
||||
}
|
||||
|
||||
func (p *postRepository) IsExist(ctx context.Context, id int) bool {
|
||||
var exists int
|
||||
err := p.db.QueryRowContext(ctx, "SELECT 1 FROM posts WHERE id = ? LIMIT 1", id).Scan(&exists)
|
||||
if err != nil {
|
||||
if err == sql.ErrNoRows {
|
||||
return false
|
||||
}
|
||||
p.logger.Error("error checking post existence: " + err.Error())
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func (p *postRepository) GetAllAdmin(ctx context.Context) ([]storage.PostReq, error) {
|
||||
result := []storage.PostReq{}
|
||||
rows, err := p.db.Query("SELECT id, title, content, tags, CREATED_AT FROM posts")
|
||||
if err != nil {
|
||||
p.logger.Error(err.Error())
|
||||
return nil, err
|
||||
}
|
||||
for rows.Next() {
|
||||
var title string
|
||||
var content string
|
||||
var id int
|
||||
var tags string
|
||||
var createdAt string
|
||||
err := rows.Scan(&id, &title, &content, &tags, &createdAt)
|
||||
if err != nil {
|
||||
p.logger.Error("error scan: " + err.Error())
|
||||
}
|
||||
result = append(result, storage.PostReq{
|
||||
ID: id,
|
||||
Title: title,
|
||||
Content: content,
|
||||
Tags: tags,
|
||||
CreatedAt: createdAt,
|
||||
})
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
32
backend/internal/storage/db.go
Normal file
32
backend/internal/storage/db.go
Normal file
@@ -0,0 +1,32 @@
|
||||
package storage
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"os"
|
||||
|
||||
"gitea.d3m0k1d.ru/d3m0k1d/d3m0k1d.ru/backend/internal/logger"
|
||||
_ "modernc.org/sqlite"
|
||||
)
|
||||
|
||||
var path = os.Getenv("DB_PATH")
|
||||
|
||||
var params = "?_journal_mode=WAL&_busy_timeout=5000&_synchronous=NORMAL&_cache_size=2000&_foreign_keys=ON"
|
||||
|
||||
func CreateTables(db *sql.DB) error {
|
||||
logger := logger.New(false)
|
||||
_, err := db.Exec(Migrations)
|
||||
if err != nil {
|
||||
logger.Error(err.Error())
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func OpenSession() (*sql.DB, error) {
|
||||
db, err := sql.Open("sqlite", path+params)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return db, nil
|
||||
}
|
||||
31
backend/internal/storage/migrations.go
Normal file
31
backend/internal/storage/migrations.go
Normal file
@@ -0,0 +1,31 @@
|
||||
package storage
|
||||
|
||||
const Migrations = `
|
||||
CREATE TABLE IF NOT EXISTS posts(
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
title TEXT NOT NULL,
|
||||
published BOOLEAN DEFAULT 0,
|
||||
content TEXT NOT NULL,
|
||||
CREATED_AT DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at DATETIME,
|
||||
tags TEXT
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS users(
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
email TEXT,
|
||||
github_id INTEGER,
|
||||
github_login TEXT,
|
||||
avatar_url TEXT
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS comments(
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
post_id INTEGER NOT NULL,
|
||||
user_id INTEGER,
|
||||
content TEXT NOT NULL,
|
||||
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||
FOREIGN KEY (post_id) REFERENCES posts(id),
|
||||
FOREIGN KEY (user_id) REFERENCES users(id)
|
||||
);
|
||||
`
|
||||
65
backend/internal/storage/models.go
Normal file
65
backend/internal/storage/models.go
Normal file
@@ -0,0 +1,65 @@
|
||||
package storage
|
||||
|
||||
// Post
|
||||
type Post struct {
|
||||
ID int `db:"id" json:"id"`
|
||||
Title string `db:"title" json:"title"`
|
||||
Published bool `db:"published" json:"published"`
|
||||
Content string `db:"content" json:"content"`
|
||||
CreatedAt string `db:"created_at" json:"created_at"`
|
||||
Tags string `db:"tags" json:"tags"`
|
||||
}
|
||||
|
||||
type PostReq struct {
|
||||
ID int `db:"id" json:"id"`
|
||||
Title string `db:"title" json:"title"`
|
||||
Content string `db:"content" json:"content"`
|
||||
CreatedAt string `db:"created" json:"created_at"`
|
||||
Tags string `db:"tags" json:"tags"`
|
||||
}
|
||||
|
||||
type PostCreate struct {
|
||||
Title string `db:"title" json:"title"`
|
||||
Published bool `db:"published" json:"published"`
|
||||
Content string `db:"content" json:"content"`
|
||||
Tags string `db:"tags" json:"tags"`
|
||||
}
|
||||
|
||||
// User
|
||||
type User struct {
|
||||
ID int `db:"id" json:"id"`
|
||||
Email string `db:"email" json:"email"`
|
||||
GithubID int `db:"github_id" json:"github_id"`
|
||||
GithubLogin string `db:"github_login" json:"github_login"`
|
||||
AvatarURL string `db:"avatar_url" json:"avatar_url"`
|
||||
}
|
||||
|
||||
type UserReg struct {
|
||||
Email string `json:"email"`
|
||||
GithubID int `json:"id"`
|
||||
GithubLogin string `json:"login"`
|
||||
AvatarURL string `json:"avatar_url"`
|
||||
}
|
||||
|
||||
// Comment
|
||||
type Comment struct {
|
||||
ID int `db:"id" json:"id"`
|
||||
PostID int `db:"post_id" json:"post_id"`
|
||||
UserID int `db:"user_id" json:"user_id"`
|
||||
Content string `db:"content" json:"content"`
|
||||
CreatedAt string `db:"created_at" json:"created_at"`
|
||||
}
|
||||
|
||||
type CommentReq struct {
|
||||
ID int `db:"id" json:"id"`
|
||||
PostID int `db:"post_id" json:"post_id"`
|
||||
UserID int `db:"user_id" json:"user_id"`
|
||||
Content string `db:"content" json:"content"`
|
||||
CreatedAt string `db:"created_at" json:"created_at"`
|
||||
}
|
||||
|
||||
type CommentCreate struct {
|
||||
PostID int `db:"post_id" json:"post_id"`
|
||||
UserID int `db:"user_id" json:"user_id"`
|
||||
Content string `db:"content" json:"content"`
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
[project]
|
||||
name = "backend"
|
||||
version = "0.1.0"
|
||||
description = "Add your description here"
|
||||
readme = "README.md"
|
||||
requires-python = ">=3.13"
|
||||
dependencies = [
|
||||
"asyncpg>=0.30.0",
|
||||
"fastapi>=0.121.3",
|
||||
"python-dotenv>=1.2.1",
|
||||
"sqlalchemy>=2.0.44",
|
||||
"uvicorn>=0.38.0",
|
||||
]
|
||||
306
backend/uv.lock
generated
306
backend/uv.lock
generated
@@ -1,306 +0,0 @@
|
||||
version = 1
|
||||
revision = 3
|
||||
requires-python = ">=3.13"
|
||||
|
||||
[[package]]
|
||||
name = "annotated-doc"
|
||||
version = "0.0.4"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/57/ba/046ceea27344560984e26a590f90bc7f4a75b06701f653222458922b558c/annotated_doc-0.0.4.tar.gz", hash = "sha256:fbcda96e87e9c92ad167c2e53839e57503ecfda18804ea28102353485033faa4", size = 7288, upload-time = "2025-11-10T22:07:42.062Z" }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/1e/d3/26bf1008eb3d2daa8ef4cacc7f3bfdc11818d111f7e2d0201bc6e3b49d45/annotated_doc-0.0.4-py3-none-any.whl", hash = "sha256:571ac1dc6991c450b25a9c2d84a3705e2ae7a53467b5d111c24fa8baabbed320", size = 5303, upload-time = "2025-11-10T22:07:40.673Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "annotated-types"
|
||||
version = "0.7.0"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/ee/67/531ea369ba64dcff5ec9c3402f9f51bf748cec26dde048a2f973a4eea7f5/annotated_types-0.7.0.tar.gz", hash = "sha256:aff07c09a53a08bc8cfccb9c85b05f1aa9a2a6f23728d790723543408344ce89", size = 16081, upload-time = "2024-05-20T21:33:25.928Z" }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/78/b6/6307fbef88d9b5ee7421e68d78a9f162e0da4900bc5f5793f6d3d0e34fb8/annotated_types-0.7.0-py3-none-any.whl", hash = "sha256:1f02e8b43a8fbbc3f3e0d4f0f4bfc8131bcb4eebe8849b8e5c773f3a1c582a53", size = 13643, upload-time = "2024-05-20T21:33:24.1Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "anyio"
|
||||
version = "4.11.0"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
dependencies = [
|
||||
{ name = "idna" },
|
||||
{ name = "sniffio" },
|
||||
]
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/c6/78/7d432127c41b50bccba979505f272c16cbcadcc33645d5fa3a738110ae75/anyio-4.11.0.tar.gz", hash = "sha256:82a8d0b81e318cc5ce71a5f1f8b5c4e63619620b63141ef8c995fa0db95a57c4", size = 219094, upload-time = "2025-09-23T09:19:12.58Z" }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/15/b3/9b1a8074496371342ec1e796a96f99c82c945a339cd81a8e73de28b4cf9e/anyio-4.11.0-py3-none-any.whl", hash = "sha256:0287e96f4d26d4149305414d4e3bc32f0dcd0862365a4bddea19d7a1ec38c4fc", size = 109097, upload-time = "2025-09-23T09:19:10.601Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "asyncpg"
|
||||
version = "0.30.0"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/2f/4c/7c991e080e106d854809030d8584e15b2e996e26f16aee6d757e387bc17d/asyncpg-0.30.0.tar.gz", hash = "sha256:c551e9928ab6707602f44811817f82ba3c446e018bfe1d3abecc8ba5f3eac851", size = 957746, upload-time = "2024-10-20T00:30:41.127Z" }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/3a/22/e20602e1218dc07692acf70d5b902be820168d6282e69ef0d3cb920dc36f/asyncpg-0.30.0-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:05b185ebb8083c8568ea8a40e896d5f7af4b8554b64d7719c0eaa1eb5a5c3a70", size = 670373, upload-time = "2024-10-20T00:29:55.165Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/3d/b3/0cf269a9d647852a95c06eb00b815d0b95a4eb4b55aa2d6ba680971733b9/asyncpg-0.30.0-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:c47806b1a8cbb0a0db896f4cd34d89942effe353a5035c62734ab13b9f938da3", size = 634745, upload-time = "2024-10-20T00:29:57.14Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/8e/6d/a4f31bf358ce8491d2a31bfe0d7bcf25269e80481e49de4d8616c4295a34/asyncpg-0.30.0-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:9b6fde867a74e8c76c71e2f64f80c64c0f3163e687f1763cfaf21633ec24ec33", size = 3512103, upload-time = "2024-10-20T00:29:58.499Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/96/19/139227a6e67f407b9c386cb594d9628c6c78c9024f26df87c912fabd4368/asyncpg-0.30.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:46973045b567972128a27d40001124fbc821c87a6cade040cfcd4fa8a30bcdc4", size = 3592471, upload-time = "2024-10-20T00:30:00.354Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/67/e4/ab3ca38f628f53f0fd28d3ff20edff1c975dd1cb22482e0061916b4b9a74/asyncpg-0.30.0-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:9110df111cabc2ed81aad2f35394a00cadf4f2e0635603db6ebbd0fc896f46a4", size = 3496253, upload-time = "2024-10-20T00:30:02.794Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/ef/5f/0bf65511d4eeac3a1f41c54034a492515a707c6edbc642174ae79034d3ba/asyncpg-0.30.0-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:04ff0785ae7eed6cc138e73fc67b8e51d54ee7a3ce9b63666ce55a0bf095f7ba", size = 3662720, upload-time = "2024-10-20T00:30:04.501Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/e7/31/1513d5a6412b98052c3ed9158d783b1e09d0910f51fbe0e05f56cc370bc4/asyncpg-0.30.0-cp313-cp313-win32.whl", hash = "sha256:ae374585f51c2b444510cdf3595b97ece4f233fde739aa14b50e0d64e8a7a590", size = 560404, upload-time = "2024-10-20T00:30:06.537Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/c8/a4/cec76b3389c4c5ff66301cd100fe88c318563ec8a520e0b2e792b5b84972/asyncpg-0.30.0-cp313-cp313-win_amd64.whl", hash = "sha256:f59b430b8e27557c3fb9869222559f7417ced18688375825f8f12302c34e915e", size = 621623, upload-time = "2024-10-20T00:30:09.024Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "backend"
|
||||
version = "0.1.0"
|
||||
source = { virtual = "." }
|
||||
dependencies = [
|
||||
{ name = "asyncpg" },
|
||||
{ name = "fastapi" },
|
||||
{ name = "python-dotenv" },
|
||||
{ name = "sqlalchemy" },
|
||||
{ name = "uvicorn" },
|
||||
]
|
||||
|
||||
[package.metadata]
|
||||
requires-dist = [
|
||||
{ name = "asyncpg", specifier = ">=0.30.0" },
|
||||
{ name = "fastapi", specifier = ">=0.121.3" },
|
||||
{ name = "python-dotenv", specifier = ">=1.2.1" },
|
||||
{ name = "sqlalchemy", specifier = ">=2.0.44" },
|
||||
{ name = "uvicorn", specifier = ">=0.38.0" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "click"
|
||||
version = "8.3.1"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
dependencies = [
|
||||
{ name = "colorama", marker = "sys_platform == 'win32'" },
|
||||
]
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/3d/fa/656b739db8587d7b5dfa22e22ed02566950fbfbcdc20311993483657a5c0/click-8.3.1.tar.gz", hash = "sha256:12ff4785d337a1bb490bb7e9c2b1ee5da3112e94a8622f26a6c77f5d2fc6842a", size = 295065, upload-time = "2025-11-15T20:45:42.706Z" }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/98/78/01c019cdb5d6498122777c1a43056ebb3ebfeef2076d9d026bfe15583b2b/click-8.3.1-py3-none-any.whl", hash = "sha256:981153a64e25f12d547d3426c367a4857371575ee7ad18df2a6183ab0545b2a6", size = 108274, upload-time = "2025-11-15T20:45:41.139Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "colorama"
|
||||
version = "0.4.6"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/d8/53/6f443c9a4a8358a93a6792e2acffb9d9d5cb0a5cfd8802644b7b1c9a02e4/colorama-0.4.6.tar.gz", hash = "sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44", size = 27697, upload-time = "2022-10-25T02:36:22.414Z" }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/d1/d6/3965ed04c63042e047cb6a3e6ed1a63a35087b6a609aa3a15ed8ac56c221/colorama-0.4.6-py2.py3-none-any.whl", hash = "sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6", size = 25335, upload-time = "2022-10-25T02:36:20.889Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "fastapi"
|
||||
version = "0.121.3"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
dependencies = [
|
||||
{ name = "annotated-doc" },
|
||||
{ name = "pydantic" },
|
||||
{ name = "starlette" },
|
||||
{ name = "typing-extensions" },
|
||||
]
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/80/f0/086c442c6516195786131b8ca70488c6ef11d2f2e33c9a893576b2b0d3f7/fastapi-0.121.3.tar.gz", hash = "sha256:0055bc24fe53e56a40e9e0ad1ae2baa81622c406e548e501e717634e2dfbc40b", size = 344501, upload-time = "2025-11-19T16:53:39.243Z" }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/98/b6/4f620d7720fc0a754c8c1b7501d73777f6ba43b57c8ab99671f4d7441eb8/fastapi-0.121.3-py3-none-any.whl", hash = "sha256:0c78fc87587fcd910ca1bbf5bc8ba37b80e119b388a7206b39f0ecc95ebf53e9", size = 109801, upload-time = "2025-11-19T16:53:37.918Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "greenlet"
|
||||
version = "3.2.4"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/03/b8/704d753a5a45507a7aab61f18db9509302ed3d0a27ac7e0359ec2905b1a6/greenlet-3.2.4.tar.gz", hash = "sha256:0dca0d95ff849f9a364385f36ab49f50065d76964944638be9691e1832e9f86d", size = 188260, upload-time = "2025-08-07T13:24:33.51Z" }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/49/e8/58c7f85958bda41dafea50497cbd59738c5c43dbbea5ee83d651234398f4/greenlet-3.2.4-cp313-cp313-macosx_11_0_universal2.whl", hash = "sha256:1a921e542453fe531144e91e1feedf12e07351b1cf6c9e8a3325ea600a715a31", size = 272814, upload-time = "2025-08-07T13:15:50.011Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/62/dd/b9f59862e9e257a16e4e610480cfffd29e3fae018a68c2332090b53aac3d/greenlet-3.2.4-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:cd3c8e693bff0fff6ba55f140bf390fa92c994083f838fece0f63be121334945", size = 641073, upload-time = "2025-08-07T13:42:57.23Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/f7/0b/bc13f787394920b23073ca3b6c4a7a21396301ed75a655bcb47196b50e6e/greenlet-3.2.4-cp313-cp313-manylinux2014_ppc64le.manylinux_2_17_ppc64le.whl", hash = "sha256:710638eb93b1fa52823aa91bf75326f9ecdfd5e0466f00789246a5280f4ba0fc", size = 655191, upload-time = "2025-08-07T13:45:29.752Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/f2/d6/6adde57d1345a8d0f14d31e4ab9c23cfe8e2cd39c3baf7674b4b0338d266/greenlet-3.2.4-cp313-cp313-manylinux2014_s390x.manylinux_2_17_s390x.whl", hash = "sha256:c5111ccdc9c88f423426df3fd1811bfc40ed66264d35aa373420a34377efc98a", size = 649516, upload-time = "2025-08-07T13:53:16.314Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/7f/3b/3a3328a788d4a473889a2d403199932be55b1b0060f4ddd96ee7cdfcad10/greenlet-3.2.4-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:d76383238584e9711e20ebe14db6c88ddcedc1829a9ad31a584389463b5aa504", size = 652169, upload-time = "2025-08-07T13:18:32.861Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/ee/43/3cecdc0349359e1a527cbf2e3e28e5f8f06d3343aaf82ca13437a9aa290f/greenlet-3.2.4-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:23768528f2911bcd7e475210822ffb5254ed10d71f4028387e5a99b4c6699671", size = 610497, upload-time = "2025-08-07T13:18:31.636Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/b8/19/06b6cf5d604e2c382a6f31cafafd6f33d5dea706f4db7bdab184bad2b21d/greenlet-3.2.4-cp313-cp313-musllinux_1_1_aarch64.whl", hash = "sha256:00fadb3fedccc447f517ee0d3fd8fe49eae949e1cd0f6a611818f4f6fb7dc83b", size = 1121662, upload-time = "2025-08-07T13:42:41.117Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/a2/15/0d5e4e1a66fab130d98168fe984c509249c833c1a3c16806b90f253ce7b9/greenlet-3.2.4-cp313-cp313-musllinux_1_1_x86_64.whl", hash = "sha256:d25c5091190f2dc0eaa3f950252122edbbadbb682aa7b1ef2f8af0f8c0afefae", size = 1149210, upload-time = "2025-08-07T13:18:24.072Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/1c/53/f9c440463b3057485b8594d7a638bed53ba531165ef0ca0e6c364b5cc807/greenlet-3.2.4-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:6e343822feb58ac4d0a1211bd9399de2b3a04963ddeec21530fc426cc121f19b", size = 1564759, upload-time = "2025-11-04T12:42:19.395Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/47/e4/3bb4240abdd0a8d23f4f88adec746a3099f0d86bfedb623f063b2e3b4df0/greenlet-3.2.4-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:ca7f6f1f2649b89ce02f6f229d7c19f680a6238af656f61e0115b24857917929", size = 1634288, upload-time = "2025-11-04T12:42:21.174Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/0b/55/2321e43595e6801e105fcfdee02b34c0f996eb71e6ddffca6b10b7e1d771/greenlet-3.2.4-cp313-cp313-win_amd64.whl", hash = "sha256:554b03b6e73aaabec3745364d6239e9e012d64c68ccd0b8430c64ccc14939a8b", size = 299685, upload-time = "2025-08-07T13:24:38.824Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/22/5c/85273fd7cc388285632b0498dbbab97596e04b154933dfe0f3e68156c68c/greenlet-3.2.4-cp314-cp314-macosx_11_0_universal2.whl", hash = "sha256:49a30d5fda2507ae77be16479bdb62a660fa51b1eb4928b524975b3bde77b3c0", size = 273586, upload-time = "2025-08-07T13:16:08.004Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/d1/75/10aeeaa3da9332c2e761e4c50d4c3556c21113ee3f0afa2cf5769946f7a3/greenlet-3.2.4-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:299fd615cd8fc86267b47597123e3f43ad79c9d8a22bebdce535e53550763e2f", size = 686346, upload-time = "2025-08-07T13:42:59.944Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/c0/aa/687d6b12ffb505a4447567d1f3abea23bd20e73a5bed63871178e0831b7a/greenlet-3.2.4-cp314-cp314-manylinux2014_ppc64le.manylinux_2_17_ppc64le.whl", hash = "sha256:c17b6b34111ea72fc5a4e4beec9711d2226285f0386ea83477cbb97c30a3f3a5", size = 699218, upload-time = "2025-08-07T13:45:30.969Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/dc/8b/29aae55436521f1d6f8ff4e12fb676f3400de7fcf27fccd1d4d17fd8fecd/greenlet-3.2.4-cp314-cp314-manylinux2014_s390x.manylinux_2_17_s390x.whl", hash = "sha256:b4a1870c51720687af7fa3e7cda6d08d801dae660f75a76f3845b642b4da6ee1", size = 694659, upload-time = "2025-08-07T13:53:17.759Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/92/2e/ea25914b1ebfde93b6fc4ff46d6864564fba59024e928bdc7de475affc25/greenlet-3.2.4-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:061dc4cf2c34852b052a8620d40f36324554bc192be474b9e9770e8c042fd735", size = 695355, upload-time = "2025-08-07T13:18:34.517Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/72/60/fc56c62046ec17f6b0d3060564562c64c862948c9d4bc8aa807cf5bd74f4/greenlet-3.2.4-cp314-cp314-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:44358b9bf66c8576a9f57a590d5f5d6e72fa4228b763d0e43fee6d3b06d3a337", size = 657512, upload-time = "2025-08-07T13:18:33.969Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/23/6e/74407aed965a4ab6ddd93a7ded3180b730d281c77b765788419484cdfeef/greenlet-3.2.4-cp314-cp314-musllinux_1_2_aarch64.whl", hash = "sha256:2917bdf657f5859fbf3386b12d68ede4cf1f04c90c3a6bc1f013dd68a22e2269", size = 1612508, upload-time = "2025-11-04T12:42:23.427Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/0d/da/343cd760ab2f92bac1845ca07ee3faea9fe52bee65f7bcb19f16ad7de08b/greenlet-3.2.4-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:015d48959d4add5d6c9f6c5210ee3803a830dce46356e3bc326d6776bde54681", size = 1680760, upload-time = "2025-11-04T12:42:25.341Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/e3/a5/6ddab2b4c112be95601c13428db1d8b6608a8b6039816f2ba09c346c08fc/greenlet-3.2.4-cp314-cp314-win_amd64.whl", hash = "sha256:e37ab26028f12dbb0ff65f29a8d3d44a765c61e729647bf2ddfbbed621726f01", size = 303425, upload-time = "2025-08-07T13:32:27.59Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "h11"
|
||||
version = "0.16.0"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/01/ee/02a2c011bdab74c6fb3c75474d40b3052059d95df7e73351460c8588d963/h11-0.16.0.tar.gz", hash = "sha256:4e35b956cf45792e4caa5885e69fba00bdbc6ffafbfa020300e549b208ee5ff1", size = 101250, upload-time = "2025-04-24T03:35:25.427Z" }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/04/4b/29cac41a4d98d144bf5f6d33995617b185d14b22401f75ca86f384e87ff1/h11-0.16.0-py3-none-any.whl", hash = "sha256:63cf8bbe7522de3bf65932fda1d9c2772064ffb3dae62d55932da54b31cb6c86", size = 37515, upload-time = "2025-04-24T03:35:24.344Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "idna"
|
||||
version = "3.11"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/6f/6d/0703ccc57f3a7233505399edb88de3cbd678da106337b9fcde432b65ed60/idna-3.11.tar.gz", hash = "sha256:795dafcc9c04ed0c1fb032c2aa73654d8e8c5023a7df64a53f39190ada629902", size = 194582, upload-time = "2025-10-12T14:55:20.501Z" }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/0e/61/66938bbb5fc52dbdf84594873d5b51fb1f7c7794e9c0f5bd885f30bc507b/idna-3.11-py3-none-any.whl", hash = "sha256:771a87f49d9defaf64091e6e6fe9c18d4833f140bd19464795bc32d966ca37ea", size = 71008, upload-time = "2025-10-12T14:55:18.883Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pydantic"
|
||||
version = "2.12.4"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
dependencies = [
|
||||
{ name = "annotated-types" },
|
||||
{ name = "pydantic-core" },
|
||||
{ name = "typing-extensions" },
|
||||
{ name = "typing-inspection" },
|
||||
]
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/96/ad/a17bc283d7d81837c061c49e3eaa27a45991759a1b7eae1031921c6bd924/pydantic-2.12.4.tar.gz", hash = "sha256:0f8cb9555000a4b5b617f66bfd2566264c4984b27589d3b845685983e8ea85ac", size = 821038, upload-time = "2025-11-05T10:50:08.59Z" }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/82/2f/e68750da9b04856e2a7ec56fc6f034a5a79775e9b9a81882252789873798/pydantic-2.12.4-py3-none-any.whl", hash = "sha256:92d3d202a745d46f9be6df459ac5a064fdaa3c1c4cd8adcfa332ccf3c05f871e", size = 463400, upload-time = "2025-11-05T10:50:06.732Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pydantic-core"
|
||||
version = "2.41.5"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
dependencies = [
|
||||
{ name = "typing-extensions" },
|
||||
]
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/71/70/23b021c950c2addd24ec408e9ab05d59b035b39d97cdc1130e1bce647bb6/pydantic_core-2.41.5.tar.gz", hash = "sha256:08daa51ea16ad373ffd5e7606252cc32f07bc72b28284b6bc9c6df804816476e", size = 460952, upload-time = "2025-11-04T13:43:49.098Z" }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/87/06/8806241ff1f70d9939f9af039c6c35f2360cf16e93c2ca76f184e76b1564/pydantic_core-2.41.5-cp313-cp313-macosx_10_12_x86_64.whl", hash = "sha256:941103c9be18ac8daf7b7adca8228f8ed6bb7a1849020f643b3a14d15b1924d9", size = 2120403, upload-time = "2025-11-04T13:40:25.248Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/94/02/abfa0e0bda67faa65fef1c84971c7e45928e108fe24333c81f3bfe35d5f5/pydantic_core-2.41.5-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:112e305c3314f40c93998e567879e887a3160bb8689ef3d2c04b6cc62c33ac34", size = 1896206, upload-time = "2025-11-04T13:40:27.099Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/15/df/a4c740c0943e93e6500f9eb23f4ca7ec9bf71b19e608ae5b579678c8d02f/pydantic_core-2.41.5-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:0cbaad15cb0c90aa221d43c00e77bb33c93e8d36e0bf74760cd00e732d10a6a0", size = 1919307, upload-time = "2025-11-04T13:40:29.806Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/9a/e3/6324802931ae1d123528988e0e86587c2072ac2e5394b4bc2bc34b61ff6e/pydantic_core-2.41.5-cp313-cp313-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:03ca43e12fab6023fc79d28ca6b39b05f794ad08ec2feccc59a339b02f2b3d33", size = 2063258, upload-time = "2025-11-04T13:40:33.544Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/c9/d4/2230d7151d4957dd79c3044ea26346c148c98fbf0ee6ebd41056f2d62ab5/pydantic_core-2.41.5-cp313-cp313-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:dc799088c08fa04e43144b164feb0c13f9a0bc40503f8df3e9fde58a3c0c101e", size = 2214917, upload-time = "2025-11-04T13:40:35.479Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/e6/9f/eaac5df17a3672fef0081b6c1bb0b82b33ee89aa5cec0d7b05f52fd4a1fa/pydantic_core-2.41.5-cp313-cp313-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:97aeba56665b4c3235a0e52b2c2f5ae9cd071b8a8310ad27bddb3f7fb30e9aa2", size = 2332186, upload-time = "2025-11-04T13:40:37.436Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/cf/4e/35a80cae583a37cf15604b44240e45c05e04e86f9cfd766623149297e971/pydantic_core-2.41.5-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:406bf18d345822d6c21366031003612b9c77b3e29ffdb0f612367352aab7d586", size = 2073164, upload-time = "2025-11-04T13:40:40.289Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/bf/e3/f6e262673c6140dd3305d144d032f7bd5f7497d3871c1428521f19f9efa2/pydantic_core-2.41.5-cp313-cp313-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:b93590ae81f7010dbe380cdeab6f515902ebcbefe0b9327cc4804d74e93ae69d", size = 2179146, upload-time = "2025-11-04T13:40:42.809Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/75/c7/20bd7fc05f0c6ea2056a4565c6f36f8968c0924f19b7d97bbfea55780e73/pydantic_core-2.41.5-cp313-cp313-musllinux_1_1_aarch64.whl", hash = "sha256:01a3d0ab748ee531f4ea6c3e48ad9dac84ddba4b0d82291f87248f2f9de8d740", size = 2137788, upload-time = "2025-11-04T13:40:44.752Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/3a/8d/34318ef985c45196e004bc46c6eab2eda437e744c124ef0dbe1ff2c9d06b/pydantic_core-2.41.5-cp313-cp313-musllinux_1_1_armv7l.whl", hash = "sha256:6561e94ba9dacc9c61bce40e2d6bdc3bfaa0259d3ff36ace3b1e6901936d2e3e", size = 2340133, upload-time = "2025-11-04T13:40:46.66Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/9c/59/013626bf8c78a5a5d9350d12e7697d3d4de951a75565496abd40ccd46bee/pydantic_core-2.41.5-cp313-cp313-musllinux_1_1_x86_64.whl", hash = "sha256:915c3d10f81bec3a74fbd4faebe8391013ba61e5a1a8d48c4455b923bdda7858", size = 2324852, upload-time = "2025-11-04T13:40:48.575Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/1a/d9/c248c103856f807ef70c18a4f986693a46a8ffe1602e5d361485da502d20/pydantic_core-2.41.5-cp313-cp313-win32.whl", hash = "sha256:650ae77860b45cfa6e2cdafc42618ceafab3a2d9a3811fcfbd3bbf8ac3c40d36", size = 1994679, upload-time = "2025-11-04T13:40:50.619Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/9e/8b/341991b158ddab181cff136acd2552c9f35bd30380422a639c0671e99a91/pydantic_core-2.41.5-cp313-cp313-win_amd64.whl", hash = "sha256:79ec52ec461e99e13791ec6508c722742ad745571f234ea6255bed38c6480f11", size = 2019766, upload-time = "2025-11-04T13:40:52.631Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/73/7d/f2f9db34af103bea3e09735bb40b021788a5e834c81eedb541991badf8f5/pydantic_core-2.41.5-cp313-cp313-win_arm64.whl", hash = "sha256:3f84d5c1b4ab906093bdc1ff10484838aca54ef08de4afa9de0f5f14d69639cd", size = 1981005, upload-time = "2025-11-04T13:40:54.734Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/ea/28/46b7c5c9635ae96ea0fbb779e271a38129df2550f763937659ee6c5dbc65/pydantic_core-2.41.5-cp314-cp314-macosx_10_12_x86_64.whl", hash = "sha256:3f37a19d7ebcdd20b96485056ba9e8b304e27d9904d233d7b1015db320e51f0a", size = 2119622, upload-time = "2025-11-04T13:40:56.68Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/74/1a/145646e5687e8d9a1e8d09acb278c8535ebe9e972e1f162ed338a622f193/pydantic_core-2.41.5-cp314-cp314-macosx_11_0_arm64.whl", hash = "sha256:1d1d9764366c73f996edd17abb6d9d7649a7eb690006ab6adbda117717099b14", size = 1891725, upload-time = "2025-11-04T13:40:58.807Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/23/04/e89c29e267b8060b40dca97bfc64a19b2a3cf99018167ea1677d96368273/pydantic_core-2.41.5-cp314-cp314-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:25e1c2af0fce638d5f1988b686f3b3ea8cd7de5f244ca147c777769e798a9cd1", size = 1915040, upload-time = "2025-11-04T13:41:00.853Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/84/a3/15a82ac7bd97992a82257f777b3583d3e84bdb06ba6858f745daa2ec8a85/pydantic_core-2.41.5-cp314-cp314-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:506d766a8727beef16b7adaeb8ee6217c64fc813646b424d0804d67c16eddb66", size = 2063691, upload-time = "2025-11-04T13:41:03.504Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/74/9b/0046701313c6ef08c0c1cf0e028c67c770a4e1275ca73131563c5f2a310a/pydantic_core-2.41.5-cp314-cp314-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:4819fa52133c9aa3c387b3328f25c1facc356491e6135b459f1de698ff64d869", size = 2213897, upload-time = "2025-11-04T13:41:05.804Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/8a/cd/6bac76ecd1b27e75a95ca3a9a559c643b3afcd2dd62086d4b7a32a18b169/pydantic_core-2.41.5-cp314-cp314-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:2b761d210c9ea91feda40d25b4efe82a1707da2ef62901466a42492c028553a2", size = 2333302, upload-time = "2025-11-04T13:41:07.809Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/4c/d2/ef2074dc020dd6e109611a8be4449b98cd25e1b9b8a303c2f0fca2f2bcf7/pydantic_core-2.41.5-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:22f0fb8c1c583a3b6f24df2470833b40207e907b90c928cc8d3594b76f874375", size = 2064877, upload-time = "2025-11-04T13:41:09.827Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/18/66/e9db17a9a763d72f03de903883c057b2592c09509ccfe468187f2a2eef29/pydantic_core-2.41.5-cp314-cp314-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:2782c870e99878c634505236d81e5443092fba820f0373997ff75f90f68cd553", size = 2180680, upload-time = "2025-11-04T13:41:12.379Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/d3/9e/3ce66cebb929f3ced22be85d4c2399b8e85b622db77dad36b73c5387f8f8/pydantic_core-2.41.5-cp314-cp314-musllinux_1_1_aarch64.whl", hash = "sha256:0177272f88ab8312479336e1d777f6b124537d47f2123f89cb37e0accea97f90", size = 2138960, upload-time = "2025-11-04T13:41:14.627Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/a6/62/205a998f4327d2079326b01abee48e502ea739d174f0a89295c481a2272e/pydantic_core-2.41.5-cp314-cp314-musllinux_1_1_armv7l.whl", hash = "sha256:63510af5e38f8955b8ee5687740d6ebf7c2a0886d15a6d65c32814613681bc07", size = 2339102, upload-time = "2025-11-04T13:41:16.868Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/3c/0d/f05e79471e889d74d3d88f5bd20d0ed189ad94c2423d81ff8d0000aab4ff/pydantic_core-2.41.5-cp314-cp314-musllinux_1_1_x86_64.whl", hash = "sha256:e56ba91f47764cc14f1daacd723e3e82d1a89d783f0f5afe9c364b8bb491ccdb", size = 2326039, upload-time = "2025-11-04T13:41:18.934Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/ec/e1/e08a6208bb100da7e0c4b288eed624a703f4d129bde2da475721a80cab32/pydantic_core-2.41.5-cp314-cp314-win32.whl", hash = "sha256:aec5cf2fd867b4ff45b9959f8b20ea3993fc93e63c7363fe6851424c8a7e7c23", size = 1995126, upload-time = "2025-11-04T13:41:21.418Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/48/5d/56ba7b24e9557f99c9237e29f5c09913c81eeb2f3217e40e922353668092/pydantic_core-2.41.5-cp314-cp314-win_amd64.whl", hash = "sha256:8e7c86f27c585ef37c35e56a96363ab8de4e549a95512445b85c96d3e2f7c1bf", size = 2015489, upload-time = "2025-11-04T13:41:24.076Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/4e/bb/f7a190991ec9e3e0ba22e4993d8755bbc4a32925c0b5b42775c03e8148f9/pydantic_core-2.41.5-cp314-cp314-win_arm64.whl", hash = "sha256:e672ba74fbc2dc8eea59fb6d4aed6845e6905fc2a8afe93175d94a83ba2a01a0", size = 1977288, upload-time = "2025-11-04T13:41:26.33Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/92/ed/77542d0c51538e32e15afe7899d79efce4b81eee631d99850edc2f5e9349/pydantic_core-2.41.5-cp314-cp314t-macosx_10_12_x86_64.whl", hash = "sha256:8566def80554c3faa0e65ac30ab0932b9e3a5cd7f8323764303d468e5c37595a", size = 2120255, upload-time = "2025-11-04T13:41:28.569Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/bb/3d/6913dde84d5be21e284439676168b28d8bbba5600d838b9dca99de0fad71/pydantic_core-2.41.5-cp314-cp314t-macosx_11_0_arm64.whl", hash = "sha256:b80aa5095cd3109962a298ce14110ae16b8c1aece8b72f9dafe81cf597ad80b3", size = 1863760, upload-time = "2025-11-04T13:41:31.055Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/5a/f0/e5e6b99d4191da102f2b0eb9687aaa7f5bea5d9964071a84effc3e40f997/pydantic_core-2.41.5-cp314-cp314t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:3006c3dd9ba34b0c094c544c6006cc79e87d8612999f1a5d43b769b89181f23c", size = 1878092, upload-time = "2025-11-04T13:41:33.21Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/71/48/36fb760642d568925953bcc8116455513d6e34c4beaa37544118c36aba6d/pydantic_core-2.41.5-cp314-cp314t-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:72f6c8b11857a856bcfa48c86f5368439f74453563f951e473514579d44aa612", size = 2053385, upload-time = "2025-11-04T13:41:35.508Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/20/25/92dc684dd8eb75a234bc1c764b4210cf2646479d54b47bf46061657292a8/pydantic_core-2.41.5-cp314-cp314t-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:5cb1b2f9742240e4bb26b652a5aeb840aa4b417c7748b6f8387927bc6e45e40d", size = 2218832, upload-time = "2025-11-04T13:41:37.732Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/e2/09/f53e0b05023d3e30357d82eb35835d0f6340ca344720a4599cd663dca599/pydantic_core-2.41.5-cp314-cp314t-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:bd3d54f38609ff308209bd43acea66061494157703364ae40c951f83ba99a1a9", size = 2327585, upload-time = "2025-11-04T13:41:40Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/aa/4e/2ae1aa85d6af35a39b236b1b1641de73f5a6ac4d5a7509f77b814885760c/pydantic_core-2.41.5-cp314-cp314t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:2ff4321e56e879ee8d2a879501c8e469414d948f4aba74a2d4593184eb326660", size = 2041078, upload-time = "2025-11-04T13:41:42.323Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/cd/13/2e215f17f0ef326fc72afe94776edb77525142c693767fc347ed6288728d/pydantic_core-2.41.5-cp314-cp314t-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:d0d2568a8c11bf8225044aa94409e21da0cb09dcdafe9ecd10250b2baad531a9", size = 2173914, upload-time = "2025-11-04T13:41:45.221Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/02/7a/f999a6dcbcd0e5660bc348a3991c8915ce6599f4f2c6ac22f01d7a10816c/pydantic_core-2.41.5-cp314-cp314t-musllinux_1_1_aarch64.whl", hash = "sha256:a39455728aabd58ceabb03c90e12f71fd30fa69615760a075b9fec596456ccc3", size = 2129560, upload-time = "2025-11-04T13:41:47.474Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/3a/b1/6c990ac65e3b4c079a4fb9f5b05f5b013afa0f4ed6780a3dd236d2cbdc64/pydantic_core-2.41.5-cp314-cp314t-musllinux_1_1_armv7l.whl", hash = "sha256:239edca560d05757817c13dc17c50766136d21f7cd0fac50295499ae24f90fdf", size = 2329244, upload-time = "2025-11-04T13:41:49.992Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/d9/02/3c562f3a51afd4d88fff8dffb1771b30cfdfd79befd9883ee094f5b6c0d8/pydantic_core-2.41.5-cp314-cp314t-musllinux_1_1_x86_64.whl", hash = "sha256:2a5e06546e19f24c6a96a129142a75cee553cc018ffee48a460059b1185f4470", size = 2331955, upload-time = "2025-11-04T13:41:54.079Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/5c/96/5fb7d8c3c17bc8c62fdb031c47d77a1af698f1d7a406b0f79aaa1338f9ad/pydantic_core-2.41.5-cp314-cp314t-win32.whl", hash = "sha256:b4ececa40ac28afa90871c2cc2b9ffd2ff0bf749380fbdf57d165fd23da353aa", size = 1988906, upload-time = "2025-11-04T13:41:56.606Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/22/ed/182129d83032702912c2e2d8bbe33c036f342cc735737064668585dac28f/pydantic_core-2.41.5-cp314-cp314t-win_amd64.whl", hash = "sha256:80aa89cad80b32a912a65332f64a4450ed00966111b6615ca6816153d3585a8c", size = 1981607, upload-time = "2025-11-04T13:41:58.889Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/9f/ed/068e41660b832bb0b1aa5b58011dea2a3fe0ba7861ff38c4d4904c1c1a99/pydantic_core-2.41.5-cp314-cp314t-win_arm64.whl", hash = "sha256:35b44f37a3199f771c3eaa53051bc8a70cd7b54f333531c59e29fd4db5d15008", size = 1974769, upload-time = "2025-11-04T13:42:01.186Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "python-dotenv"
|
||||
version = "1.2.1"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/f0/26/19cadc79a718c5edbec86fd4919a6b6d3f681039a2f6d66d14be94e75fb9/python_dotenv-1.2.1.tar.gz", hash = "sha256:42667e897e16ab0d66954af0e60a9caa94f0fd4ecf3aaf6d2d260eec1aa36ad6", size = 44221, upload-time = "2025-10-26T15:12:10.434Z" }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/14/1b/a298b06749107c305e1fe0f814c6c74aea7b2f1e10989cb30f544a1b3253/python_dotenv-1.2.1-py3-none-any.whl", hash = "sha256:b81ee9561e9ca4004139c6cbba3a238c32b03e4894671e181b671e8cb8425d61", size = 21230, upload-time = "2025-10-26T15:12:09.109Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sniffio"
|
||||
version = "1.3.1"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/a2/87/a6771e1546d97e7e041b6ae58d80074f81b7d5121207425c964ddf5cfdbd/sniffio-1.3.1.tar.gz", hash = "sha256:f4324edc670a0f49750a81b895f35c3adb843cca46f0530f79fc1babb23789dc", size = 20372, upload-time = "2024-02-25T23:20:04.057Z" }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/e9/44/75a9c9421471a6c4805dbf2356f7c181a29c1879239abab1ea2cc8f38b40/sniffio-1.3.1-py3-none-any.whl", hash = "sha256:2f6da418d1f1e0fddd844478f41680e794e6051915791a034ff65e5f100525a2", size = 10235, upload-time = "2024-02-25T23:20:01.196Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sqlalchemy"
|
||||
version = "2.0.44"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
dependencies = [
|
||||
{ name = "greenlet", marker = "platform_machine == 'AMD64' or platform_machine == 'WIN32' or platform_machine == 'aarch64' or platform_machine == 'amd64' or platform_machine == 'ppc64le' or platform_machine == 'win32' or platform_machine == 'x86_64'" },
|
||||
{ name = "typing-extensions" },
|
||||
]
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/f0/f2/840d7b9496825333f532d2e3976b8eadbf52034178aac53630d09fe6e1ef/sqlalchemy-2.0.44.tar.gz", hash = "sha256:0ae7454e1ab1d780aee69fd2aae7d6b8670a581d8847f2d1e0f7ddfbf47e5a22", size = 9819830, upload-time = "2025-10-10T14:39:12.935Z" }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/45/d3/c67077a2249fdb455246e6853166360054c331db4613cda3e31ab1cadbef/sqlalchemy-2.0.44-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:ff486e183d151e51b1d694c7aa1695747599bb00b9f5f604092b54b74c64a8e1", size = 2135479, upload-time = "2025-10-10T16:03:37.671Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/2b/91/eabd0688330d6fd114f5f12c4f89b0d02929f525e6bf7ff80aa17ca802af/sqlalchemy-2.0.44-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:0b1af8392eb27b372ddb783b317dea0f650241cea5bd29199b22235299ca2e45", size = 2123212, upload-time = "2025-10-10T16:03:41.755Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/b0/bb/43e246cfe0e81c018076a16036d9b548c4cc649de241fa27d8d9ca6f85ab/sqlalchemy-2.0.44-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:2b61188657e3a2b9ac4e8f04d6cf8e51046e28175f79464c67f2fd35bceb0976", size = 3255353, upload-time = "2025-10-10T15:35:31.221Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/b9/96/c6105ed9a880abe346b64d3b6ddef269ddfcab04f7f3d90a0bf3c5a88e82/sqlalchemy-2.0.44-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:b87e7b91a5d5973dda5f00cd61ef72ad75a1db73a386b62877d4875a8840959c", size = 3260222, upload-time = "2025-10-10T15:43:50.124Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/44/16/1857e35a47155b5ad927272fee81ae49d398959cb749edca6eaa399b582f/sqlalchemy-2.0.44-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:15f3326f7f0b2bfe406ee562e17f43f36e16167af99c4c0df61db668de20002d", size = 3189614, upload-time = "2025-10-10T15:35:32.578Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/88/ee/4afb39a8ee4fc786e2d716c20ab87b5b1fb33d4ac4129a1aaa574ae8a585/sqlalchemy-2.0.44-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:1e77faf6ff919aa8cd63f1c4e561cac1d9a454a191bb864d5dd5e545935e5a40", size = 3226248, upload-time = "2025-10-10T15:43:51.862Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/32/d5/0e66097fc64fa266f29a7963296b40a80d6a997b7ac13806183700676f86/sqlalchemy-2.0.44-cp313-cp313-win32.whl", hash = "sha256:ee51625c2d51f8baadf2829fae817ad0b66b140573939dd69284d2ba3553ae73", size = 2101275, upload-time = "2025-10-10T15:03:26.096Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/03/51/665617fe4f8c6450f42a6d8d69243f9420f5677395572c2fe9d21b493b7b/sqlalchemy-2.0.44-cp313-cp313-win_amd64.whl", hash = "sha256:c1c80faaee1a6c3428cecf40d16a2365bcf56c424c92c2b6f0f9ad204b899e9e", size = 2127901, upload-time = "2025-10-10T15:03:27.548Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/9c/5e/6a29fa884d9fb7ddadf6b69490a9d45fded3b38541713010dad16b77d015/sqlalchemy-2.0.44-py3-none-any.whl", hash = "sha256:19de7ca1246fbef9f9d1bff8f1ab25641569df226364a0e40457dc5457c54b05", size = 1928718, upload-time = "2025-10-10T15:29:45.32Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "starlette"
|
||||
version = "0.50.0"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
dependencies = [
|
||||
{ name = "anyio" },
|
||||
]
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/ba/b8/73a0e6a6e079a9d9cfa64113d771e421640b6f679a52eeb9b32f72d871a1/starlette-0.50.0.tar.gz", hash = "sha256:a2a17b22203254bcbc2e1f926d2d55f3f9497f769416b3190768befe598fa3ca", size = 2646985, upload-time = "2025-11-01T15:25:27.516Z" }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/d9/52/1064f510b141bd54025f9b55105e26d1fa970b9be67ad766380a3c9b74b0/starlette-0.50.0-py3-none-any.whl", hash = "sha256:9e5391843ec9b6e472eed1365a78c8098cfceb7a74bfd4d6b1c0c0095efb3bca", size = 74033, upload-time = "2025-11-01T15:25:25.461Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "typing-extensions"
|
||||
version = "4.15.0"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/72/94/1a15dd82efb362ac84269196e94cf00f187f7ed21c242792a923cdb1c61f/typing_extensions-4.15.0.tar.gz", hash = "sha256:0cea48d173cc12fa28ecabc3b837ea3cf6f38c6d1136f85cbaaf598984861466", size = 109391, upload-time = "2025-08-25T13:49:26.313Z" }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/18/67/36e9267722cc04a6b9f15c7f3441c2363321a3ea07da7ae0c0707beb2a9c/typing_extensions-4.15.0-py3-none-any.whl", hash = "sha256:f0fa19c6845758ab08074a0cfa8b7aecb71c999ca73d62883bc25cc018c4e548", size = 44614, upload-time = "2025-08-25T13:49:24.86Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "typing-inspection"
|
||||
version = "0.4.2"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
dependencies = [
|
||||
{ name = "typing-extensions" },
|
||||
]
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/55/e3/70399cb7dd41c10ac53367ae42139cf4b1ca5f36bb3dc6c9d33acdb43655/typing_inspection-0.4.2.tar.gz", hash = "sha256:ba561c48a67c5958007083d386c3295464928b01faa735ab8547c5692e87f464", size = 75949, upload-time = "2025-10-01T02:14:41.687Z" }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/dc/9b/47798a6c91d8bdb567fe2698fe81e0c6b7cb7ef4d13da4114b41d239f65d/typing_inspection-0.4.2-py3-none-any.whl", hash = "sha256:4ed1cacbdc298c220f1bd249ed5287caa16f34d44ef4e9c3d0cbad5b521545e7", size = 14611, upload-time = "2025-10-01T02:14:40.154Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "uvicorn"
|
||||
version = "0.38.0"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
dependencies = [
|
||||
{ name = "click" },
|
||||
{ name = "h11" },
|
||||
]
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/cb/ce/f06b84e2697fef4688ca63bdb2fdf113ca0a3be33f94488f2cadb690b0cf/uvicorn-0.38.0.tar.gz", hash = "sha256:fd97093bdd120a2609fc0d3afe931d4d4ad688b6e75f0f929fde1bc36fe0e91d", size = 80605, upload-time = "2025-10-18T13:46:44.63Z" }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/ee/d9/d88e73ca598f4f6ff671fb5fde8a32925c2e08a637303a1d12883c7305fa/uvicorn-0.38.0-py3-none-any.whl", hash = "sha256:48c0afd214ceb59340075b4a052ea1ee91c16fbc2a9b1469cca0e54566977b02", size = 68109, upload-time = "2025-10-18T13:46:42.958Z" },
|
||||
]
|
||||
4
frontend/.dockerignore
Normal file
4
frontend/.dockerignore
Normal file
@@ -0,0 +1,4 @@
|
||||
Makefile
|
||||
dist
|
||||
node_modules
|
||||
|
||||
8
frontend/Makefile
Normal file
8
frontend/Makefile
Normal file
@@ -0,0 +1,8 @@
|
||||
.PHONY: build dev
|
||||
|
||||
|
||||
build:
|
||||
npm run build
|
||||
|
||||
dev:
|
||||
npm run dev
|
||||
@@ -2,11 +2,115 @@
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
||||
<link rel="icon" type="image/png" href="/favicon.png" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta
|
||||
name="title"
|
||||
content="d3m0k1d - DevOps Engineer & InfoSec Student | Go Backend Developer"
|
||||
/>
|
||||
<meta
|
||||
name="keywords"
|
||||
content="DevOps, InfoSec, Backend Developer, Go, Linux, Security, Portfolio, Programming, Personal Website, Personal blog, DSTU, Don State Technical Unversity, Unix"
|
||||
/>
|
||||
<script type="application/ld+json">
|
||||
{
|
||||
"@context": "https://schema.org",
|
||||
"@type": "Person",
|
||||
"name": "d3m0k1d",
|
||||
"url": "https://d3m0k1d.ru",
|
||||
"jobTitle": "DevOps Engineer",
|
||||
"description": "DevOps Engineer, InfoSec student at DSTU, and Go backend developer",
|
||||
"alumniOf": {
|
||||
"@type": "EducationalOrganization",
|
||||
"name": "Don State Technical University"
|
||||
},
|
||||
"knowsAbout": [
|
||||
"DevOps",
|
||||
"Information Security",
|
||||
"Backend Development",
|
||||
"Go",
|
||||
"Linux",
|
||||
"Infrastructure Automation"
|
||||
],
|
||||
"sameAs": ["https://github.com/d3m0k1d"]
|
||||
}
|
||||
</script>
|
||||
<link rel="canonical" href="https://d3m0k1d.ru" />
|
||||
<link rel="icon" type="image/svg+xml" href="/favicon.png" />
|
||||
<meta name="author" content="d3m0k1d" />
|
||||
<meta name="robots" content="index, follow" />
|
||||
<title>d3m0k1d - DevOps Engineer & InfoSec Student</title>
|
||||
|
||||
<style>
|
||||
#initial-loader {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
background: #000;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
z-index: 9999;
|
||||
font-family: monospace;
|
||||
}
|
||||
|
||||
#initial-loader .spinner {
|
||||
width: 48px;
|
||||
height: 48px;
|
||||
border: 3px solid rgba(255, 255, 255, 0.1);
|
||||
border-top-color: hsl(270, 73%, 63%);
|
||||
border-radius: 50%;
|
||||
animation: spin 1s linear infinite;
|
||||
}
|
||||
|
||||
#initial-loader .text {
|
||||
margin-top: 16px;
|
||||
color: #666;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
#initial-loader .cursor {
|
||||
color: hsl(270, 73%, 63%);
|
||||
animation: blink 1s infinite;
|
||||
}
|
||||
|
||||
@keyframes spin {
|
||||
to {
|
||||
transform: rotate(360deg);
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes blink {
|
||||
0%,
|
||||
50% {
|
||||
opacity: 1;
|
||||
}
|
||||
51%,
|
||||
100% {
|
||||
opacity: 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* Скрываем loader когда React готов */
|
||||
body.loaded #initial-loader {
|
||||
opacity: 0;
|
||||
pointer-events: none;
|
||||
transition: opacity 0.3s ease-out;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<!-- Initial loader -->
|
||||
<div id="initial-loader">
|
||||
<div class="spinner"></div>
|
||||
<div class="text">
|
||||
<span class="cursor">$</span> loading<span class="cursor"
|
||||
>_</span
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="root"></div>
|
||||
<script type="module" src="/src/main.tsx"></script>
|
||||
</body>
|
||||
|
||||
@@ -8,8 +8,19 @@ server {
|
||||
location / {
|
||||
try_files $uri $uri/ /index.html;
|
||||
}
|
||||
location /api/ {
|
||||
proxy_pass http://d3m0k1d-backend:8080;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection 'upgrade';
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_cache_bypass $http_upgrade;
|
||||
}
|
||||
|
||||
|
||||
# Кэширование статики
|
||||
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2)$ {
|
||||
expires 1y;
|
||||
add_header Cache-Control "public, immutable";
|
||||
|
||||
1830
frontend/package-lock.json
generated
1830
frontend/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -11,15 +11,22 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@tailwindcss/vite": "^4.1.18",
|
||||
"prismjs": "^1.30.0",
|
||||
"react": "^19.2.0",
|
||||
"react-dom": "^19.2.0",
|
||||
"react-markdown": "^10.1.0",
|
||||
"react-router-dom": "^7.13.0",
|
||||
"react-syntax-highlighter": "^16.1.0",
|
||||
"rehype-raw": "^7.0.0",
|
||||
"remark-gfm": "^4.0.1",
|
||||
"tailwindcss": "^4.1.18"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@eslint/js": "^9.39.1",
|
||||
"@types/node": "^24.10.1",
|
||||
"@types/react": "^19.2.5",
|
||||
"@types/react": "^19.2.14",
|
||||
"@types/react-dom": "^19.2.3",
|
||||
"@types/react-syntax-highlighter": "^15.5.13",
|
||||
"@vitejs/plugin-react": "^5.1.1",
|
||||
"daisyui": "^5.5.14",
|
||||
"eslint": "^9.39.1",
|
||||
|
||||
BIN
frontend/public/favicon.png
Normal file
BIN
frontend/public/favicon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.0 MiB |
@@ -1 +0,0 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>
|
||||
|
Before Width: | Height: | Size: 1.5 KiB |
@@ -1,7 +1,16 @@
|
||||
@import "tailwindcss";
|
||||
@plugin "daisyui";
|
||||
|
||||
#root {
|
||||
max-width: 1280px;
|
||||
margin: 0 auto;
|
||||
padding: 2rem;
|
||||
color: oklch(var(--bc));
|
||||
|
||||
}
|
||||
|
||||
|
||||
body {
|
||||
color: oklch(var(--bc));
|
||||
background-color: oklch(var(--b1));
|
||||
}
|
||||
|
||||
@@ -1,18 +1,53 @@
|
||||
// frontend/src/App.tsx
|
||||
import "./App.css";
|
||||
import { BrowserRouter, Routes, Route } from "react-router-dom";
|
||||
import { useEffect } from "react";
|
||||
import { AuthProvider } from "./contexts/AuthContext.tsx";
|
||||
import Navigation from "./components/Navigation.tsx";
|
||||
import Footer from "./components/Footer.tsx";
|
||||
import AuthCallback from "./components/AuthCallback.tsx";
|
||||
import Home from "./pages/Home.tsx";
|
||||
import About from "./components/Skills.tsx";
|
||||
import Login from "./pages/Login.tsx";
|
||||
import Admin from "./pages/Admin.tsx";
|
||||
import Upload from "./pages/Upload.tsx";
|
||||
import Blog from "./pages/Blog.tsx";
|
||||
import BlogPost from "./pages/BlogPost.tsx";
|
||||
|
||||
function App() {
|
||||
useEffect(() => {
|
||||
document.body.classList.add("loaded");
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<AuthProvider>
|
||||
<BrowserRouter>
|
||||
<div className="min-h-screen flex flex-col">
|
||||
<Navigation />
|
||||
<main className="flex-grow">
|
||||
<Routes>
|
||||
<Route
|
||||
path="/"
|
||||
element={
|
||||
<>
|
||||
<Home />
|
||||
<About />
|
||||
</>
|
||||
}
|
||||
/>
|
||||
<Route path="/blog" element={<Blog />} />
|
||||
<Route path="/blog/:id" element={<BlogPost />} />{" "}
|
||||
{/* Новый роут */}
|
||||
<Route path="/login" element={<Login />} />
|
||||
<Route path="/auth/callback" element={<AuthCallback />} />
|
||||
<Route path="/admin" element={<Admin />} />
|
||||
<Route path="/admin/upload" element={<Upload />} />
|
||||
</Routes>
|
||||
</main>
|
||||
<Footer />
|
||||
</div>
|
||||
</BrowserRouter>
|
||||
</AuthProvider>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
36
frontend/src/components/AuthCallback.tsx
Normal file
36
frontend/src/components/AuthCallback.tsx
Normal file
@@ -0,0 +1,36 @@
|
||||
import { useEffect } from "react";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { useAuth } from "../contexts/AuthContext.tsx";
|
||||
|
||||
export default function AuthCallback() {
|
||||
const navigate = useNavigate();
|
||||
const { checkAuth } = useAuth();
|
||||
|
||||
useEffect(() => {
|
||||
const processAuth = async () => {
|
||||
const hash = window.location.hash.substring(1);
|
||||
const params = new URLSearchParams(hash);
|
||||
const token = params.get("token");
|
||||
|
||||
if (token) {
|
||||
localStorage.setItem("auth_token", token);
|
||||
console.log("Token saved, loading user...");
|
||||
|
||||
await checkAuth();
|
||||
|
||||
window.location.href = "/";
|
||||
} else {
|
||||
console.error("No token in URL");
|
||||
navigate("/login?error=no_token");
|
||||
}
|
||||
};
|
||||
|
||||
processAuth();
|
||||
}, [navigate, checkAuth]);
|
||||
|
||||
return (
|
||||
<div className="fixed inset-0 bg-black flex items-center justify-center">
|
||||
<div className="w-12 h-12 border-2 border-gray-800 border-t-[hsl(270,73%,63%)] rounded-full animate-spin"></div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -1,12 +1,91 @@
|
||||
import { useState } from "react";
|
||||
import { useAuth } from "../contexts/AuthContext.tsx";
|
||||
|
||||
export default function Navigation() {
|
||||
const [isOpen, setIsOpen] = useState(false);
|
||||
function AccountAvatar() {
|
||||
const { user, isLoading, logout } = useAuth();
|
||||
|
||||
const handleLogout = () => {
|
||||
logout();
|
||||
window.location.href = "/";
|
||||
};
|
||||
|
||||
const getInitials = (user: { name?: string; email?: string }): string => {
|
||||
if (user.name) {
|
||||
return user.name.substring(0, 2).toUpperCase();
|
||||
}
|
||||
if (user.email) {
|
||||
return user.email.substring(0, 2).toUpperCase();
|
||||
}
|
||||
return "?";
|
||||
};
|
||||
|
||||
if (isLoading) {
|
||||
return <div className="w-10 h-10 rounded-full bg-gray-200 animate-pulse" />;
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
{user ? (
|
||||
<div
|
||||
className="relative cursor-pointer group"
|
||||
onClick={handleLogout}
|
||||
title={`Logout (${user.name || user.email})`}
|
||||
>
|
||||
{user.avatar ? (
|
||||
<img
|
||||
src={user.avatar}
|
||||
alt={user.name || user.email || "User"}
|
||||
className="w-10 h-10 rounded-full object-cover border-2 border-[hsl(270,73%,63%)] group-hover:border-red-500 transition-colors"
|
||||
/>
|
||||
) : (
|
||||
<div className="w-10 h-10 rounded-full bg-gradient-to-br from-purple-500 to-pink-500 flex items-center justify-center text-white font-semibold text-sm group-hover:from-red-500 group-hover:to-red-600 transition-colors">
|
||||
{getInitials(user)}
|
||||
</div>
|
||||
)}
|
||||
<div className="absolute top-12 right-0 bg-black text-white text-xs px-2 py-1 rounded opacity-0 group-hover:opacity-100 transition-opacity whitespace-nowrap pointer-events-none">
|
||||
Click to logout
|
||||
</div>
|
||||
</div>
|
||||
) : (
|
||||
<a
|
||||
href="/login"
|
||||
className="w-10 h-10 rounded-full bg-gray-300 flex items-center justify-center hover:bg-gray-400 transition-colors"
|
||||
>
|
||||
<svg
|
||||
className="w-6 h-6 text-gray-600"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
viewBox="0 0 24 24"
|
||||
>
|
||||
<path
|
||||
strokeLinecap="round"
|
||||
strokeLinejoin="round"
|
||||
strokeWidth={2}
|
||||
d="M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z"
|
||||
/>
|
||||
</svg>
|
||||
</a>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
export default function Navigation() {
|
||||
const [isOpen, setIsOpen] = useState(false);
|
||||
const { user, logout } = useAuth();
|
||||
|
||||
const handleLogout = () => {
|
||||
logout();
|
||||
window.location.href = "/";
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className="hidden md:block fixed right-4 lg:right-8 top-3 z-50">
|
||||
<AccountAvatar />
|
||||
</div>
|
||||
|
||||
<nav className="sticky top-0 z-50 py-3">
|
||||
{/* Desktop */}
|
||||
<div className="hidden md:flex gap-8 lg:gap-12 justify-center">
|
||||
<a
|
||||
href="/"
|
||||
@@ -28,10 +107,10 @@ export default function Navigation() {
|
||||
</a>
|
||||
</div>
|
||||
|
||||
{/* Mobile Burger Button */}
|
||||
<div className="md:hidden flex justify-between items-center px-4">
|
||||
<button
|
||||
onClick={() => setIsOpen(!isOpen)}
|
||||
className="md:hidden fixed left-4 top-4 z-50 btn btn-ghost btn-sm"
|
||||
className="z-50 btn btn-ghost btn-sm"
|
||||
>
|
||||
<svg
|
||||
className="w-6 h-6"
|
||||
@@ -56,9 +135,10 @@ export default function Navigation() {
|
||||
)}
|
||||
</svg>
|
||||
</button>
|
||||
<AccountAvatar />
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
{/* Mobile Menu */}
|
||||
{isOpen && (
|
||||
<>
|
||||
<div
|
||||
@@ -88,6 +168,24 @@ export default function Navigation() {
|
||||
>
|
||||
Guestbook
|
||||
</a>
|
||||
|
||||
{user && (
|
||||
<>
|
||||
<hr className="my-2" />
|
||||
<div className="py-3 px-4 text-sm text-gray-600">
|
||||
{user.name || user.email}
|
||||
</div>
|
||||
<button
|
||||
onClick={() => {
|
||||
setIsOpen(false);
|
||||
handleLogout();
|
||||
}}
|
||||
className="py-3 px-4 hover:bg-gray-100 rounded-lg transition-all text-red-600 text-left"
|
||||
>
|
||||
Logout
|
||||
</button>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
|
||||
@@ -12,7 +12,7 @@ export default function About() {
|
||||
💻 Github
|
||||
</a>
|
||||
<a
|
||||
href="https://git.d3m0k1d.ru"
|
||||
href="https://gitea.d3m0k1d.ru"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="px-3 py-1 border border-base-content/20 rounded hover:border-[hsl(270,73%,63%)] hover:text-[hsl(270,73%,63%)] transition-all font-mono"
|
||||
@@ -64,7 +64,7 @@ export default function About() {
|
||||
<div>
|
||||
<h3 className="font-mono font-semibold mb-1">Languages:</h3>
|
||||
<p className="text-base-content/70">
|
||||
Golang, Python, Bash, C (Base level), HTML/CSS, Typescript
|
||||
Golang, Python, Bash, C (Base level), HTML/CSS, Typescript, SQL
|
||||
</p>
|
||||
</div>
|
||||
|
||||
@@ -75,7 +75,7 @@ export default function About() {
|
||||
</h3>
|
||||
<p className="text-base-content/70">
|
||||
Docker, k8s, LXC, Proxmox, Git, CI/CD (GitHub Actions, GitLab),
|
||||
Ansible, nginx
|
||||
Ansible, nginx, HashiCorp Vault
|
||||
</p>
|
||||
</div>
|
||||
|
||||
|
||||
86
frontend/src/contexts/AuthContext.tsx
Normal file
86
frontend/src/contexts/AuthContext.tsx
Normal file
@@ -0,0 +1,86 @@
|
||||
import {
|
||||
createContext,
|
||||
useContext,
|
||||
useState,
|
||||
useEffect,
|
||||
type ReactNode,
|
||||
} from "react";
|
||||
|
||||
interface User {
|
||||
name?: string;
|
||||
email?: string;
|
||||
avatar?: string;
|
||||
}
|
||||
|
||||
interface AuthContextType {
|
||||
user: User | null;
|
||||
isLoading: boolean;
|
||||
checkAuth: () => Promise<void>;
|
||||
logout: () => void;
|
||||
}
|
||||
|
||||
const AuthContext = createContext<AuthContextType | undefined>(undefined);
|
||||
|
||||
export function AuthProvider({ children }: { children: ReactNode }) {
|
||||
const [user, setUser] = useState<User | null>(null);
|
||||
const [isLoading, setIsLoading] = useState(true);
|
||||
|
||||
const checkAuth = async () => {
|
||||
setIsLoading(true);
|
||||
try {
|
||||
const token = localStorage.getItem("auth_token");
|
||||
|
||||
if (!token) {
|
||||
setUser(null);
|
||||
setIsLoading(false);
|
||||
return;
|
||||
}
|
||||
|
||||
const response = await fetch("/api/v1/session", {
|
||||
headers: {
|
||||
Authorization: `Bearer ${token}`,
|
||||
},
|
||||
});
|
||||
|
||||
if (response.ok) {
|
||||
const data = await response.json();
|
||||
setUser(data.user);
|
||||
console.log("User loaded:", data.user);
|
||||
} else {
|
||||
console.error("Token invalid, removing");
|
||||
localStorage.removeItem("auth_token");
|
||||
setUser(null);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Auth check failed:", error);
|
||||
localStorage.removeItem("auth_token");
|
||||
setUser(null);
|
||||
} finally {
|
||||
setIsLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
const logout = () => {
|
||||
localStorage.removeItem("auth_token");
|
||||
setUser(null);
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
checkAuth();
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<AuthContext.Provider value={{ user, isLoading, checkAuth, logout }}>
|
||||
{children}
|
||||
</AuthContext.Provider>
|
||||
);
|
||||
}
|
||||
|
||||
// eslint-disable-next-line react-refresh/only-export-components
|
||||
export function useAuth() {
|
||||
const context = useContext(AuthContext);
|
||||
if (!context) {
|
||||
throw new Error("useAuth must be used within AuthProvider");
|
||||
}
|
||||
return context;
|
||||
}
|
||||
561
frontend/src/pages/Admin.tsx
Normal file
561
frontend/src/pages/Admin.tsx
Normal file
@@ -0,0 +1,561 @@
|
||||
// frontend/src/pages/Admin.tsx
|
||||
import { useState, useEffect } from "react";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import ReactMarkdown from "react-markdown";
|
||||
import remarkGfm from "remark-gfm";
|
||||
import rehypeRaw from "rehype-raw";
|
||||
|
||||
interface Post {
|
||||
id: number;
|
||||
title: string;
|
||||
content: string;
|
||||
published: boolean;
|
||||
created_at: string;
|
||||
}
|
||||
|
||||
function Admin() {
|
||||
const [posts, setPosts] = useState<Post[]>([]);
|
||||
const [selectedPost, setSelectedPost] = useState<Post | null>(null);
|
||||
const [title, setTitle] = useState("");
|
||||
const [content, setContent] = useState("");
|
||||
const [published, setPublished] = useState(false);
|
||||
const [showPreview, setShowPreview] = useState(false);
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
const navigate = useNavigate();
|
||||
|
||||
useEffect(() => {
|
||||
checkAuth();
|
||||
fetchPosts();
|
||||
}, []);
|
||||
|
||||
const checkAuth = async () => {
|
||||
const token = localStorage.getItem("auth_token");
|
||||
if (!token) {
|
||||
navigate("/login");
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await fetch("/api/v1/session", {
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
localStorage.removeItem("auth_token");
|
||||
navigate("/login");
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Auth check failed:", error);
|
||||
navigate("/login");
|
||||
}
|
||||
};
|
||||
|
||||
const fetchPosts = async () => {
|
||||
const token = localStorage.getItem("auth_token");
|
||||
|
||||
try {
|
||||
const response = await fetch("/api/v1/admin/posts", {
|
||||
headers: {
|
||||
Authorization: `Bearer ${token}`,
|
||||
},
|
||||
});
|
||||
|
||||
if (response.ok) {
|
||||
const data = await response.json();
|
||||
setPosts(data.data || []);
|
||||
} else if (response.status === 401) {
|
||||
localStorage.removeItem("auth_token");
|
||||
navigate("/login");
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Failed to fetch posts:", error);
|
||||
}
|
||||
};
|
||||
|
||||
const handleCreate = async () => {
|
||||
if (!title.trim() || !content.trim()) {
|
||||
alert("Title and content are required");
|
||||
return;
|
||||
}
|
||||
|
||||
setIsLoading(true);
|
||||
const token = localStorage.getItem("auth_token");
|
||||
|
||||
try {
|
||||
const response = await fetch("/api/v1/posts/", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
Authorization: `Bearer ${token}`,
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
title,
|
||||
content,
|
||||
published,
|
||||
}),
|
||||
});
|
||||
|
||||
if (response.ok) {
|
||||
setTitle("");
|
||||
setContent("");
|
||||
setPublished(false);
|
||||
setSelectedPost(null);
|
||||
fetchPosts();
|
||||
alert("Post created successfully!");
|
||||
} else {
|
||||
const error = await response.text();
|
||||
alert("Failed to create post: " + error);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Failed to create post:", error);
|
||||
alert("Network error");
|
||||
} finally {
|
||||
setIsLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
const handleUpdate = async () => {
|
||||
if (!selectedPost || !title.trim() || !content.trim()) {
|
||||
alert("Title and content are required");
|
||||
return;
|
||||
}
|
||||
|
||||
setIsLoading(true);
|
||||
const token = localStorage.getItem("auth_token");
|
||||
|
||||
try {
|
||||
const response = await fetch(`/api/v1/posts/${selectedPost.id}`, {
|
||||
method: "PUT",
|
||||
headers: {
|
||||
Authorization: `Bearer ${token}`,
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
title,
|
||||
content,
|
||||
published,
|
||||
}),
|
||||
});
|
||||
|
||||
if (response.ok) {
|
||||
setTitle("");
|
||||
setContent("");
|
||||
setPublished(false);
|
||||
setSelectedPost(null);
|
||||
fetchPosts();
|
||||
alert("Post updated successfully!");
|
||||
} else {
|
||||
const error = await response.text();
|
||||
alert("Failed to update post: " + error);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Failed to update post:", error);
|
||||
alert("Network error");
|
||||
} finally {
|
||||
setIsLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
const handleDelete = async (id: number) => {
|
||||
if (!confirm("Delete this post? This action cannot be undone.")) return;
|
||||
|
||||
const token = localStorage.getItem("auth_token");
|
||||
|
||||
try {
|
||||
const response = await fetch(`/api/v1/posts/${id}`, {
|
||||
method: "DELETE",
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
});
|
||||
|
||||
if (response.ok) {
|
||||
fetchPosts();
|
||||
if (selectedPost?.id === id) {
|
||||
setSelectedPost(null);
|
||||
setTitle("");
|
||||
setContent("");
|
||||
setPublished(false);
|
||||
}
|
||||
alert("Post deleted successfully!");
|
||||
} else {
|
||||
alert("Failed to delete post");
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Failed to delete post:", error);
|
||||
alert("Network error");
|
||||
}
|
||||
};
|
||||
|
||||
const selectPost = (post: Post) => {
|
||||
setSelectedPost(post);
|
||||
setTitle(post.title);
|
||||
setContent(post.content);
|
||||
setPublished(post.published);
|
||||
setShowPreview(false);
|
||||
};
|
||||
|
||||
const clearForm = () => {
|
||||
setSelectedPost(null);
|
||||
setTitle("");
|
||||
setContent("");
|
||||
setPublished(false);
|
||||
setShowPreview(false);
|
||||
};
|
||||
|
||||
// Markdown shortcut helpers
|
||||
const insertMarkdown = (syntax: string, placeholder: string = "") => {
|
||||
const textarea = document.querySelector("textarea");
|
||||
if (!textarea) return;
|
||||
|
||||
const start = textarea.selectionStart;
|
||||
const end = textarea.selectionEnd;
|
||||
const selectedText = content.substring(start, end) || placeholder;
|
||||
const beforeText = content.substring(0, start);
|
||||
const afterText = content.substring(end);
|
||||
|
||||
let newText = "";
|
||||
let cursorPosition = start;
|
||||
|
||||
if (syntax === "link") {
|
||||
newText = `${beforeText}[${selectedText}](url)${afterText}`;
|
||||
cursorPosition = start + selectedText.length + 3;
|
||||
} else if (syntax === "image") {
|
||||
newText = `${beforeText}${afterText}`;
|
||||
cursorPosition = start + selectedText.length + 4;
|
||||
} else if (syntax === "code") {
|
||||
newText = `${beforeText}\`\`\`\n${selectedText}\n\`\`\`${afterText}`;
|
||||
cursorPosition = start + 4;
|
||||
} else if (syntax === "bold") {
|
||||
newText = `${beforeText}**${selectedText}**${afterText}`;
|
||||
cursorPosition = start + 2 + selectedText.length;
|
||||
} else if (syntax === "italic") {
|
||||
newText = `${beforeText}*${selectedText}*${afterText}`;
|
||||
cursorPosition = start + 1 + selectedText.length;
|
||||
} else if (syntax === "h1") {
|
||||
newText = `${beforeText}# ${selectedText}${afterText}`;
|
||||
cursorPosition = start + 2 + selectedText.length;
|
||||
} else if (syntax === "h2") {
|
||||
newText = `${beforeText}## ${selectedText}${afterText}`;
|
||||
cursorPosition = start + 3 + selectedText.length;
|
||||
} else if (syntax === "list") {
|
||||
newText = `${beforeText}- ${selectedText}${afterText}`;
|
||||
cursorPosition = start + 2 + selectedText.length;
|
||||
}
|
||||
|
||||
setContent(newText);
|
||||
setTimeout(() => {
|
||||
textarea.focus();
|
||||
textarea.setSelectionRange(cursorPosition, cursorPosition);
|
||||
}, 0);
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="min-h-screen bg-black text-white font-['Commit_Mono',monospace]">
|
||||
<div className="max-w-[2000px] mx-auto px-2 sm:px-4">
|
||||
{/* Header */}
|
||||
<div className="pt-6 pb-4 border-b border-gray-800">
|
||||
<div className="flex items-center justify-between">
|
||||
<div>
|
||||
<h1 className="text-xl sm:text-2xl font-bold text-[hsl(270,73%,63%)]">
|
||||
Admin Panel
|
||||
</h1>
|
||||
<p className="text-gray-500 text-xs sm:text-sm mt-1">
|
||||
Blog Editor
|
||||
</p>
|
||||
</div>
|
||||
<div className="flex gap-2 sm:gap-3">
|
||||
<button
|
||||
onClick={() => navigate("/admin/upload")}
|
||||
className="px-3 py-1.5 sm:px-4 sm:py-2 border border-gray-700 rounded hover:border-[hsl(270,73%,63%)] transition-colors text-xs sm:text-sm"
|
||||
>
|
||||
Upload
|
||||
</button>
|
||||
<button
|
||||
onClick={() => {
|
||||
localStorage.removeItem("auth_token");
|
||||
navigate("/");
|
||||
}}
|
||||
className="px-3 py-1.5 sm:px-4 sm:py-2 border border-gray-700 rounded hover:border-red-500 hover:text-red-500 transition-colors text-xs sm:text-sm"
|
||||
>
|
||||
Logout
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="grid grid-cols-12 gap-3 sm:gap-4 mt-4">
|
||||
{/* Sidebar - Posts List - Адаптивная ширина */}
|
||||
<div className="col-span-12 xl:col-span-2">
|
||||
<div className="xl:sticky xl:top-6">
|
||||
<div className="flex items-center justify-between mb-3">
|
||||
<h2 className="text-base sm:text-lg font-semibold">
|
||||
Posts ({posts.length})
|
||||
</h2>
|
||||
<button
|
||||
onClick={clearForm}
|
||||
className="px-2 py-1 sm:px-3 sm:py-1 bg-[hsl(270,73%,63%)] text-white rounded text-xs sm:text-sm hover:bg-[hsl(270,73%,70%)] transition-colors"
|
||||
>
|
||||
+ New
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div className="space-y-2 max-h-[300px] xl:max-h-[calc(100vh-200px)] overflow-y-auto custom-scrollbar">
|
||||
{posts.map((post) => (
|
||||
<div
|
||||
key={post.id}
|
||||
onClick={() => selectPost(post)}
|
||||
className={`p-2 sm:p-3 rounded border cursor-pointer transition-all ${
|
||||
selectedPost?.id === post.id
|
||||
? "border-[hsl(270,73%,63%)] bg-[hsl(270,73%,63%)]/10"
|
||||
: "border-gray-800 hover:border-gray-700"
|
||||
}`}
|
||||
>
|
||||
<div className="flex items-start justify-between mb-1">
|
||||
<h3 className="font-medium text-xs sm:text-sm truncate flex-1">
|
||||
{post.title}
|
||||
</h3>
|
||||
<div className="flex items-center gap-1 sm:gap-2">
|
||||
{post.published ? (
|
||||
<span
|
||||
className="text-xs text-green-500"
|
||||
title="Published"
|
||||
>
|
||||
✓
|
||||
</span>
|
||||
) : (
|
||||
<span className="text-xs text-gray-600" title="Draft">
|
||||
○
|
||||
</span>
|
||||
)}
|
||||
<span className="text-xs text-gray-500">
|
||||
#{post.id}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<p className="text-xs text-gray-500 line-clamp-2 hidden sm:block">
|
||||
{post.content.substring(0, 60)}...
|
||||
</p>
|
||||
<div className="flex items-center justify-between mt-1 sm:mt-2">
|
||||
<span className="text-xs text-gray-600">
|
||||
{new Date(post.created_at).toLocaleDateString()}
|
||||
</span>
|
||||
<button
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
handleDelete(post.id);
|
||||
}}
|
||||
className="text-xs text-red-500 hover:text-red-400"
|
||||
>
|
||||
Del
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Main Editor - Увеличенная рабочая область */}
|
||||
<div className="col-span-12 xl:col-span-10">
|
||||
<div className="bg-black border border-gray-800 rounded-lg">
|
||||
{/* Toolbar */}
|
||||
<div className="border-b border-gray-800 p-2 sm:p-3 flex items-center justify-between flex-wrap gap-2">
|
||||
<div className="flex items-center gap-1 sm:gap-2 flex-wrap">
|
||||
<button
|
||||
onClick={() => insertMarkdown("bold", "bold text")}
|
||||
className="p-1.5 sm:p-2 hover:bg-gray-900 rounded transition-colors text-xs sm:text-sm"
|
||||
title="Bold"
|
||||
>
|
||||
<strong>B</strong>
|
||||
</button>
|
||||
<button
|
||||
onClick={() => insertMarkdown("italic", "italic text")}
|
||||
className="p-1.5 sm:p-2 hover:bg-gray-900 rounded transition-colors text-xs sm:text-sm"
|
||||
title="Italic"
|
||||
>
|
||||
<em>I</em>
|
||||
</button>
|
||||
<div className="w-px h-4 sm:h-6 bg-gray-800"></div>
|
||||
<button
|
||||
onClick={() => insertMarkdown("h1", "Heading 1")}
|
||||
className="p-1.5 sm:p-2 hover:bg-gray-900 rounded transition-colors text-xs sm:text-sm"
|
||||
title="H1"
|
||||
>
|
||||
H1
|
||||
</button>
|
||||
<button
|
||||
onClick={() => insertMarkdown("h2", "Heading 2")}
|
||||
className="p-1.5 sm:p-2 hover:bg-gray-900 rounded transition-colors text-xs sm:text-sm"
|
||||
title="H2"
|
||||
>
|
||||
H2
|
||||
</button>
|
||||
<div className="w-px h-4 sm:h-6 bg-gray-800"></div>
|
||||
<button
|
||||
onClick={() => insertMarkdown("link", "link text")}
|
||||
className="p-1.5 sm:p-2 hover:bg-gray-900 rounded transition-colors text-xs sm:text-sm"
|
||||
title="Link"
|
||||
>
|
||||
🔗
|
||||
</button>
|
||||
<button
|
||||
onClick={() => insertMarkdown("image", "alt text")}
|
||||
className="p-1.5 sm:p-2 hover:bg-gray-900 rounded transition-colors text-xs sm:text-sm"
|
||||
title="Image"
|
||||
>
|
||||
🖼️
|
||||
</button>
|
||||
<button
|
||||
onClick={() => insertMarkdown("code", "code")}
|
||||
className="p-1.5 sm:p-2 hover:bg-gray-900 rounded transition-colors text-xs sm:text-sm"
|
||||
title="Code"
|
||||
>
|
||||
</>
|
||||
</button>
|
||||
<button
|
||||
onClick={() => insertMarkdown("list", "list item")}
|
||||
className="p-1.5 sm:p-2 hover:bg-gray-900 rounded transition-colors text-xs sm:text-sm"
|
||||
title="List"
|
||||
>
|
||||
•
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<button
|
||||
onClick={() => setShowPreview(!showPreview)}
|
||||
className={`px-3 py-1.5 sm:px-4 sm:py-2 rounded text-xs sm:text-sm transition-colors ${
|
||||
showPreview
|
||||
? "bg-[hsl(270,73%,63%)] text-white"
|
||||
: "border border-gray-700 hover:border-gray-600"
|
||||
}`}
|
||||
>
|
||||
{showPreview ? "📝 Editor" : "👁️ Preview"}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{/* Content Area */}
|
||||
<div className="p-3 sm:p-4 md:p-6">
|
||||
{!showPreview ? (
|
||||
<>
|
||||
<input
|
||||
type="text"
|
||||
placeholder="Post title..."
|
||||
value={title}
|
||||
onChange={(e) => setTitle(e.target.value)}
|
||||
className="w-full bg-transparent border-none outline-none text-2xl sm:text-3xl font-bold mb-4 sm:mb-6 placeholder-gray-700"
|
||||
/>
|
||||
|
||||
{/* Чекбокс Published */}
|
||||
<div className="mb-4 sm:mb-6 flex flex-col sm:flex-row sm:items-center gap-2 sm:gap-3">
|
||||
<label className="flex items-center gap-2 cursor-pointer">
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={published}
|
||||
onChange={(e) => setPublished(e.target.checked)}
|
||||
className="w-4 h-4 sm:w-5 sm:h-5 rounded border-gray-700 bg-transparent text-[hsl(270,73%,63%)] focus:ring-[hsl(270,73%,63%)] focus:ring-offset-0 cursor-pointer"
|
||||
/>
|
||||
<span className="text-xs sm:text-sm">
|
||||
Publish this post
|
||||
</span>
|
||||
</label>
|
||||
<span className="text-xs text-gray-600">
|
||||
{published
|
||||
? "(Visible to everyone)"
|
||||
: "(Draft - only admins)"}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<textarea
|
||||
placeholder="Write your post content in Markdown...
|
||||
|
||||
Examples:
|
||||
# Heading
|
||||
**bold** *italic*
|
||||
[link](url)
|
||||

|
||||
\`\`\`code\`\`\`
|
||||
"
|
||||
value={content}
|
||||
onChange={(e) => setContent(e.target.value)}
|
||||
className="w-full h-[400px] sm:h-[500px] md:h-[600px] lg:h-[700px] bg-transparent border border-gray-800 rounded p-3 sm:p-4 outline-none focus:border-gray-700 transition-colors resize-none font-mono text-xs sm:text-sm"
|
||||
/>
|
||||
</>
|
||||
) : (
|
||||
<div className="prose prose-invert prose-sm sm:prose-lg max-w-none">
|
||||
<h1 className="text-3xl sm:text-4xl font-bold mb-4 sm:mb-6 text-[hsl(270,73%,63%)]">
|
||||
{title || "Untitled Post"}
|
||||
</h1>
|
||||
<div className="mb-4 sm:mb-6 text-xs sm:text-sm">
|
||||
{published ? (
|
||||
<span className="text-green-500">✓ Published</span>
|
||||
) : (
|
||||
<span className="text-yellow-500">○ Draft</span>
|
||||
)}
|
||||
</div>
|
||||
<div className="markdown-content">
|
||||
<ReactMarkdown
|
||||
remarkPlugins={[remarkGfm]}
|
||||
rehypePlugins={[rehypeRaw]}
|
||||
>
|
||||
{content || "*No content yet...*"}
|
||||
</ReactMarkdown>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Actions */}
|
||||
<div className="border-t border-gray-800 p-3 sm:p-4 flex flex-col sm:flex-row items-start sm:items-center justify-between gap-3">
|
||||
<div className="text-xs sm:text-sm text-gray-500">
|
||||
{selectedPost
|
||||
? `Editing post #${selectedPost.id}`
|
||||
: "Creating new post"}
|
||||
</div>
|
||||
<div className="flex gap-2 sm:gap-3 w-full sm:w-auto">
|
||||
{selectedPost && (
|
||||
<button
|
||||
onClick={clearForm}
|
||||
className="flex-1 sm:flex-none px-3 py-1.5 sm:px-4 sm:py-2 border border-gray-700 rounded hover:border-gray-600 transition-colors text-xs sm:text-sm"
|
||||
>
|
||||
Cancel
|
||||
</button>
|
||||
)}
|
||||
<button
|
||||
onClick={selectedPost ? handleUpdate : handleCreate}
|
||||
disabled={isLoading || !title.trim() || !content.trim()}
|
||||
className="flex-1 sm:flex-none px-4 py-1.5 sm:px-6 sm:py-2 bg-[hsl(270,73%,63%)] text-white rounded hover:bg-[hsl(270,73%,70%)] transition-colors disabled:opacity-50 disabled:cursor-not-allowed text-xs sm:text-sm font-medium"
|
||||
>
|
||||
{isLoading
|
||||
? "Saving..."
|
||||
: selectedPost
|
||||
? "Update"
|
||||
: published
|
||||
? "Publish"
|
||||
: "Save Draft"}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style>{`
|
||||
.custom-scrollbar::-webkit-scrollbar {
|
||||
width: 6px;
|
||||
}
|
||||
.custom-scrollbar::-webkit-scrollbar-track {
|
||||
background: #111;
|
||||
}
|
||||
.custom-scrollbar::-webkit-scrollbar-thumb {
|
||||
background: #333;
|
||||
border-radius: 4px;
|
||||
}
|
||||
.custom-scrollbar::-webkit-scrollbar-thumb:hover {
|
||||
background: #444;
|
||||
}
|
||||
`}</style>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default Admin;
|
||||
151
frontend/src/pages/Blog.tsx
Normal file
151
frontend/src/pages/Blog.tsx
Normal file
@@ -0,0 +1,151 @@
|
||||
// frontend/src/pages/Blog.tsx
|
||||
import { useState, useEffect } from "react";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
|
||||
interface Post {
|
||||
id: number;
|
||||
title: string;
|
||||
content: string;
|
||||
created_at: string;
|
||||
}
|
||||
|
||||
function Blog() {
|
||||
const [posts, setPosts] = useState<Post[]>([]);
|
||||
const [isLoading, setIsLoading] = useState(true);
|
||||
const navigate = useNavigate();
|
||||
|
||||
useEffect(() => {
|
||||
fetchPosts();
|
||||
}, []);
|
||||
|
||||
const fetchPosts = async () => {
|
||||
try {
|
||||
const response = await fetch("/api/v1/posts");
|
||||
if (response.ok) {
|
||||
const data = await response.json();
|
||||
const fetchedPosts = data.data || [];
|
||||
|
||||
// Сортируем от новых к старым
|
||||
const sorted = fetchedPosts.sort((a: Post, b: Post) => {
|
||||
const dateA = new Date(a.created_at).getTime();
|
||||
const dateB = new Date(b.created_at).getTime();
|
||||
return dateB - dateA; // От нового к старому
|
||||
});
|
||||
|
||||
setPosts(sorted);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Failed to fetch posts:", error);
|
||||
} finally {
|
||||
setIsLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
const truncateContent = (content: string, sentences: number = 3) => {
|
||||
const plainText = content
|
||||
.replace(/#{1,6}\\s/g, "")
|
||||
.replace(/\\*\\*(.+?)\\*\\*/g, "$1")
|
||||
.replace(/\\*(.+?)\\*/g, "$1")
|
||||
.replace(/`{3}[\\s\\S]*?`{3}/g, "")
|
||||
.replace(/`(.+?)`/g, "$1")
|
||||
.replace(/\\[(.+?)\\]\\(.+?\\)/g, "$1")
|
||||
.replace(/!\\[.*?\\]\\(.+?\\)/g, "")
|
||||
.replace(/\\n+/g, " ")
|
||||
.trim();
|
||||
|
||||
const sentenceRegex = /[^.!?]+[.!?]+/g;
|
||||
const matches = plainText.match(sentenceRegex);
|
||||
|
||||
if (!matches || matches.length === 0) {
|
||||
if (plainText.length <= 200) return plainText;
|
||||
return plainText.substring(0, 200).trim() + "...";
|
||||
}
|
||||
|
||||
const truncated = matches.slice(0, sentences).join(" ");
|
||||
return truncated + (matches.length > sentences ? "..." : "");
|
||||
};
|
||||
|
||||
const formatDate = (dateString: string) => {
|
||||
if (!dateString) return "";
|
||||
|
||||
const date = new Date(dateString);
|
||||
if (isNaN(date.getTime())) {
|
||||
console.error("Invalid date from API:", dateString);
|
||||
return "recent";
|
||||
}
|
||||
|
||||
return date.toLocaleDateString("en-US", {
|
||||
year: "numeric",
|
||||
month: "long",
|
||||
day: "numeric",
|
||||
});
|
||||
};
|
||||
|
||||
if (isLoading) {
|
||||
return (
|
||||
<div className="min-h-screen bg-black flex items-center justify-center">
|
||||
<div className="text-white text-lg font-['Commit_Mono',monospace]">
|
||||
Loading...
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="min-h-screen bg-black text-white font-['Commit_Mono',monospace]">
|
||||
<div className="max-w-[900px] mx-auto px-4 sm:px-6 py-10 sm:py-16">
|
||||
{/* Минимальный заголовок */}
|
||||
<div className="mb-10">
|
||||
<h1 className="text-2xl sm:text-3xl font-bold text-gray-400 mb-1">
|
||||
blog
|
||||
</h1>
|
||||
<div className="h-px w-24 bg-gray-800" />
|
||||
</div>
|
||||
|
||||
{posts.length === 0 ? (
|
||||
<div className="py-16">
|
||||
<p className="text-gray-500 text-sm">No posts yet.</p>
|
||||
</div>
|
||||
) : (
|
||||
<div className="space-y-10 sm:space-y-12">
|
||||
{posts.map((post, index) => (
|
||||
<div key={post.id}>
|
||||
<article className="flex flex-col gap-3 text-left">
|
||||
<h2 className="text-xl sm:text-2xl font-semibold text-[hsl(270,73%,63%)]">
|
||||
{post.title}
|
||||
</h2>
|
||||
|
||||
<div className="text-xs sm:text-sm text-gray-500">
|
||||
{formatDate(post.created_at)}
|
||||
</div>
|
||||
|
||||
<p className="text-gray-300 text-sm sm:text-base leading-relaxed">
|
||||
{truncateContent(post.content, 3)}
|
||||
</p>
|
||||
|
||||
<div className="mt-2">
|
||||
<button
|
||||
onClick={() => navigate(`/blog/${post.id}`)}
|
||||
className="inline-flex items-center px-4 py-2 border border-gray-700 rounded hover:border-[hsl(270,73%,63%)] hover:text-[hsl(270,73%,63%)] transition-colors text-xs sm:text-sm"
|
||||
>
|
||||
Read more
|
||||
<span className="ml-2 text-[hsl(270,73%,63%)]">→</span>
|
||||
</button>
|
||||
</div>
|
||||
</article>
|
||||
|
||||
{index !== posts.length - 1 && (
|
||||
<div className="mt-6 sm:mt-8">
|
||||
<div className="h-px w-full bg-gradient-to-r from-[hsl(270,73%,63%)] via-gray-800 to-transparent opacity-60" />
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default Blog;
|
||||
284
frontend/src/pages/BlogPost.tsx
Normal file
284
frontend/src/pages/BlogPost.tsx
Normal file
@@ -0,0 +1,284 @@
|
||||
// frontend/src/pages/BlogPost.tsx
|
||||
import { useState, useEffect, useCallback } from "react";
|
||||
import { useParams, useNavigate } from "react-router-dom";
|
||||
import ReactMarkdown from "react-markdown";
|
||||
import remarkGfm from "remark-gfm";
|
||||
import { Prism as SyntaxHighlighter } from "react-syntax-highlighter";
|
||||
import { oneDark as theme } from "react-syntax-highlighter/dist/esm/styles/prism";
|
||||
|
||||
interface Post {
|
||||
id: number;
|
||||
title: string;
|
||||
content: string;
|
||||
created_at: string;
|
||||
}
|
||||
|
||||
function BlogPost() {
|
||||
const { id } = useParams<{ id: string }>();
|
||||
const [post, setPost] = useState<Post | null>(null);
|
||||
const [isLoading, setIsLoading] = useState(true);
|
||||
const navigate = useNavigate();
|
||||
|
||||
useEffect(() => {
|
||||
if (id) {
|
||||
fetchPost(id);
|
||||
}
|
||||
}, [id]);
|
||||
|
||||
const fetchPost = async (postId: string) => {
|
||||
try {
|
||||
const response = await fetch(`/api/v1/posts/${postId}`);
|
||||
if (response.ok) {
|
||||
const data = await response.json();
|
||||
setPost(data.data || data);
|
||||
} else {
|
||||
navigate("/blog");
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Failed to fetch post:", error);
|
||||
navigate("/blog");
|
||||
} finally {
|
||||
setIsLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
const formatDate = (dateString: string) => {
|
||||
const date = new Date(dateString);
|
||||
return date.toLocaleDateString("en-US", {
|
||||
year: "numeric",
|
||||
month: "long",
|
||||
day: "numeric",
|
||||
});
|
||||
};
|
||||
|
||||
const copyCode = useCallback((code: string) => {
|
||||
navigator.clipboard.writeText(code);
|
||||
}, []);
|
||||
|
||||
if (isLoading) {
|
||||
return (
|
||||
<div className="min-h-screen bg-black flex items-center justify-center">
|
||||
<div className="text-[hsl(270,73%,63%)] text-xl font-['Commit_Mono',monospace]">
|
||||
Loading...
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
if (!post) {
|
||||
return (
|
||||
<div className="min-h-screen bg-black flex items-center justify-center">
|
||||
<div className="text-gray-500 text-xl font-['Commit_Mono',monospace]">
|
||||
Post not found
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="min-h-screen bg-black text-white font-['Commit_Mono',monospace]">
|
||||
<div className="max-w-[900px] mx-auto px-4 sm:px-6 py-12 sm:py-16">
|
||||
<button
|
||||
onClick={() => navigate("/blog")}
|
||||
className="flex items-center gap-2 text-gray-400 hover:text-[hsl(270,73%,63%)] transition-colors mb-8 text-sm sm:text-base"
|
||||
>
|
||||
<svg
|
||||
className="w-4 h-4"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
viewBox="0 0 24 24"
|
||||
>
|
||||
<path
|
||||
strokeLinecap="round"
|
||||
strokeLinejoin="round"
|
||||
strokeWidth={2}
|
||||
d="M15 19l-7-7 7-7"
|
||||
/>
|
||||
</svg>
|
||||
Back to blog page
|
||||
</button>
|
||||
|
||||
<article>
|
||||
<header className="mb-8 sm:mb-12">
|
||||
<h1 className="text-3xl sm:text-4xl md:text-5xl font-bold text-[hsl(270,73%,63%)] mb-4 leading-tight">
|
||||
{post.title}
|
||||
</h1>
|
||||
<div className="flex items-center gap-4 text-sm text-gray-500">
|
||||
<time dateTime={post.created_at}>
|
||||
{formatDate(post.created_at)}
|
||||
</time>
|
||||
<span>•</span>
|
||||
<span>{Math.ceil(post.content.length / 1000)} min reading</span>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<div className="blog-content">
|
||||
<ReactMarkdown
|
||||
remarkPlugins={[remarkGfm]}
|
||||
components={{
|
||||
code(props) {
|
||||
const { children, className, ...rest } = props;
|
||||
const match = /language-(\w+)/.exec(className || "");
|
||||
const language = match ? match[1] : "text";
|
||||
|
||||
if (!match) {
|
||||
return (
|
||||
<code {...rest} className="inline-code">
|
||||
{children}
|
||||
</code>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="code-container">
|
||||
<button
|
||||
onClick={() =>
|
||||
copyCode(String(children).replace(/\n$/, ""))
|
||||
}
|
||||
className="copy-button"
|
||||
title="Copy code"
|
||||
>
|
||||
<span>Copy</span>
|
||||
</button>
|
||||
<SyntaxHighlighter
|
||||
style={theme}
|
||||
language={language}
|
||||
PreTag="div"
|
||||
customStyle={{
|
||||
background: "rgb(12, 12, 22)",
|
||||
margin: 0,
|
||||
padding: "1.75rem 1.5rem 1.5rem",
|
||||
borderRadius: "0 0 12px 12px",
|
||||
fontSize: "0.875rem",
|
||||
lineHeight: "1.65",
|
||||
}}
|
||||
>
|
||||
{String(children).replace(/\n$/, "")}
|
||||
</SyntaxHighlighter>
|
||||
</div>
|
||||
);
|
||||
},
|
||||
strong: ({ children }) => (
|
||||
<strong className="text-white font-bold">{children}</strong>
|
||||
),
|
||||
em: ({ children }) => (
|
||||
<em className="text-white italic">{children}</em>
|
||||
),
|
||||
}}
|
||||
>
|
||||
{post.content}
|
||||
</ReactMarkdown>
|
||||
</div>
|
||||
</article>
|
||||
</div>
|
||||
|
||||
<style>{`
|
||||
.blog-content {
|
||||
color: #ffffff !important;
|
||||
line-height: 1.8;
|
||||
}
|
||||
|
||||
.blog-content p {
|
||||
color: #ffffff !important;
|
||||
margin-bottom: 1.5em;
|
||||
}
|
||||
|
||||
.blog-content strong {
|
||||
color: #ffffff !important;
|
||||
font-weight: 700 !important;
|
||||
}
|
||||
|
||||
.blog-content ul, .blog-content ol {
|
||||
color: #ffffff !important;
|
||||
padding-left: 1.5em;
|
||||
}
|
||||
|
||||
.blog-content li {
|
||||
color: #ffffff !important;
|
||||
}
|
||||
|
||||
/* Inline код */
|
||||
.inline-code {
|
||||
color: #ffffff !important;
|
||||
background: rgba(255,255,255,0.1) !important;
|
||||
padding: 0.2em 0.4em !important;
|
||||
border-radius: 6px !important;
|
||||
font-size: 0.875em !important;
|
||||
font-family: 'Commit_Mono', monospace !important;
|
||||
}
|
||||
|
||||
/* Контейнер кода */
|
||||
.code-container {
|
||||
position: relative;
|
||||
margin: 2em 0;
|
||||
border-radius: 12px;
|
||||
overflow: hidden;
|
||||
background: linear-gradient(145deg, rgb(8,8,18) 0%, rgb(18,18,32) 100%);
|
||||
border: 1px solid rgba(255,255,255,0.06);
|
||||
box-shadow: 0 12px 40px rgba(0,0,0,0.5);
|
||||
}
|
||||
|
||||
/* Анимированная кнопка */
|
||||
.copy-button {
|
||||
position: absolute;
|
||||
top: 14px;
|
||||
right: 14px;
|
||||
z-index: 20;
|
||||
background: linear-gradient(135deg, rgba(117,43,255,0.25) 0%, rgba(117,43,255,0.15) 100%);
|
||||
border: 1px solid rgba(117,43,255,0.5);
|
||||
color: #ffffff;
|
||||
padding: 8px 16px;
|
||||
border-radius: 8px;
|
||||
font-size: 13px;
|
||||
font-weight: 500;
|
||||
cursor: pointer;
|
||||
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
||||
font-family: 'Commit_Mono', monospace;
|
||||
backdrop-filter: blur(20px);
|
||||
box-shadow: 0 4px 16px rgba(117,43,255,0.25);
|
||||
}
|
||||
|
||||
.copy-button:hover {
|
||||
background: linear-gradient(135deg, hsl(270,73%,65%) 0%, hsl(270,73%,55%) 100%);
|
||||
transform: translateY(-3px) scale(1.03);
|
||||
box-shadow: 0 12px 30px rgba(117,43,255,0.45);
|
||||
border-color: hsl(270,73%,75%);
|
||||
}
|
||||
|
||||
.copy-button:active {
|
||||
transform: translateY(-1px) scale(0.98);
|
||||
transition: all 0.1s;
|
||||
}
|
||||
|
||||
/* Заголовки */
|
||||
.blog-content h1, .blog-content h2, .blog-content h3 {
|
||||
color: hsl(270, 73%, 63%) !important;
|
||||
margin-top: 2em;
|
||||
margin-bottom: 0.75em;
|
||||
}
|
||||
|
||||
.blog-content a {
|
||||
color: hsl(270, 73%, 63%) !important;
|
||||
}
|
||||
|
||||
/* Responsive */
|
||||
@media (max-width: 640px) {
|
||||
.code-container {
|
||||
margin: 1.5em -1rem;
|
||||
border-radius: 0;
|
||||
border-left: none;
|
||||
border-right: none;
|
||||
}
|
||||
.copy-button {
|
||||
top: 10px;
|
||||
right: 10px;
|
||||
padding: 6px 12px;
|
||||
font-size: 12px;
|
||||
}
|
||||
}
|
||||
`}</style>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default BlogPost;
|
||||
79
frontend/src/pages/Login.tsx
Normal file
79
frontend/src/pages/Login.tsx
Normal file
@@ -0,0 +1,79 @@
|
||||
export default function Login() {
|
||||
const handleGitHubLogin = () => {
|
||||
window.location.href = "/api/v1/auth/github";
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="flex items-center justify-center px-4 py-12 md:py-0 md:min-h-[calc(100vh-200px)]">
|
||||
<div className="max-w-md w-full">
|
||||
{/* ASCII Art Header */}
|
||||
<pre className="text-center mb-8 text-[10px] sm:text-xs lg:text-sm opacity-80 font-mono leading-tight select-none">
|
||||
{`
|
||||
██╗ ██████╗ ██████╗ ██╗███╗ ██╗
|
||||
██║ ██╔═══██╗██╔════╝ ██║████╗ ██║
|
||||
██║ ██║ ██║██║ ███╗██║██╔██╗ ██║
|
||||
██║ ██║ ██║██║ ██║██║██║╚██╗██║
|
||||
███████╗╚██████╔╝╚██████╔╝██║██║ ╚████║
|
||||
╚══════╝ ╚═════╝ ╚═════╝ ╚═╝╚═╝ ╚═══╝
|
||||
|
||||
╔════════════════════════════════════╗
|
||||
║ Secure GitHub Authentication ║
|
||||
╚════════════════════════════════════╝
|
||||
`}
|
||||
</pre>
|
||||
|
||||
{/* Login Card */}
|
||||
<div className="border border-gray-700 rounded-lg p-6 sm:p-8 bg-black/30 backdrop-blur-sm shadow-xl">
|
||||
<h1 className="text-xl sm:text-2xl font-bold mb-2 text-center">
|
||||
Welcome Back
|
||||
</h1>
|
||||
<p className="text-gray-400 text-center mb-6 sm:mb-8 text-sm">
|
||||
Sign in to continue to your account
|
||||
</p>
|
||||
|
||||
{/* GitHub Login Button */}
|
||||
<button
|
||||
onClick={handleGitHubLogin}
|
||||
className="w-full bg-white text-black hover:bg-gray-200 active:scale-95 transition-all duration-300 py-3 sm:py-4 px-6 rounded-lg font-semibold flex items-center justify-center gap-3 group shadow-lg hover:shadow-xl"
|
||||
>
|
||||
<svg
|
||||
className="w-5 h-5 sm:w-6 sm:h-6 group-hover:scale-110 transition-transform"
|
||||
fill="currentColor"
|
||||
viewBox="0 0 24 24"
|
||||
>
|
||||
<path
|
||||
fillRule="evenodd"
|
||||
d="M12 2C6.477 2 2 6.484 2 12.017c0 4.425 2.865 8.18 6.839 9.504.5.092.682-.217.682-.483 0-.237-.008-.868-.013-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.029-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.202 2.398.1 2.651.64.7 1.028 1.595 1.028 2.688 0 3.848-2.339 4.695-4.566 4.943.359.309.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.019 10.019 0 0022 12.017C22 6.484 17.522 2 12 2z"
|
||||
clipRule="evenodd"
|
||||
/>
|
||||
</svg>
|
||||
<span className="text-sm sm:text-base">Login via GitHub</span>
|
||||
</button>
|
||||
|
||||
{/* Divider */}
|
||||
<div className="relative my-6">
|
||||
<div className="absolute inset-0 flex items-center">
|
||||
<div className="w-full border-t border-gray-700"></div>
|
||||
</div>
|
||||
<div className="relative flex justify-center text-xs">
|
||||
<span className="bg-black/30 px-2 text-gray-500">
|
||||
secure authentication
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Footer note */}
|
||||
<p className="text-gray-500 text-xs text-center">
|
||||
By signing in, you agree to our{" "}
|
||||
<a
|
||||
href="/terms"
|
||||
className="text-[hsl(270,73%,63%)] hover:underline"
|
||||
>
|
||||
terms of service
|
||||
</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
323
frontend/src/pages/Upload.tsx
Normal file
323
frontend/src/pages/Upload.tsx
Normal file
@@ -0,0 +1,323 @@
|
||||
// frontend/src/pages/Upload.tsx
|
||||
import { useState } from "react";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
|
||||
interface UploadedFile {
|
||||
url: string;
|
||||
filename: string;
|
||||
size: number;
|
||||
uploaded_at: string;
|
||||
}
|
||||
|
||||
function Upload() {
|
||||
const [selectedFile, setSelectedFile] = useState<File | null>(null);
|
||||
const [uploadedFiles, setUploadedFiles] = useState<UploadedFile[]>([]);
|
||||
const [isUploading, setIsUploading] = useState(false);
|
||||
const [dragActive, setDragActive] = useState(false);
|
||||
const navigate = useNavigate();
|
||||
|
||||
const handleFileSelect = (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||
if (e.target.files && e.target.files[0]) {
|
||||
setSelectedFile(e.target.files[0]);
|
||||
}
|
||||
};
|
||||
|
||||
const handleDrag = (e: React.DragEvent) => {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
if (e.type === "dragenter" || e.type === "dragover") {
|
||||
setDragActive(true);
|
||||
} else if (e.type === "dragleave") {
|
||||
setDragActive(false);
|
||||
}
|
||||
};
|
||||
|
||||
const handleDrop = (e: React.DragEvent) => {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
setDragActive(false);
|
||||
|
||||
if (e.dataTransfer.files && e.dataTransfer.files[0]) {
|
||||
setSelectedFile(e.dataTransfer.files[0]);
|
||||
}
|
||||
};
|
||||
|
||||
const handleUpload = async () => {
|
||||
if (!selectedFile) {
|
||||
alert("Please select a file first");
|
||||
return;
|
||||
}
|
||||
|
||||
setIsUploading(true);
|
||||
const token = localStorage.getItem("auth_token");
|
||||
const formData = new FormData();
|
||||
formData.append("file", selectedFile);
|
||||
|
||||
try {
|
||||
const response = await fetch("/api/v1/upload", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
Authorization: `Bearer ${token}`,
|
||||
},
|
||||
body: formData,
|
||||
});
|
||||
|
||||
if (response.ok) {
|
||||
const data = await response.json();
|
||||
const newFile: UploadedFile = {
|
||||
url: data.data?.url || data.url,
|
||||
filename: selectedFile.name,
|
||||
size: selectedFile.size,
|
||||
uploaded_at: new Date().toISOString(),
|
||||
};
|
||||
setUploadedFiles([newFile, ...uploadedFiles]);
|
||||
setSelectedFile(null);
|
||||
alert("File uploaded successfully!");
|
||||
} else {
|
||||
const error = await response.text();
|
||||
alert("Upload failed: " + error);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Upload error:", error);
|
||||
alert("Network error");
|
||||
} finally {
|
||||
setIsUploading(false);
|
||||
}
|
||||
};
|
||||
|
||||
const copyToClipboard = (text: string) => {
|
||||
navigator.clipboard.writeText(text);
|
||||
alert("Copied to clipboard!");
|
||||
};
|
||||
|
||||
const formatFileSize = (bytes: number) => {
|
||||
if (bytes < 1024) return bytes + " B";
|
||||
if (bytes < 1024 * 1024) return (bytes / 1024).toFixed(2) + " KB";
|
||||
return (bytes / (1024 * 1024)).toFixed(2) + " MB";
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="min-h-screen bg-black text-white font-['Commit_Mono',monospace]">
|
||||
<div className="max-w-[1400px] mx-auto px-2 sm:px-4">
|
||||
{/* Header */}
|
||||
<div className="pt-6 pb-4 border-b border-gray-800">
|
||||
<div className="flex items-center justify-between">
|
||||
<div>
|
||||
<h1 className="text-xl sm:text-2xl font-bold text-[hsl(270,73%,63%)]">
|
||||
File Upload
|
||||
</h1>
|
||||
<p className="text-gray-500 text-xs sm:text-sm mt-1">
|
||||
Upload images and files
|
||||
</p>
|
||||
</div>
|
||||
<div className="flex gap-2 sm:gap-3">
|
||||
<button
|
||||
onClick={() => navigate("/admin")}
|
||||
className="px-3 py-1.5 sm:px-4 sm:py-2 border border-gray-700 rounded hover:border-[hsl(270,73%,63%)] transition-colors text-xs sm:text-sm"
|
||||
>
|
||||
Editor
|
||||
</button>
|
||||
<button
|
||||
onClick={() => {
|
||||
localStorage.removeItem("auth_token");
|
||||
navigate("/");
|
||||
}}
|
||||
className="px-3 py-1.5 sm:px-4 sm:py-2 border border-gray-700 rounded hover:border-red-500 hover:text-red-500 transition-colors text-xs sm:text-sm"
|
||||
>
|
||||
Logout
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="mt-6 grid grid-cols-1 lg:grid-cols-2 gap-6">
|
||||
{/* Upload Section */}
|
||||
<div>
|
||||
<h2 className="text-lg font-semibold mb-4">Upload New File</h2>
|
||||
<div
|
||||
className={`border-2 border-dashed rounded-lg p-8 text-center transition-all ${
|
||||
dragActive
|
||||
? "border-[hsl(270,73%,63%)] bg-[hsl(270,73%,63%)]/10"
|
||||
: "border-gray-700 hover:border-gray-600"
|
||||
}`}
|
||||
onDragEnter={handleDrag}
|
||||
onDragLeave={handleDrag}
|
||||
onDragOver={handleDrag}
|
||||
onDrop={handleDrop}
|
||||
>
|
||||
<div className="mb-4">
|
||||
<svg
|
||||
className="mx-auto h-12 w-12 text-gray-600"
|
||||
stroke="currentColor"
|
||||
fill="none"
|
||||
viewBox="0 0 48 48"
|
||||
>
|
||||
<path
|
||||
d="M28 8H12a4 4 0 00-4 4v20m32-12v8m0 0v8a4 4 0 01-4 4H12a4 4 0 01-4-4v-4m32-4l-3.172-3.172a4 4 0 00-5.656 0L28 28M8 32l9.172-9.172a4 4 0 015.656 0L28 28m0 0l4 4m4-24h8m-4-4v8m-12 4h.02"
|
||||
strokeWidth="2"
|
||||
strokeLinecap="round"
|
||||
strokeLinejoin="round"
|
||||
/>
|
||||
</svg>
|
||||
</div>
|
||||
|
||||
<div className="mb-4">
|
||||
{selectedFile ? (
|
||||
<div className="text-sm">
|
||||
<p className="font-medium text-[hsl(270,73%,63%)]">
|
||||
{selectedFile.name}
|
||||
</p>
|
||||
<p className="text-gray-500 mt-1">
|
||||
{formatFileSize(selectedFile.size)}
|
||||
</p>
|
||||
</div>
|
||||
) : (
|
||||
<>
|
||||
<p className="text-sm text-gray-400 mb-2">
|
||||
Drag and drop a file here, or click to select
|
||||
</p>
|
||||
<p className="text-xs text-gray-600">
|
||||
Supported: Images, Documents, Archives
|
||||
</p>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<input
|
||||
type="file"
|
||||
onChange={handleFileSelect}
|
||||
className="hidden"
|
||||
id="file-input"
|
||||
/>
|
||||
<label
|
||||
htmlFor="file-input"
|
||||
className="inline-block px-4 py-2 border border-gray-700 rounded hover:border-gray-600 transition-colors cursor-pointer text-sm"
|
||||
>
|
||||
Select File
|
||||
</label>
|
||||
</div>
|
||||
|
||||
{selectedFile && (
|
||||
<div className="mt-4 flex gap-3">
|
||||
<button
|
||||
onClick={handleUpload}
|
||||
disabled={isUploading}
|
||||
className="flex-1 px-6 py-3 bg-[hsl(270,73%,63%)] text-white rounded hover:bg-[hsl(270,73%,70%)] transition-colors disabled:opacity-50 disabled:cursor-not-allowed font-medium"
|
||||
>
|
||||
{isUploading ? "Uploading..." : "Upload File"}
|
||||
</button>
|
||||
<button
|
||||
onClick={() => setSelectedFile(null)}
|
||||
className="px-4 py-3 border border-gray-700 rounded hover:border-gray-600 transition-colors"
|
||||
>
|
||||
Clear
|
||||
</button>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Uploaded Files Section */}
|
||||
<div>
|
||||
<h2 className="text-lg font-semibold mb-4">
|
||||
Uploaded Files ({uploadedFiles.length})
|
||||
</h2>
|
||||
<div className="space-y-3 max-h-[600px] overflow-y-auto custom-scrollbar">
|
||||
{uploadedFiles.length === 0 ? (
|
||||
<div className="text-center py-12 text-gray-600">
|
||||
<p>No files uploaded yet</p>
|
||||
<p className="text-sm mt-2">Upload files to see them here</p>
|
||||
</div>
|
||||
) : (
|
||||
uploadedFiles.map((file, index) => (
|
||||
<div
|
||||
key={index}
|
||||
className="border border-gray-800 rounded-lg p-4 hover:border-gray-700 transition-colors"
|
||||
>
|
||||
<div className="flex items-start justify-between mb-2">
|
||||
<div className="flex-1 min-w-0">
|
||||
<p className="font-medium text-sm truncate">
|
||||
{file.filename}
|
||||
</p>
|
||||
<p className="text-xs text-gray-500 mt-1">
|
||||
{formatFileSize(file.size)} •{" "}
|
||||
{new Date(file.uploaded_at).toLocaleDateString()}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Preview if image */}
|
||||
{file.filename.match(/\.(jpg|jpeg|png|gif|webp)$/i) && (
|
||||
<img
|
||||
src={file.url}
|
||||
alt={file.filename}
|
||||
className="w-full h-32 object-cover rounded mt-3 mb-3 border border-gray-800"
|
||||
/>
|
||||
)}
|
||||
|
||||
<div className="space-y-2">
|
||||
{/* URL */}
|
||||
<div className="flex items-center gap-2">
|
||||
<input
|
||||
type="text"
|
||||
value={file.url}
|
||||
readOnly
|
||||
className="flex-1 bg-gray-900 border border-gray-800 rounded px-3 py-2 text-xs font-mono"
|
||||
/>
|
||||
<button
|
||||
onClick={() => copyToClipboard(file.url)}
|
||||
className="px-3 py-2 border border-gray-700 rounded hover:border-gray-600 transition-colors text-xs"
|
||||
>
|
||||
Copy
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{/* Markdown */}
|
||||
{file.filename.match(/\.(jpg|jpeg|png|gif|webp)$/i) && (
|
||||
<div className="flex items-center gap-2">
|
||||
<input
|
||||
type="text"
|
||||
value={``}
|
||||
readOnly
|
||||
className="flex-1 bg-gray-900 border border-gray-800 rounded px-3 py-2 text-xs font-mono"
|
||||
/>
|
||||
<button
|
||||
onClick={() =>
|
||||
copyToClipboard(
|
||||
``,
|
||||
)
|
||||
}
|
||||
className="px-3 py-2 border border-gray-700 rounded hover:border-gray-600 transition-colors text-xs"
|
||||
>
|
||||
MD
|
||||
</button>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
))
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style>{`
|
||||
.custom-scrollbar::-webkit-scrollbar {
|
||||
width: 6px;
|
||||
}
|
||||
.custom-scrollbar::-webkit-scrollbar-track {
|
||||
background: #111;
|
||||
}
|
||||
.custom-scrollbar::-webkit-scrollbar-thumb {
|
||||
background: #333;
|
||||
border-radius: 4px;
|
||||
}
|
||||
.custom-scrollbar::-webkit-scrollbar-thumb:hover {
|
||||
background: #444;
|
||||
}
|
||||
`}</style>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default Upload;
|
||||
@@ -5,4 +5,13 @@ import tailwindcss from "@tailwindcss/vite";
|
||||
// https://vite.dev/config/
|
||||
export default defineConfig({
|
||||
plugins: [react(), tailwindcss()],
|
||||
server: {
|
||||
proxy: {
|
||||
"/api": {
|
||||
target: "http://localhost:8080",
|
||||
changeOrigin: true,
|
||||
secure: false,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user