Beyhan Oğur 71eff2d979 first commit
2026-04-26 22:09:32 +03:00
2026-04-26 22:09:32 +03:00
2026-04-26 22:09:32 +03:00
2026-04-26 22:09:32 +03:00
2026-04-26 22:09:32 +03:00
2026-04-26 22:09:32 +03:00
2026-04-26 22:09:32 +03:00
2026-04-26 22:09:32 +03:00
2026-04-26 22:09:32 +03:00
2026-04-26 22:09:32 +03:00
2026-04-26 22:09:32 +03:00
2026-04-26 22:09:32 +03:00
2026-04-26 22:09:32 +03:00
2026-04-26 22:09:32 +03:00
2026-04-26 22:09:32 +03:00
2026-04-26 22:09:32 +03:00
2026-04-26 22:09:32 +03:00
2026-04-26 22:09:32 +03:00
2026-04-26 22:09:32 +03:00
2026-04-26 22:09:32 +03:00
2026-04-26 22:09:32 +03:00
2026-04-26 22:09:32 +03:00
2026-04-26 22:09:32 +03:00
2026-04-26 22:09:32 +03:00
2026-04-26 22:09:32 +03:00
2026-04-26 22:09:32 +03:00
2026-04-26 22:09:32 +03:00
2026-04-26 22:09:32 +03:00
2026-04-26 22:09:32 +03:00
2026-04-26 22:09:32 +03:00
2026-04-26 22:09:32 +03:00
2026-04-26 22:09:32 +03:00

Image Manipulation API

Modern, güvenli ve ölçeklenebilir resim yönetim ve manipülasyon platformu. Next.js 16, Better Auth ve Drizzle ORM ile geliştirilmiştir.

Özellikler

🔐 Güvenlik & Kimlik Doğrulama

  • Better Auth ile session tabanlı kimlik doğrulama
  • JWT destekli REST API (dış uygulamalar için)
  • Role-Based Access Control (RBAC) - 3 farklı rol (User, Moderator, Admin)
  • API Key yönetimi
  • Şifre hashleme (bcrypt)

🎨 Resim İşleme

  • Sharp kütüphanesi ile hızlı resim manipülasyonu
  • Boyutlandırma (width/height)
  • Format dönüştürme (JPEG, PNG, WebP, AVIF)
  • Kalite ayarı (1-100)
  • Otomatik dosya boyutu optimizasyonu

👥 Kullanıcı Yönetimi

  • Admin Panel - Kullanıcıları yönetme, rol atama, silme
  • Kullanıcı profili
  • Email doğrulama desteği
  • Kayıt açma/kapama kontrolü

📊 Rol ve İzinler

Rol İzinler
User Kendi resimlerini yükleyebilir, görüntüleyebilir ve silebilir
Moderator Tüm resimleri görüntüleyebilir ve silebilir
Admin Tüm moderator izinleri + Kullanıcı yönetimi

🚀 API Özellikleri

  • RESTful API tasarımı
  • JWT token authentication
  • API Key authentication
  • Rate limiting (opsiyonel)
  • Swagger-style dokümantasyon

📦 Teknolojiler

  • Framework: Next.js 16.1.1 (App Router, Turbopack)
  • Auth: better-auth v1.4.10
  • Database: PostgreSQL + Drizzle ORM v0.45.1
  • Image Processing: Sharp v0.34.5
  • Styling: Tailwind CSS v4
  • Container: Docker & Docker Compose
  • Runtime: Node.js v24.12.0

🛠️ Kurulum

1. Proje Klonlama

```bash git clone cd image-api ```

2. Ortam Değişkenleri

`.env` dosyası oluşturun: ```env DATABASE_URL=postgresql://user:password@localhost:5432/image_api BETTER_AUTH_SECRET=your-super-secret-key-min-32-chars BETTER_AUTH_URL=http://localhost:3000 NEXT_PUBLIC_APP_URL=http://localhost:3000 JWT_SECRET=another-super-secret-key-min-32-characters REGISTER_ENABLE=true ```

3. Docker ile Çalıştırma

