Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file removed .DS_Store
Binary file not shown.
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
GOOSE_DRIVER=postgres
GOOSE_DBSTRING=postgres://admin:admin@localhost:5433/blog
GOOSE_DBSTRING=postgres://postgres:password@localhost:5432/blog
GOOSE_MIGRATION_DIR=./migrations
1 change: 1 addition & 0 deletions internal/repo/.gitignore → .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@ go.work.sum

# --- PostgreSQL data ---
/db_data/
.DS_Store
15 changes: 15 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM golang:1.24-alpine

WORKDIR /app

COPY go.mod go.sum ./

RUN go mod download

COPY . .

RUN go build -o main .

EXPOSE 8080

CMD ["./main"]
11 changes: 11 additions & 0 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Задачи на проект

[ ] Придумать эндпоинты для полноценной работы блога (Update post, delete post, update comment...)
[ ] Реализовать их
[ ] Выставить там где надо мидлвари
[ ] Не забыть в слое сервиса например при обновлении поста проверять что пост принадлежит юзеру, который сделал запрос


### Общее
1. [ ] Добавить возможность отвечать на другие комментарии
2. [ ] Добавить Register и Log in и Refresh
30 changes: 30 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
services:
api:
build:
context: .
dockerfile: Dockerfile
ports:
- "8080:8088"
container_name: blog-api
depends_on:
- redis
- postgres

postgres:
image: postgres:15
container_name: blog-postgres
environment:
POSTGRES_DB: blog
POSTGRES_USER: postgres
POSTGRES_PASSWORD: password
volumes:
- postgres_data:/var/lib/postgresql/data

redis:
image: redis:7-alpine
container_name: blog-redis
restart: unless-stopped
command: redis-server --appendonly yes

volumes:
postgres_data:
10 changes: 10 additions & 0 deletions docs/endpoints.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
| Status | HTTP Method | Endpoint | Method Name | Description |
|--------|-------------|----------------------------------------|---------------------|-------------------------------------------|
| ✅ | POST | `/users/` | CreateUser | Создание нового пользователя |
| ✅ | GET | `/users/:id/` | GetUser | Получение информации о пользователе по ID |
| ✅ | GET | `/users/:id/posts/` | GetPostsByUserID | Получение списка всех постов пользователя |
| ✅ | POST | `/posts/` | CreatePost | Создание нового поста |
| ✅ | GET | `/posts/` | GetPosts | Получение списка всех постов |
| ✅ | GET | `/posts/:id/` | GetPost | Получение информации о посте по ID |
| ✅ | POST | `/posts/:id/comments?reply_to=231e119` | CreateComment | Создание комментария к посту |
| ⏳ | GET | `/posts/:id/comments/` | GetCommentsByPostID | Получение всех комментариев к посту |
31 changes: 14 additions & 17 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,40 +3,37 @@ module github.com/berduk-dev/blog
go 1.24.5

require (
github.com/gin-contrib/cors v1.7.6
github.com/gin-gonic/gin v1.10.1
github.com/go-redis/redis v6.15.9+incompatible
github.com/jackc/pgx/v5 v5.7.5
golang.org/x/crypto v0.41.0
)

require (
github.com/bytedance/sonic v1.11.6 // indirect
github.com/bytedance/sonic/loader v0.1.1 // indirect
github.com/cloudwego/base64x v0.1.4 // indirect
github.com/cloudwego/iasm v0.2.0 // indirect
github.com/gabriel-vasile/mimetype v1.4.3 // indirect
github.com/gin-contrib/sse v0.1.0 // indirect
github.com/bytedance/sonic v1.13.3 // indirect
github.com/bytedance/sonic/loader v0.2.4 // indirect
github.com/cloudwego/base64x v0.1.5 // indirect
github.com/gabriel-vasile/mimetype v1.4.9 // indirect
github.com/gin-contrib/sse v1.1.0 // 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.20.0 // indirect
github.com/goccy/go-json v0.10.2 // indirect
github.com/google/go-cmp v0.7.0 // indirect
github.com/go-playground/validator/v10 v10.26.0 // indirect
github.com/go-redis/redis v6.15.9+incompatible // indirect
github.com/goccy/go-json v0.10.5 // indirect
github.com/jackc/pgpassfile v1.0.0 // indirect
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/cpuid/v2 v2.2.7 // indirect
github.com/klauspost/cpuid/v2 v2.2.10 // 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/onsi/ginkgo v1.16.5 // indirect
github.com/onsi/gomega v1.38.2 // indirect
github.com/pelletier/go-toml/v2 v2.2.2 // indirect
github.com/pelletier/go-toml/v2 v2.2.4 // indirect
github.com/rogpeppe/go-internal v1.14.1 // indirect
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
github.com/ugorji/go/codec v1.2.12 // indirect
golang.org/x/arch v0.8.0 // indirect
golang.org/x/crypto v0.41.0 // indirect
github.com/ugorji/go/codec v1.3.0 // indirect
golang.org/x/arch v0.18.0 // indirect
golang.org/x/net v0.43.0 // indirect
golang.org/x/sys v0.35.0 // indirect
golang.org/x/text v0.28.0 // indirect
Expand Down
Loading