@source/cdn (1.3.3)
Published 2026-02-14 11:04:01 +00:00 by hibna
Installation
@source:registry=npm install @source/cdn@1.3.3"@source/cdn": "1.3.3"About this package
@source/cdn
Hibna CDN backend API'sini API key veya admin yetkisi ile kullanmak icin JavaScript/TypeScript SDK.
Kurulum
npm install @source/cdn
Kullanim
import { CdnClient } from '@source/cdn';
const client = new CdnClient({
baseUrl: 'https://cdn.hibna.com.tr',
apiKey: '<API_KEY>',
timeoutMs: 10_000,
retry: {
retries: 2,
retryDelayMs: 250,
},
});
const buckets = await client.listBuckets();
console.log(buckets);
Uzak Profil Isleme (FFmpeg + GPU otomatik)
SDK, uzak sunucuda FFmpeg ile profil uretip sonucu CDN'e geri yukleyebilir.
mp4-* profillerinde h264_nvenc + cuda destekleniyorsa GPU kullanir, destek yoksa otomatik CPU'ya duser.
import { CdnClient } from '@source/cdn';
const client = new CdnClient({
baseUrl: 'https://cdn.hibna.com.tr',
apiKey: '<API_KEY>',
});
const result = await client.executeRemoteOptimizationWithFfmpeg(
'<FILE_ID>',
['mp4-1080p', 'webm-720p', 'video-thumb'],
{
sourceTtlSeconds: 1800,
hardwareAcceleration: 'auto', // auto | gpu | cpu
ffmpegPath: 'ffmpeg',
},
);
console.log(result.hardwareAcceleration); // gpu | cpu | mixed
console.log(result.profileHardware); // profil bazli hangi mod kullanildi
Admin ve Audit islemleri
SDK artik admin endpointlerini de destekler.
import { CdnClient } from '@source/cdn';
const adminClient = new CdnClient({
baseUrl: 'https://cdn.hibna.com.tr',
adminToken: '<ADMIN_JWT>',
});
const stats = await adminClient.getAdminStats();
const apiKeys = await adminClient.listApiKeys();
const auditLogs = await adminClient.listAuditLogs({ page: 1, limit: 20 });
Alternatif olarak loginAdmin(...) ile cookie tabanli session alinabilir:
const adminClient = new CdnClient({ baseUrl: 'https://cdn.hibna.com.tr' });
await adminClient.loginAdmin('<ADMIN_PASSWORD>');
const session = await adminClient.getAdminSession();
Yayinlama (gits.hibna.com.tr)
- Hibna owner registry URL:
https://gits.hibna.com.tr/api/packages/hibna/npm/
- Auth bilgisini manuel girin (token veya mail/sifre):
npm login --registry https://gits.hibna.com.tr/api/packages/hibna/npm/ --scope=@source
- Publish komutunu calistirin:
PowerShell:
npm run sdk:publish:gits
Farkli owner registry gerekiyorsa:
$env:SDK_NPM_REGISTRY="https://gits.hibna.com.tr/api/packages/<owner>/npm/"
npm run sdk:publish:gits
Dry-run:
$env:SDK_NPM_DRY_RUN="true"
npm run sdk:publish:gits
Dependencies
Development Dependencies
| ID | Version |
|---|---|
| typescript | ^5.9.3 |