nextemos 4.0.4 → 4.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/helpers/cdn.d.ts
CHANGED
package/dist/helpers/cdn.js
CHANGED
|
@@ -3,12 +3,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const html_entities_1 = require("html-entities");
|
|
4
4
|
// Ortam değişkenlerinden CDN URL'si alınıyor, tanımlı değilse varsayılan olarak 'https://images.proj-e.com' kullanılıyor
|
|
5
5
|
const CDN_URL = process.env.CDN_URL || 'https://images.proj-e.com';
|
|
6
|
+
const VIDEO_CDN_URL = process.env.VIDEO_CDN_URL || CDN_URL;
|
|
6
7
|
// Ortam değişkenlerinden CDN sağlayıcısı alınıyor
|
|
7
8
|
const CDN_PROVIDER = process.env.CDN_PROVIDER;
|
|
8
9
|
// CDN işlemleri için kullanılan nesne
|
|
9
10
|
const cdn = {
|
|
10
11
|
// CDN URL'sini döndüren özellik
|
|
11
12
|
url: CDN_URL,
|
|
13
|
+
// Video CDN URL'sini döndüren özellik
|
|
14
|
+
videoUrl: VIDEO_CDN_URL,
|
|
12
15
|
// Thumbnail URL'si oluşturan fonksiyon
|
|
13
16
|
thumbImage: function (props) {
|
|
14
17
|
switch (CDN_PROVIDER) { // CDN sağlayıcısına göre işlemci fonksiyonunu seçiyor
|
|
@@ -23,6 +26,10 @@ const cdn = {
|
|
|
23
26
|
// CDN'deki dosyayı linkini getiren fonksiyon
|
|
24
27
|
getFile: function name(path = '') {
|
|
25
28
|
return `${this.url}/${encodeURI((0, html_entities_1.decode)(path))}`;
|
|
29
|
+
},
|
|
30
|
+
// CDN'deki video url'ini getiren fonksiyon
|
|
31
|
+
getVideo: function name(path = '') {
|
|
32
|
+
return `${this.videoUrl}/${encodeURI((0, html_entities_1.decode)(path))}`;
|
|
26
33
|
}
|
|
27
34
|
};
|
|
28
35
|
// Değerin geçerli olup olmadığını kontrol eden ve string olarak döndüren yardımcı fonksiyon
|
|
@@ -42,10 +42,6 @@ const fetchRequest = () => {
|
|
|
42
42
|
console.log(`Fetch Request: ${method} - ${apiURL} - ${JSON.stringify(options)}`);
|
|
43
43
|
try {
|
|
44
44
|
const response = yield fetch(apiURL.toString(), Object.assign(Object.assign({}, options), { method }));
|
|
45
|
-
if (!response.ok) {
|
|
46
|
-
const errorDetail = yield response.text();
|
|
47
|
-
throw new Error(`Fetch Request HTTP Error: ${response.status} - ${apiURL} - ${errorDetail}`);
|
|
48
|
-
}
|
|
49
45
|
// Headers nesnesini Object'e dönüştürme
|
|
50
46
|
const headers = {};
|
|
51
47
|
if (response === null || response === void 0 ? void 0 : response.headers) {
|
|
@@ -53,6 +49,15 @@ const fetchRequest = () => {
|
|
|
53
49
|
headers[name] = value;
|
|
54
50
|
});
|
|
55
51
|
}
|
|
52
|
+
if (!response.ok) {
|
|
53
|
+
const errorDetail = yield response.text();
|
|
54
|
+
return {
|
|
55
|
+
status: response.status,
|
|
56
|
+
errorMessage: errorDetail,
|
|
57
|
+
headers
|
|
58
|
+
};
|
|
59
|
+
// throw new Error(`Fetch Request HTTP Error: ${response.status} - ${apiURL} - ${errorDetail}`);
|
|
60
|
+
}
|
|
56
61
|
// response data nesnesini JSON'a dönüştürme.
|
|
57
62
|
const responseData = yield response.json().catch(() => ({}));
|
|
58
63
|
return {
|