```bash

PostgreSQL başlat

docker compose up -d postgres

Bağımlılıkları yükle

yarn install

Database migration

yarn db:push

Development server

yarn dev ```

4. İlk Admin Kullanıcısı

```bash

Kayıt ol

Sonra admin yap:

npx tsx make-admin.ts your-email@example.com ```

📚 API Kullanımı

Kayıt ve Login

```bash

Kayıt

curl -X POST http://localhost:3000/api/v1/auth/register \ -H "Content-Type: application/json" \ -d '{"email":"user@example.com","password":"password123","name":"John Doe"}'

Login

curl -X POST http://localhost:3000/api/v1/auth/login \ -H "Content-Type: application/json" \ -d '{"email":"user@example.com","password":"password123"}'

Response: {"success":true,"token":"jwt-token-here"}

```

Resim Yükleme

```bash curl -X POST http://localhost:3000/api/v1/images/upload \ -H "Authorization: Bearer YOUR_JWT_TOKEN" \ -F "file=@photo.jpg" \ -F "width=800" \ -F "quality=90" \ -F "format=webp" ```

Resim Listeleme

```bash

User: Sadece kendi resimleri

Moderator/Admin: Tüm resimler

curl http://localhost:3000/api/v1/images \ -H "Authorization: Bearer YOUR_JWT_TOKEN" ```

Admin - Kullanıcıları Listeleme

```bash curl http://localhost:3000/api/v1/admin/users \ -H "Authorization: Bearer ADMIN_JWT_TOKEN" ```

Admin - Rol Değiştirme

```bash curl -X PATCH http://localhost:3000/api/v1/admin/users/USER_ID/role \ -H "Authorization: Bearer ADMIN_JWT_TOKEN" \ -H "Content-Type: application/json" \ -d '{"role":"moderator"}' ```

Detaylı API dokümantasyonu: http://localhost:3000/api-docs

🎯 Sayfalar

  • `/` - Anasayfa
  • `/login` - Giriş yap
  • `/register` - Kayıt ol (REGISTER_ENABLE=true ise)
  • `/upload` - Resim yükle
  • `/profile` - Profil ve resimlerim
  • `/admin` - Admin panel (sadece adminler)
  • `/api-docs` - API dokümantasyonu

🔒 Güvenlik Özellikleri

  1. Password Hashing: bcrypt ile şifreler güvenle saklanır
  2. JWT Tokens: 7 günlük geçerlilik süresi
  3. Role-Based Access: Endpoint bazında yetkilendirme
  4. Session Management: Better Auth ile güvenli session yönetimi
  5. CORS: Yapılandırılabilir CORS desteği
  6. Environment Variables: Hassas bilgiler .env'de

📊 Database Schema

Tables

  • `user` - Kullanıcı bilgileri (email, password_hash, role)
  • `session` - Aktif oturumlar
  • `account` - OAuth provider hesapları
  • `verification` - Email doğrulama
  • `images` - Yüklenen resimler
  • `apiKeys` - API anahtarları

🐳 Docker Production Build

```bash

Build image

docker build -t image-api .

Run with docker-compose

docker compose up -d

Check logs

docker compose logs -f image-api ```

📝 Scripts

```bash yarn dev # Development server yarn build # Production build yarn start # Production server yarn lint # ESLint yarn db:generate # Generate migrations yarn db:push # Push schema to DB yarn db:studio # Drizzle Studio ```

🤝 Katkıda Bulunma

  1. Fork edin
  2. Feature branch oluşturun (`git checkout -b feature/amazing`)
  3. Commit edin (`git commit -m 'Add amazing feature'`)
  4. Push edin (`git push origin feature/amazing`)
  5. Pull Request açın

📄 Lisans

MIT

👨‍💻 Geliştirici

Beyhan Oğur - beyhan@beyhan.dev


Daha fazla bilgi için:

Description
No description provided
Readme 470 KiB
Languages
TypeScript 97.9%
Dockerfile 1.2%
JavaScript 0.4%
CSS 0.4%
Shell 0.1%