first commit
This commit is contained in:
72
yap.md
Normal file
72
yap.md
Normal file
@@ -0,0 +1,72 @@
|
||||
# GinImageAPI Kisa Teknik Ozet
|
||||
|
||||
## Proje Dizini (aktif)
|
||||
|
||||
```text
|
||||
ginimageApi/
|
||||
├── main.go
|
||||
├── go.mod
|
||||
├── app/
|
||||
│ ├── accounts/
|
||||
│ │ ├── handlers/user.go
|
||||
│ │ └── models/{accounts,token}.go
|
||||
│ └── middleware/{auth,security}.go
|
||||
├── configs/{db,redis}.go
|
||||
├── routers/router.go
|
||||
├── docs/{docs.go,swagger.json,swagger.yaml}
|
||||
├── app/images/{handlers,models}
|
||||
└── pkg/images/processor.go
|
||||
```
|
||||
|
||||
## Uygulama Baslangic Akisi
|
||||
|
||||
1. `.env` yuklenir (`godotenv`).
|
||||
2. `JWT_SECRET` kontrol edilir; bos ise uygulama fail-fast kapanir.
|
||||
3. `configs.ConnectDB()` ile DB baglantisi acilir.
|
||||
4. `configs.RunAutoMigrate()` modelleri uygular.
|
||||
5. `configs.SeedSecurityDefaults()` calisir.
|
||||
6. `configs.ConnectRedis()` ile Redis baglanir.
|
||||
7. Gin middleware zinciri calisir:
|
||||
- `DynamicCORS()`
|
||||
- `DynamicRateLimit()`
|
||||
8. `routers.Setup(r)` ile endpointler yuklenir.
|
||||
|
||||
## Auth ve Yetki Kurallari
|
||||
|
||||
- Access token formati: standart JWT (HS256)
|
||||
- Zorunlu claim kontrolleri: `iss`, `aud`, `nbf`, `exp`
|
||||
- `Authorization` header formati zorunludur: `Bearer <access_token>`
|
||||
- Legacy access token formatlari desteklenmez
|
||||
- `AuthRequired()` context'e sunlari yazar: `user_id`, `email`, `username`
|
||||
- `AdminRequired()` mutating methodlarda (`POST/PUT/PATCH/DELETE`) `users.is_admin` kontrolu yapar
|
||||
|
||||
## Route Gruplari
|
||||
|
||||
- Public auth: `/api/v1/auth/register`, `/api/v1/auth/login`, `/api/v1/auth/refresh`
|
||||
- Auth gerekli: `/api/v1/me`
|
||||
- Auth gerekli: `/api/v1/images/process`
|
||||
- Auth gerekli: `/api/v1/images`
|
||||
- Auth gerekli: `/api/v1/images/{id}`
|
||||
- Admin gerekli: `/api/v1/users/{id}/admin`
|
||||
- Swagger UI: `/swagger/index.html`
|
||||
|
||||
## Resim Isleme
|
||||
|
||||
- Endpoint: `POST /api/v1/images/process` (`multipart/form-data`)
|
||||
- Dosya alani: `file` (zorunlu)
|
||||
- Opsiyonel alanlar: `width`, `height`, `format`, `quality`, `cover`
|
||||
- Varsayilanlar:
|
||||
- `format`: `avif`
|
||||
- `quality`: `90`
|
||||
- `width`/`height` verilmezse boyutlar orijinal kalir (sifir deger)
|
||||
- Desteklenen formatlar: `avif`, `webp`, `png`, `jpg`/`jpeg`
|
||||
- Islenmis dosya fiziksel olarak `uploads/processed/` altina yazilir
|
||||
- DB'ye `images` tablosunda kayit atilir (`public_path`, `format`, `size`, `width`, `height`, `quality`)
|
||||
- Response JSON olarak `file_name`, `public_path` ve `url` bilgilerini doner
|
||||
|
||||
## Swagger
|
||||
|
||||
- Uretim komutu:
|
||||
- `swag init -g main.go -o docs`
|
||||
- UI:
|
||||
- `http://localhost:8080/swagger/index.html`
|
||||
Reference in New Issue
Block a user