nextemos 3.0.9 → 3.2.0

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.
@@ -64,8 +64,11 @@ const fetchRequest = () => {
64
64
  return { status: response.status, data: responseData, headers };
65
65
  }
66
66
  catch (error) {
67
- logger_1.default.error(`Fetch Request Exception Error! -> ${error}`);
68
- return { status: 500, error: `Fetch Request Exception Error! -> ${error}` };
67
+ logger_1.default.fatal(`Fetch Request Exception Error! -> ${error}`);
68
+ return {
69
+ status: 500,
70
+ error: `${error}`
71
+ };
69
72
  }
70
73
  });
71
74
  /**
@@ -54,7 +54,11 @@ export interface IBannerService {
54
54
  * Service URL'i
55
55
  */
56
56
  ServiceUrl: string;
57
- GetURL: (isClient: boolean) => string;
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
- return process.env.API_URL;
33
- return this.ServiceUrl;
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((this.GetURL((options === null || options === void 0 ? void 0 : options.useClient) || false) + urls_1.default.Banner.GetBannerById)
43
- .replace(/{language}/g, (data === null || data === void 0 ? void 0 : data.language) || process.env.DEFAULT_LANGUAGE || "tr"), Object.assign(Object.assign({}, options), { params: data }));
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((this.GetURL((options === null || options === void 0 ? void 0 : options.useClient) || false) + urls_1.default.Banner.GetBannerByName)
54
- .replace(/{language}/g, (data === null || data === void 0 ? void 0 : data.language) || process.env.DEFAULT_LANGUAGE || "tr"), Object.assign(Object.assign({}, options), { params: data }));
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((this.GetURL((options === null || options === void 0 ? void 0 : options.useClient) || false) + urls_1.default.Banner.GetBannerByKey)
65
- .replace(/{language}/g, (data === null || data === void 0 ? void 0 : data.language) || process.env.DEFAULT_LANGUAGE || "tr"), Object.assign(Object.assign({}, options), { params: data }));
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((this.GetURL((options === null || options === void 0 ? void 0 : options.useClient) || false) + urls_1.default.Banner.GetBannerList)
76
- .replace(/{language}/g, (data === null || data === void 0 ? void 0 : data.language) || process.env.DEFAULT_LANGUAGE || "tr"), Object.assign(Object.assign({}, options), { params: data }));
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((this.GetURL((options === null || options === void 0 ? void 0 : options.useClient) || false) + urls_1.default.Banner.GetBannerContainerList)
87
- .replace(/{language}/g, (data === null || data === void 0 ? void 0 : data.language) || process.env.DEFAULT_LANGUAGE || "tr"), Object.assign(Object.assign({}, options), { params: data }));
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: boolean) => string;
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
- return process.env.API_URL;
34
- return this.ServiceUrl;
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
- // URL'deki {language} yer tutucusunu dil verisiyle değiştirir
46
- (this.GetURL((options === null || options === void 0 ? void 0 : options.useClient) || false) + urls_1.default.Blog.GetBlogPostsRequest)
47
- .replace(/{language}/g, (data === null || data === void 0 ? void 0 : data.language) || process.env.DEFAULT_LANGUAGE || "tr"), Object.assign(Object.assign({}, options), { body: JSON.stringify(data) }));
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((this.GetURL((options === null || options === void 0 ? void 0 : options.useClient) || false) + urls_1.default.Blog.GetBlogPostRequest)
59
- .replace(/{language}/g, (data === null || data === void 0 ? void 0 : data.language) || process.env.DEFAULT_LANGUAGE || "tr"), Object.assign(Object.assign({}, options), { body: JSON.stringify(data) }));
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((this.GetURL((options === null || options === void 0 ? void 0 : options.useClient) || false) + urls_1.default.Blog.GetBlogCategoriesRequest)
71
- .replace(/{language}/g, (data === null || data === void 0 ? void 0 : data.language) || process.env.DEFAULT_LANGUAGE || "tr"), Object.assign(Object.assign({}, options), { body: JSON.stringify(data) }));
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((this.GetURL((options === null || options === void 0 ? void 0 : options.useClient) || false) + urls_1.default.Blog.GetBlogCategoryRequest)
83
- .replace(/{language}/g, (data === null || data === void 0 ? void 0 : data.language) || process.env.DEFAULT_LANGUAGE || "tr"), Object.assign(Object.assign({}, options), { body: JSON.stringify(data) }));
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((this.GetURL((options === null || options === void 0 ? void 0 : options.useClient) || false) + urls_1.default.Blog.GetBlogCategoryHierarchyRequest)
95
- .replace(/{language}/g, (data === null || data === void 0 ? void 0 : data.language) || process.env.DEFAULT_LANGUAGE || "tr"), Object.assign(Object.assign({}, options), { body: JSON.stringify(data) }));
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((this.GetURL((options === null || options === void 0 ? void 0 : options.useClient) || false) + urls_1.default.Blog.GetBlogCategoryTreeRequest)
107
- .replace(/{language}/g, (data === null || data === void 0 ? void 0 : data.language) || process.env.DEFAULT_LANGUAGE || "tr"), Object.assign(Object.assign({}, options), { body: JSON.stringify(data) }));
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((this.GetURL((options === null || options === void 0 ? void 0 : options.useClient) || false) + urls_1.default.Blog.GetBlogTagRequest)
119
- .replace(/{language}/g, (data === null || data === void 0 ? void 0 : data.language) || process.env.DEFAULT_LANGUAGE || "tr"), Object.assign(Object.assign({}, options), { body: JSON.stringify(data) }));
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((this.GetURL((options === null || options === void 0 ? void 0 : options.useClient) || false) + urls_1.default.Blog.GetBlogTagsRequest)
131
- .replace(/{language}/g, (data === null || data === void 0 ? void 0 : data.language) || process.env.DEFAULT_LANGUAGE || "tr"), Object.assign(Object.assign({}, options), { body: JSON.stringify(data) }));
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
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nextemos",
3
- "version": "3.0.9",
3
+ "version": "3.2.0",
4
4
  "description": "For helpers and hooks used in NextJS projects",
5
5
  "main": "dist/index.js",
6
6
  "types": "./dist/index.d.ts",