nextemos 3.1.0 → 3.2.1
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/fetchRequest.js +19 -9
- package/dist/interfaces/response.d.ts +7 -0
- package/dist/services/banner/banner.types.d.ts +5 -1
- package/dist/services/banner/index.js +29 -13
- package/dist/services/blog/blog.types.d.ts +5 -1
- package/dist/services/blog/index.js +44 -21
- package/package.json +1 -1
|
@@ -46,6 +46,10 @@ const fetchRequest = () => {
|
|
|
46
46
|
logger_1.default.info(`Fetch Request: ${method} - ${apiURL} - ${JSON.stringify(Object.assign({ cache: 'no-cache' }, options))}`);
|
|
47
47
|
try {
|
|
48
48
|
const response = yield fetch(apiURL.toString(), Object.assign(Object.assign({ cache: 'no-cache' }, options), { method }));
|
|
49
|
+
if (!response.ok) {
|
|
50
|
+
const errorDetail = yield response.text();
|
|
51
|
+
throw new Error(`Fetch Request HTTP Error: ${response.status} - ${errorDetail}`);
|
|
52
|
+
}
|
|
49
53
|
// Headers nesnesini Object'e dönüştürme
|
|
50
54
|
const headers = {};
|
|
51
55
|
if (response === null || response === void 0 ? void 0 : response.headers) {
|
|
@@ -55,19 +59,25 @@ const fetchRequest = () => {
|
|
|
55
59
|
}
|
|
56
60
|
// response data nesnesini JSON'a dönüştürme.
|
|
57
61
|
const responseData = yield response.json().catch(() => ({}));
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
}
|
|
64
|
-
return { status: response.status, data: responseData, headers };
|
|
62
|
+
return {
|
|
63
|
+
status: response.status,
|
|
64
|
+
data: responseData,
|
|
65
|
+
headers
|
|
66
|
+
};
|
|
65
67
|
}
|
|
66
68
|
catch (error) {
|
|
67
|
-
logger_1.default.fatal(`Fetch Request Exception Error! -> ${error}`);
|
|
69
|
+
logger_1.default.fatal(`Fetch Request Exception Error! -> ${apiURL}: ${error}`);
|
|
70
|
+
if (error instanceof Error) {
|
|
71
|
+
return {
|
|
72
|
+
status: 500,
|
|
73
|
+
error: error.name,
|
|
74
|
+
errorMessage: error.message
|
|
75
|
+
};
|
|
76
|
+
}
|
|
68
77
|
return {
|
|
69
78
|
status: 500,
|
|
70
|
-
error: `${error}
|
|
79
|
+
error: `${error}`,
|
|
80
|
+
errorMessage: `${error}`
|
|
71
81
|
};
|
|
72
82
|
}
|
|
73
83
|
});
|
|
@@ -45,8 +45,15 @@ export interface IApiResponse<T = any> {
|
|
|
45
45
|
/**
|
|
46
46
|
* API çağrısı sırasında meydana gelen hata mesajı.
|
|
47
47
|
* Bu alan opsiyoneldir ve API çağrısı başarısız olduğunda kullanılır.
|
|
48
|
+
* Hata mesajının adını içerir
|
|
48
49
|
*/
|
|
49
50
|
error?: string;
|
|
51
|
+
/**
|
|
52
|
+
* API çağrısı sırasında meydana gelen hata mesajı.
|
|
53
|
+
* Bu alan opsiyoneldir ve API çağrısı başarısız olduğunda kullanılır.
|
|
54
|
+
* Hata mesajına dair detayları içerir
|
|
55
|
+
*/
|
|
56
|
+
errorMessage?: string;
|
|
50
57
|
/**
|
|
51
58
|
* HTTP durum kodu.
|
|
52
59
|
* Bu alan, API çağrısının HTTP durum kodunu belirtir (ör. 200, 404, 500).
|
|
@@ -54,7 +54,11 @@ export interface IBannerService {
|
|
|
54
54
|
* Service URL'i
|
|
55
55
|
*/
|
|
56
56
|
ServiceUrl: string;
|
|
57
|
-
GetURL: (isClient
|
|
57
|
+
GetURL: ({ isClient, language, methodName }: {
|
|
58
|
+
isClient?: boolean;
|
|
59
|
+
language?: string;
|
|
60
|
+
methodName: string;
|
|
61
|
+
}) => string;
|
|
58
62
|
/**
|
|
59
63
|
* Banner ID'sine göre banner al.
|
|
60
64
|
*/
|
|
@@ -27,10 +27,11 @@ exports.BannerService = {
|
|
|
27
27
|
* Bu servise ait local adres
|
|
28
28
|
*/
|
|
29
29
|
ServiceUrl: "http://banner.emosv2service.svc.cluster.local",
|
|
30
|
-
GetURL: function (isClient) {
|
|
30
|
+
GetURL: function ({ isClient = false, language = process.env.DEFAULT_LANGUAGE || "tr", methodName }) {
|
|
31
|
+
let url = this.ServiceUrl;
|
|
31
32
|
if (process.env.API_URL && (process.env.USE_API_URL === 'true' || isClient))
|
|
32
|
-
|
|
33
|
-
return
|
|
33
|
+
url = `${process.env.API_URL}/api/banner`;
|
|
34
|
+
return (url + methodName).replace(/{language}/g, language);
|
|
34
35
|
},
|
|
35
36
|
/**
|
|
36
37
|
* ID'ye göre banner al.
|
|
@@ -39,8 +40,11 @@ exports.BannerService = {
|
|
|
39
40
|
*/
|
|
40
41
|
GetBannerById: function (data, options) {
|
|
41
42
|
return __awaiter(this, void 0, void 0, function* () {
|
|
42
|
-
return yield (0, __1.fetchRequest)().get(
|
|
43
|
-
|
|
43
|
+
return yield (0, __1.fetchRequest)().get(this.GetURL({
|
|
44
|
+
isClient: options === null || options === void 0 ? void 0 : options.useClient,
|
|
45
|
+
language: data === null || data === void 0 ? void 0 : data.language,
|
|
46
|
+
methodName: urls_1.default.Banner.GetBannerById,
|
|
47
|
+
}), Object.assign(Object.assign({}, options), { params: data }));
|
|
44
48
|
});
|
|
45
49
|
},
|
|
46
50
|
/**
|
|
@@ -50,8 +54,11 @@ exports.BannerService = {
|
|
|
50
54
|
*/
|
|
51
55
|
GetBannerByName: function (data, options) {
|
|
52
56
|
return __awaiter(this, void 0, void 0, function* () {
|
|
53
|
-
return yield (0, __1.fetchRequest)().get(
|
|
54
|
-
|
|
57
|
+
return yield (0, __1.fetchRequest)().get(this.GetURL({
|
|
58
|
+
isClient: options === null || options === void 0 ? void 0 : options.useClient,
|
|
59
|
+
language: data === null || data === void 0 ? void 0 : data.language,
|
|
60
|
+
methodName: urls_1.default.Banner.GetBannerByName,
|
|
61
|
+
}), Object.assign(Object.assign({}, options), { params: data }));
|
|
55
62
|
});
|
|
56
63
|
},
|
|
57
64
|
/**
|
|
@@ -61,8 +68,11 @@ exports.BannerService = {
|
|
|
61
68
|
*/
|
|
62
69
|
GetBannerByKey: function (data, options) {
|
|
63
70
|
return __awaiter(this, void 0, void 0, function* () {
|
|
64
|
-
return yield (0, __1.fetchRequest)().get(
|
|
65
|
-
|
|
71
|
+
return yield (0, __1.fetchRequest)().get(this.GetURL({
|
|
72
|
+
isClient: options === null || options === void 0 ? void 0 : options.useClient,
|
|
73
|
+
language: data === null || data === void 0 ? void 0 : data.language,
|
|
74
|
+
methodName: urls_1.default.Banner.GetBannerByKey,
|
|
75
|
+
}), Object.assign(Object.assign({}, options), { params: data }));
|
|
66
76
|
});
|
|
67
77
|
},
|
|
68
78
|
/**
|
|
@@ -72,8 +82,11 @@ exports.BannerService = {
|
|
|
72
82
|
*/
|
|
73
83
|
GetBannerList: function (data, options) {
|
|
74
84
|
return __awaiter(this, void 0, void 0, function* () {
|
|
75
|
-
return yield (0, __1.fetchRequest)().get(
|
|
76
|
-
|
|
85
|
+
return yield (0, __1.fetchRequest)().get(this.GetURL({
|
|
86
|
+
isClient: options === null || options === void 0 ? void 0 : options.useClient,
|
|
87
|
+
language: data === null || data === void 0 ? void 0 : data.language,
|
|
88
|
+
methodName: urls_1.default.Banner.GetBannerList,
|
|
89
|
+
}), Object.assign(Object.assign({}, options), { params: data }));
|
|
77
90
|
});
|
|
78
91
|
},
|
|
79
92
|
/**
|
|
@@ -83,8 +96,11 @@ exports.BannerService = {
|
|
|
83
96
|
*/
|
|
84
97
|
GetBannerContainerList: function (data, options) {
|
|
85
98
|
return __awaiter(this, void 0, void 0, function* () {
|
|
86
|
-
return yield (0, __1.fetchRequest)().get(
|
|
87
|
-
|
|
99
|
+
return yield (0, __1.fetchRequest)().get(this.GetURL({
|
|
100
|
+
isClient: options === null || options === void 0 ? void 0 : options.useClient,
|
|
101
|
+
language: data === null || data === void 0 ? void 0 : data.language,
|
|
102
|
+
methodName: urls_1.default.Banner.GetBannerContainerList,
|
|
103
|
+
}), Object.assign(Object.assign({}, options), { params: data }));
|
|
88
104
|
});
|
|
89
105
|
},
|
|
90
106
|
};
|
|
@@ -108,7 +108,11 @@ export interface IBlogService {
|
|
|
108
108
|
* Service URL'i
|
|
109
109
|
*/
|
|
110
110
|
ServiceUrl: string;
|
|
111
|
-
GetURL: (isClient
|
|
111
|
+
GetURL: ({ isClient, language, methodName }: {
|
|
112
|
+
isClient?: boolean;
|
|
113
|
+
language?: string;
|
|
114
|
+
methodName: string;
|
|
115
|
+
}) => string;
|
|
112
116
|
/**
|
|
113
117
|
* Blog gönderilerini almak için istek fonksiyonu
|
|
114
118
|
*/
|
|
@@ -28,10 +28,11 @@ exports.BlogService = {
|
|
|
28
28
|
* Bu servise ait local adres
|
|
29
29
|
*/
|
|
30
30
|
ServiceUrl: "http://blog.emosv2service.svc.cluster.local",
|
|
31
|
-
GetURL: function (isClient) {
|
|
31
|
+
GetURL: function ({ isClient = false, language = process.env.DEFAULT_LANGUAGE || "tr", methodName }) {
|
|
32
|
+
let url = this.ServiceUrl;
|
|
32
33
|
if (process.env.API_URL && (process.env.USE_API_URL === 'true' || isClient))
|
|
33
|
-
|
|
34
|
-
return
|
|
34
|
+
url = `${process.env.API_URL}/api/blog`;
|
|
35
|
+
return (url + methodName).replace(/{language}/g, language);
|
|
35
36
|
},
|
|
36
37
|
/**
|
|
37
38
|
* Blog gönderilerini almak için istek fonksiyonu
|
|
@@ -41,10 +42,11 @@ exports.BlogService = {
|
|
|
41
42
|
*/
|
|
42
43
|
GetBlogPostsRequest: function () {
|
|
43
44
|
return __awaiter(this, arguments, void 0, function* (data = {}, options) {
|
|
44
|
-
return yield (0, __1.fetchRequest)().post(
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
45
|
+
return yield (0, __1.fetchRequest)().post(this.GetURL({
|
|
46
|
+
isClient: options === null || options === void 0 ? void 0 : options.useClient,
|
|
47
|
+
language: data === null || data === void 0 ? void 0 : data.language,
|
|
48
|
+
methodName: urls_1.default.Blog.GetBlogPostsRequest,
|
|
49
|
+
}), Object.assign(Object.assign({}, options), { body: JSON.stringify(data) }));
|
|
48
50
|
});
|
|
49
51
|
},
|
|
50
52
|
/**
|
|
@@ -55,8 +57,11 @@ exports.BlogService = {
|
|
|
55
57
|
*/
|
|
56
58
|
GetBlogPostRequest: function (data, options) {
|
|
57
59
|
return __awaiter(this, void 0, void 0, function* () {
|
|
58
|
-
return yield (0, __1.fetchRequest)().post(
|
|
59
|
-
|
|
60
|
+
return yield (0, __1.fetchRequest)().post(this.GetURL({
|
|
61
|
+
isClient: options === null || options === void 0 ? void 0 : options.useClient,
|
|
62
|
+
language: data === null || data === void 0 ? void 0 : data.language,
|
|
63
|
+
methodName: urls_1.default.Blog.GetBlogPostRequest,
|
|
64
|
+
}), Object.assign(Object.assign({}, options), { body: JSON.stringify(data) }));
|
|
60
65
|
});
|
|
61
66
|
},
|
|
62
67
|
/**
|
|
@@ -67,8 +72,11 @@ exports.BlogService = {
|
|
|
67
72
|
*/
|
|
68
73
|
GetBlogCategoriesRequest: function () {
|
|
69
74
|
return __awaiter(this, arguments, void 0, function* (data = {}, options) {
|
|
70
|
-
return yield (0, __1.fetchRequest)().post(
|
|
71
|
-
|
|
75
|
+
return yield (0, __1.fetchRequest)().post(this.GetURL({
|
|
76
|
+
isClient: options === null || options === void 0 ? void 0 : options.useClient,
|
|
77
|
+
language: data === null || data === void 0 ? void 0 : data.language,
|
|
78
|
+
methodName: urls_1.default.Blog.GetBlogCategoriesRequest,
|
|
79
|
+
}), Object.assign(Object.assign({}, options), { body: JSON.stringify(data) }));
|
|
72
80
|
});
|
|
73
81
|
},
|
|
74
82
|
/**
|
|
@@ -79,8 +87,11 @@ exports.BlogService = {
|
|
|
79
87
|
*/
|
|
80
88
|
GetBlogCategoryRequest: function (data, options) {
|
|
81
89
|
return __awaiter(this, void 0, void 0, function* () {
|
|
82
|
-
return yield (0, __1.fetchRequest)().post(
|
|
83
|
-
|
|
90
|
+
return yield (0, __1.fetchRequest)().post(this.GetURL({
|
|
91
|
+
isClient: options === null || options === void 0 ? void 0 : options.useClient,
|
|
92
|
+
language: data === null || data === void 0 ? void 0 : data.language,
|
|
93
|
+
methodName: urls_1.default.Blog.GetBlogCategoryRequest,
|
|
94
|
+
}), Object.assign(Object.assign({}, options), { body: JSON.stringify(data) }));
|
|
84
95
|
});
|
|
85
96
|
},
|
|
86
97
|
/**
|
|
@@ -91,8 +102,11 @@ exports.BlogService = {
|
|
|
91
102
|
*/
|
|
92
103
|
GetBlogCategoryHierarchyRequest: function (data, options) {
|
|
93
104
|
return __awaiter(this, void 0, void 0, function* () {
|
|
94
|
-
return yield (0, __1.fetchRequest)().post(
|
|
95
|
-
|
|
105
|
+
return yield (0, __1.fetchRequest)().post(this.GetURL({
|
|
106
|
+
isClient: options === null || options === void 0 ? void 0 : options.useClient,
|
|
107
|
+
language: data === null || data === void 0 ? void 0 : data.language,
|
|
108
|
+
methodName: urls_1.default.Blog.GetBlogCategoryHierarchyRequest,
|
|
109
|
+
}), Object.assign(Object.assign({}, options), { body: JSON.stringify(data) }));
|
|
96
110
|
});
|
|
97
111
|
},
|
|
98
112
|
/**
|
|
@@ -103,8 +117,11 @@ exports.BlogService = {
|
|
|
103
117
|
*/
|
|
104
118
|
GetBlogCategoryTreeRequest: function (data, options) {
|
|
105
119
|
return __awaiter(this, void 0, void 0, function* () {
|
|
106
|
-
return yield (0, __1.fetchRequest)().post(
|
|
107
|
-
|
|
120
|
+
return yield (0, __1.fetchRequest)().post(this.GetURL({
|
|
121
|
+
isClient: options === null || options === void 0 ? void 0 : options.useClient,
|
|
122
|
+
language: data === null || data === void 0 ? void 0 : data.language,
|
|
123
|
+
methodName: urls_1.default.Blog.GetBlogCategoryTreeRequest,
|
|
124
|
+
}), Object.assign(Object.assign({}, options), { body: JSON.stringify(data) }));
|
|
108
125
|
});
|
|
109
126
|
},
|
|
110
127
|
/**
|
|
@@ -115,8 +132,11 @@ exports.BlogService = {
|
|
|
115
132
|
*/
|
|
116
133
|
GetBlogTagRequest: function (data, options) {
|
|
117
134
|
return __awaiter(this, void 0, void 0, function* () {
|
|
118
|
-
return yield (0, __1.fetchRequest)().post(
|
|
119
|
-
|
|
135
|
+
return yield (0, __1.fetchRequest)().post(this.GetURL({
|
|
136
|
+
isClient: options === null || options === void 0 ? void 0 : options.useClient,
|
|
137
|
+
language: data === null || data === void 0 ? void 0 : data.language,
|
|
138
|
+
methodName: urls_1.default.Blog.GetBlogTagRequest,
|
|
139
|
+
}), Object.assign(Object.assign({}, options), { body: JSON.stringify(data) }));
|
|
120
140
|
});
|
|
121
141
|
},
|
|
122
142
|
/**
|
|
@@ -127,8 +147,11 @@ exports.BlogService = {
|
|
|
127
147
|
*/
|
|
128
148
|
GetBlogTagsRequest: function (data, options) {
|
|
129
149
|
return __awaiter(this, void 0, void 0, function* () {
|
|
130
|
-
return yield (0, __1.fetchRequest)().post(
|
|
131
|
-
|
|
150
|
+
return yield (0, __1.fetchRequest)().post(this.GetURL({
|
|
151
|
+
isClient: options === null || options === void 0 ? void 0 : options.useClient,
|
|
152
|
+
language: data === null || data === void 0 ? void 0 : data.language,
|
|
153
|
+
methodName: urls_1.default.Blog.GetBlogTagsRequest,
|
|
154
|
+
}), Object.assign(Object.assign({}, options), { body: JSON.stringify(data) }));
|
|
132
155
|
});
|
|
133
156
|
},
|
|
134
157
|
};
|