4.6 KiB
4.6 KiB
Company Uygulaması API Entegrasyonu
Bu dokümantasyon, Company uygulamasına yapılan API entegrasyonu, üyelik sistemi, forum ve dinamik blog özelliklerini açıklamaktadır.
🚀 Yapılan Değişiklikler
1. API Entegrasyonu
- Axios ve React Query kullanılarak API yapısı kuruldu
- API servis katmanı oluşturuldu (
/src/services/api/) - Interceptor'lar ile otomatik token yönetimi eklendi
2. Üyelik Sistemi
- Zustand ile state management kuruldu
- Login ve Register sayfaları oluşturuldu
- JWT token tabanlı authentication sistemi entegre edildi
- Protected route yapısı kuruldu
3. Forum Sistemi
- Kapsamlı forum sayfası oluşturuldu
- Kategori, konu ve mesaj yönetimi
- Like, pin, lock gibi özellikler
- Etiket sistemi
4. Dinamik Blog
- Static blog yapısı dinamik hale getirildi
- Kategori filtreleme
- Arama özelliği
- Sayfalama (pagination)
- Etiket sistemi
📦 Yeni Eklenen Paketler
{
"axios": "^1.6.5",
"@tanstack/react-query": "^5.17.9",
"zustand": "^4.4.7",
"react-hook-form": "^7.48.2",
"date-fns": "^3.2.0",
"react-markdown": "^9.0.1",
"react-hot-toast": "^2.4.1"
}
🛠️ Kurulum
- Paketleri yükleyin:
cd company
npm install
- Environment değişkenlerini ayarlayın:
VITE_API_URL=http://localhost:44328
📁 Yeni Dosya Yapısı
company/src/
├── services/
│ └── api/
│ ├── config.ts # Axios yapılandırması
│ ├── auth.service.ts # Authentication servisi
│ ├── blog.service.ts # Blog API servisi
│ └── forum.service.ts # Forum API servisi
├── store/
│ └── authStore.ts # Zustand auth store
├── pages/
│ ├── Login.tsx # Giriş sayfası
│ ├── Register.tsx # Kayıt sayfası
│ ├── Forum.tsx # Forum ana sayfası
│ └── Blog.tsx # Dinamik blog sayfası (güncellendi)
└── components/
└── layout/
└── Header.tsx # Auth butonları eklendi
🔐 Authentication Akışı (UI Uygulaması ile Aynı)
- Kullanıcı login sayfasından giriş yapar
- OAuth2
/connect/tokenendpoint'i kullanılarak token alınır - Access token ve refresh token localStorage'a kaydedilir
/api/abp/application-configurationendpoint'inden kullanıcı bilgileri çekilir- Axios interceptor ile her istekte:
- Authorization header'a Bearer token eklenir
__tenantheader'a tenant ID eklenir (multi-tenancy desteği)
- Protected route'lar için authentication kontrolü yapılır
- Token expire olduğunda refresh token ile yenilenir
- Refresh token da expire olduysa otomatik logout
OAuth2 Parametreleri
- grant_type: password
- scope: offline_access Platform
- client_id: Platform_App
- client_secret: 1q2w3e*
🌟 Özellikler
Forum
- Kategori bazlı konu listeleme
- Yeni konu açma
- Konulara cevap yazma
- Like/Unlike
- Pin/Unpin (moderatör)
- Lock/Unlock (moderatör)
- Çözüldü olarak işaretleme
- Etiket sistemi
- Arama özelliği
Blog
- Dinamik içerik yönetimi
- Kategori filtreleme
- Arama
- Sayfalama
- Yorum sistemi
- Like sistemi
- Etiketler
🔄 API Endpoints
Authentication (UI ile Aynı Endpoint'ler)
POST /connect/token- OAuth2 token endpoint (Login & Refresh)POST /api/account/register- RegisterGET /api/abp/application-configuration- Current user & app config
Blog
GET /api/app/blog/posts- Blog listesiGET /api/app/blog/posts/:id- Blog detayGET /api/app/blog/categories- KategorilerPOST /api/app/blog/comments- Yorum ekle
Forum
GET /api/app/forum/categories- Forum kategorileriGET /api/app/forum/topics- Konu listesiPOST /api/app/forum/topics- Yeni konuGET /api/app/forum/topics/:id/posts- Konu mesajlarıPOST /api/app/forum/posts- Yeni mesaj
⚠️ Dikkat Edilmesi Gerekenler
- UI uygulaması ile aynı auth yapısı kullanılıyor - Aynı token'lar ve endpoint'ler
- Blog ve Forum API endpoint'leri henüz backend'de implement edilmemiş olabilir
- CORS ayarlarının yapılması gerekebilir (Company domain'i için)
- Production için environment değişkenlerinin güncellenmesi gerekir
- Error handling mekanizmaları geliştirilmeli
- Multi-tenancy desteği aktif - Tenant header'ı otomatik ekleniyor
🚧 Yapılacaklar
- Backend API endpoint'lerinin implement edilmesi
- Profil sayfası oluşturulması
- Forum moderasyon paneli
- Blog admin paneli
- Bildirim sistemi
- Real-time özellikler (WebSocket)
- Dosya yükleme sistemi
- Gelişmiş arama özellikleri