feat(api): public API POC — API-key auth + /api/v1 decode & OEM xref
Kapalı-beta public API temeli (rapor: api-widget-analizi-2026-07-03): - better-auth apiKey plugin (defaultPrefix sase_, enableMetadata, anahtar başına 120 istek/dk); enableSessionForAPIKeys KAPALI — anahtar dashboard oturumu yerine geçmez, cookie AuthGuard davranışı değişmez - apikeys tablosu (migration 0023, plugin şemasının birebir karşılığı) - ApiKeyGuard: Authorization Bearer / x-api-key → verifyApiKey → kullanıcı yüklenir (status kontrolü), request.user + request.apiKey doldurulur - /api/v1/vin/decode: mevcut slim kontrat + aday akışı; günlük başarılı-decode kotası (Redis, TR günü, aynı VIN idempotent; limit: key metadata dailyDecodeLimit → PUBLIC_API_DAILY_DECODE_LIMIT → 100) ve X-Decode-Quota-* header'ları - /api/v1/oem/:code: P çapraz-referans (kotasız) - internal/admin/api-keys: x-internal-token ile anahtar üret/listele/kapat (düz metin yalnız create cevabında) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
17
apps/api/src/public-api/public-api.module.ts
Normal file
17
apps/api/src/public-api/public-api.module.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import { Module } from "@nestjs/common";
|
||||
import { ApiKeyGuard } from "../common/guards/api-key.guard";
|
||||
import { PModule } from "../integrations/p/p.module";
|
||||
import { VehiclesModule } from "../vehicles/vehicles.module";
|
||||
import { PublicApiQuotaService } from "./public-api-quota.service";
|
||||
import { PublicApiController } from "./public-api.controller";
|
||||
|
||||
/**
|
||||
* Müşteri entegrasyonlarına açık Public API (/api/v1). Kimlik better-auth
|
||||
* apiKey plugin'i + ApiKeyGuard; iç servisler aynen yeniden kullanılır.
|
||||
*/
|
||||
@Module({
|
||||
imports: [VehiclesModule, PModule],
|
||||
controllers: [PublicApiController],
|
||||
providers: [ApiKeyGuard, PublicApiQuotaService],
|
||||
})
|
||||
export class PublicApiModule {}
|
||||
Reference in New Issue
Block a user