nextemos 2.3.9 → 3.0.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/README.md +82 -12
- package/dist/helpers/fetchRequest.d.ts +4 -4
- package/dist/helpers/fetchRequest.js +13 -6
- package/dist/helpers/logger.d.ts +2 -0
- package/dist/helpers/logger.js +10 -0
- package/dist/interfaces/response.d.ts +9 -2
- package/dist/services/banner/banner.types.d.ts +11 -6
- package/dist/services/banner/index.d.ts +4 -0
- package/dist/services/banner/index.js +43 -15
- package/dist/services/blog/blog.types.d.ts +14 -9
- package/dist/services/blog/index.d.ts +6 -0
- package/dist/services/blog/index.js +65 -27
- package/dist/services/urls.js +13 -14
- package/dist/test.js +1 -1
- package/package.json +5 -2
package/README.md
CHANGED
|
@@ -1,19 +1,89 @@
|
|
|
1
|
-
# Custom Hooks and Helpers
|
|
2
1
|
|
|
3
|
-
|
|
2
|
+
# nextemos
|
|
4
3
|
|
|
5
|
-
|
|
4
|
+
|
|
6
5
|
|
|
7
|
-
|
|
8
|
-
- [Usage](#usage)
|
|
9
|
-
- [Hooks](#hooks)
|
|
10
|
-
- [Helpers](#helpers)
|
|
11
|
-
- [Contributing](#contributing)
|
|
12
|
-
- [License](#license)
|
|
6
|
+
nextemos, PROJE INC. projeleri için TypeScript type ve interface'leri, API'lerle iletişim kurmak için bir servis katmanı ve genel helper ve hook'ları içeren özel bir NPM paketidir. Bu paket, projelerinizde kodunuzu daha modüler ve yeniden kullanılabilir hale getirmeyi amaçlar.
|
|
13
7
|
|
|
14
|
-
##
|
|
8
|
+
## Kurulum
|
|
15
9
|
|
|
16
|
-
|
|
10
|
+
`nextemos` paketini projenize eklemek için aşağıdaki komutu kullanabilirsiniz:
|
|
17
11
|
|
|
18
12
|
```bash
|
|
19
|
-
|
|
13
|
+
|
|
14
|
+
npm install nextemos
|
|
15
|
+
|
|
16
|
+
````
|
|
17
|
+
|
|
18
|
+
veya
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
|
|
22
|
+
yarn add nextemos
|
|
23
|
+
|
|
24
|
+
````
|
|
25
|
+
|
|
26
|
+
## Kullanım
|
|
27
|
+
|
|
28
|
+
### Type ve Interface'ler
|
|
29
|
+
|
|
30
|
+
nextemos paketi, projelerinizde kullanabileceğiniz çeşitli TypeScript type ve interface'leri sağlar. Bu type ve interface'ler, kodunuzun daha tip güvenli ve okunabilir olmasını sağlar.
|
|
31
|
+
|
|
32
|
+
### Servis Katmanı
|
|
33
|
+
|
|
34
|
+
API'lerle iletişim kurmak için bir servis katmanı içerir. Bu katman, API isteklerinizi yönetir ve tekrar eden kodları ortadan kaldırarak daha temiz bir yapı sağlar. Örneğin:
|
|
35
|
+
|
|
36
|
+
```typescript
|
|
37
|
+
...
|
|
38
|
+
import { Service } from 'nextemos';
|
|
39
|
+
|
|
40
|
+
// server component (async)
|
|
41
|
+
export default async function Home() {
|
|
42
|
+
|
|
43
|
+
// istekler async-await olarak yapılmalıdır
|
|
44
|
+
const { data, status, error } = await Service.Banner.GetBannerList(
|
|
45
|
+
{ bannerKeys: ["slider"] },
|
|
46
|
+
{ cache: 'force-cache' } // opsiyonel
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
if (status !== 200) return;
|
|
50
|
+
|
|
51
|
+
return <SliderComponent data={data} />;
|
|
52
|
+
}
|
|
53
|
+
````
|
|
54
|
+
|
|
55
|
+
### Helper ve Hook'lar
|
|
56
|
+
|
|
57
|
+
nextemos paketi, genel helper ve hook'lar da içerir. Bu helper ve hook'lar, projelerinizde sıkça karşılaşılan görevleri basitleştirir. Örneğin:
|
|
58
|
+
|
|
59
|
+
```typescript
|
|
60
|
+
...
|
|
61
|
+
import { useFetch } from 'nextemos';
|
|
62
|
+
|
|
63
|
+
export default function ProductList() {
|
|
64
|
+
const { response, loading, error } = useFetch({
|
|
65
|
+
url: '/tr/api/product/getProductList'
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
## Environment Değişkenleri
|
|
72
|
+
|
|
73
|
+
nextemos paketi, belirli environment değişkenlerini kullanır. Bu değişkenler, paketinizin yapılandırmasını ve çalışma şeklini etkiler:
|
|
74
|
+
|
|
75
|
+
- `API_URL`: API isteklerinizin yapılacağı temel URL'yi belirtir. Bu, projenizin hangi sunucuya istek göndereceğini belirler.
|
|
76
|
+
- `DEFAULT_LANGUAGE`: Uygulamanızın varsayılan dilini belirler. Çok dilli projelerde kullanışlıdır. API isteklerinde dil parametresi gönderilmezse bu değer varsayılan kabul edilecektir.
|
|
77
|
+
- `USE_API_URL`: `API_URL`nin kullanılıp kullanılmayacağını belirler. Bu, Microservis mimaride servislerin iletişimi için doğrudan servisler arası iletişim yerine dışarıdan bir API URL ile erişilmek istenildiğinde kullanılmalıdır. Varsayılan değeri `false`.
|
|
78
|
+
|
|
79
|
+
### Örnek .env Dosyası
|
|
80
|
+
|
|
81
|
+
Paketinizi kullanırken gerekli environment değişkenlerini ayarlamak için projenizin kök dizininde bir `.env` dosyası oluşturabilirsiniz:
|
|
82
|
+
|
|
83
|
+
```dotenv
|
|
84
|
+
API_URL=https://api.example.com
|
|
85
|
+
DEFAULT_LANGUAGE=en
|
|
86
|
+
USE_API_URL=true
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
Bu environment değişkenlerini kullanarak nextemos paketinizin davranışını özelleştirebilirsiniz.
|
|
@@ -4,9 +4,9 @@ import { IApiResponse, IRequestOptions } from '../';
|
|
|
4
4
|
* @returns {object} İstek yapmak için yöntemlere sahip HTTP istemcisi.
|
|
5
5
|
*/
|
|
6
6
|
declare const fetchRequest: () => {
|
|
7
|
-
get: <T>(url: string, options: Omit<IRequestOptions,
|
|
8
|
-
post: <
|
|
9
|
-
put: <
|
|
10
|
-
delete: <
|
|
7
|
+
get: <T>(url: string, options: Omit<IRequestOptions, "url" | "method">) => Promise<IApiResponse<T>>;
|
|
8
|
+
post: <T>(url: string, options: Omit<IRequestOptions, "url" | "method">) => Promise<IApiResponse<T>>;
|
|
9
|
+
put: <T>(url: string, options: Omit<IRequestOptions, "url" | "method">) => Promise<IApiResponse<T>>;
|
|
10
|
+
delete: <T>(url: string, options: Omit<IRequestOptions, "url" | "method">) => Promise<IApiResponse<T>>;
|
|
11
11
|
};
|
|
12
12
|
export default fetchRequest;
|
|
@@ -19,7 +19,11 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
19
19
|
}
|
|
20
20
|
return t;
|
|
21
21
|
};
|
|
22
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
23
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
24
|
+
};
|
|
22
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
const logger_1 = __importDefault(require("./logger"));
|
|
23
27
|
const __1 = require("../");
|
|
24
28
|
/**
|
|
25
29
|
* İstek yapmak için bir HTTP istemcisi oluşturur.
|
|
@@ -34,31 +38,34 @@ const fetchRequest = () => {
|
|
|
34
38
|
*/
|
|
35
39
|
const request = (_a) => __awaiter(void 0, void 0, void 0, function* () {
|
|
36
40
|
var { url, method, params } = _a, options = __rest(_a, ["url", "method", "params"]);
|
|
37
|
-
const apiURL = new URL(url);
|
|
41
|
+
const apiURL = new URL(url);
|
|
38
42
|
if (params)
|
|
39
43
|
Object.keys(params).forEach(key => apiURL.searchParams.append(key, params[key]));
|
|
40
44
|
if (method === __1.HTTPMethod.POST)
|
|
41
45
|
options.headers = Object.assign(Object.assign({}, options.headers), { ['Content-Type']: 'application/json' });
|
|
46
|
+
logger_1.default.debug(`Fetch Request: ${method} - ${apiURL} - ${JSON.stringify(Object.assign({ cache: 'no-cache' }, options))}`);
|
|
42
47
|
try {
|
|
43
|
-
const response = yield fetch(apiURL.toString(), Object.assign(Object.assign({}, options), { method }));
|
|
48
|
+
const response = yield fetch(apiURL.toString(), Object.assign(Object.assign({ cache: 'no-cache' }, options), { method }));
|
|
44
49
|
// Headers nesnesini Object'e dönüştürme
|
|
45
50
|
const headers = {};
|
|
46
|
-
if (response.headers) {
|
|
51
|
+
if (response === null || response === void 0 ? void 0 : response.headers) {
|
|
47
52
|
response.headers.forEach((value, name) => {
|
|
48
53
|
headers[name] = value;
|
|
49
54
|
});
|
|
50
55
|
}
|
|
51
56
|
// response data nesnesini JSON'a dönüştürme.
|
|
52
57
|
const responseData = yield response.json().catch(() => ({}));
|
|
58
|
+
logger_1.default.debug(`Fetch Response: ${JSON.stringify(responseData)}`);
|
|
53
59
|
if (!response.ok) {
|
|
54
|
-
const errorMessage = (responseData === null || responseData === void 0 ? void 0 : responseData.message) || 'Bir şeyler
|
|
55
|
-
|
|
60
|
+
const errorMessage = (responseData === null || responseData === void 0 ? void 0 : responseData.message) || 'Bir şeyler ters gitti!';
|
|
61
|
+
logger_1.default.error(`Fetch Request Error: ${response.status} - ${errorMessage}`);
|
|
56
62
|
return { status: response.status, error: errorMessage, headers };
|
|
57
63
|
}
|
|
58
64
|
return { status: response.status, data: responseData, headers };
|
|
59
65
|
}
|
|
60
66
|
catch (error) {
|
|
61
|
-
|
|
67
|
+
logger_1.default.error(`Fetch Request Exception Error! -> ${error}`);
|
|
68
|
+
return { status: 500, error: `Fetch Request Exception Error! -> ${error}` };
|
|
62
69
|
}
|
|
63
70
|
});
|
|
64
71
|
/**
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const pino_1 = __importDefault(require("pino"));
|
|
7
|
+
const logger = (0, pino_1.default)({
|
|
8
|
+
level: process.env.NODE_ENV === 'development' ? 'debug' : 'silent'
|
|
9
|
+
});
|
|
10
|
+
exports.default = logger;
|
|
@@ -19,10 +19,17 @@ export interface IRequestOptions extends RequestInit {
|
|
|
19
19
|
* İsteğe bağlı olarak gönderilecek parametreler.
|
|
20
20
|
*/
|
|
21
21
|
params?: Record<string, any>;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* IRequestInıt arayüzü, Servis isteklerinde gönderilmek istenen ayarları içermelidir.
|
|
25
|
+
*/
|
|
26
|
+
export interface IRequestInit extends RequestInit {
|
|
22
27
|
/**
|
|
23
|
-
* Bu alan istek
|
|
28
|
+
* Bu alan istek yaparken API URL kullanılacaksa 'true' gönderilmelidir, Default false ayarı isteklerin servisler arası iletişim kurmasını sağlar.
|
|
29
|
+
* Environment olarak "USE_API_URL" ayarı 'true' ise bu parametreyi göndermeye gerek kalmaz
|
|
30
|
+
* @default false
|
|
24
31
|
*/
|
|
25
|
-
|
|
32
|
+
useClient?: boolean;
|
|
26
33
|
}
|
|
27
34
|
/**
|
|
28
35
|
* APIResponse arayüzü, genel API yanıtlarını temsil eder.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IApiResponse, IBannerContainersResponse, IBannerResponse, IBannersResponse } from '../..';
|
|
1
|
+
import { IApiResponse, IBannerContainersResponse, IBannerResponse, IBannersResponse, IRequestInit } from '../..';
|
|
2
2
|
/**
|
|
3
3
|
* Banner ID'sine göre banner alma isteği arayüzü.
|
|
4
4
|
*/
|
|
@@ -50,25 +50,30 @@ interface IGetBannerContainerListRequest {
|
|
|
50
50
|
* Banner hizmetleri arayüzü.
|
|
51
51
|
*/
|
|
52
52
|
export interface IBannerService {
|
|
53
|
+
/**
|
|
54
|
+
* Service URL'i
|
|
55
|
+
*/
|
|
56
|
+
ServiceUrl: string;
|
|
57
|
+
GetURL: (isClient: boolean) => string;
|
|
53
58
|
/**
|
|
54
59
|
* Banner ID'sine göre banner al.
|
|
55
60
|
*/
|
|
56
|
-
GetBannerById: (data: IGetBannerByIdRequest, options?:
|
|
61
|
+
GetBannerById: (data: IGetBannerByIdRequest, options?: IRequestInit) => Promise<IApiResponse<IBannerResponse>>;
|
|
57
62
|
/**
|
|
58
63
|
* Banner ismine göre banner al.
|
|
59
64
|
*/
|
|
60
|
-
GetBannerByName: (data: IGetBannerByNameRequest, options?:
|
|
65
|
+
GetBannerByName: (data: IGetBannerByNameRequest, options?: IRequestInit) => Promise<IApiResponse<IBannerResponse>>;
|
|
61
66
|
/**
|
|
62
67
|
* Banner anahtarına göre banner al.
|
|
63
68
|
*/
|
|
64
|
-
GetBannerByKey: (data: IGetBannerByKeyRequest, options?:
|
|
69
|
+
GetBannerByKey: (data: IGetBannerByKeyRequest, options?: IRequestInit) => Promise<IApiResponse<IBannerResponse>>;
|
|
65
70
|
/**
|
|
66
71
|
* Banner listesini al.
|
|
67
72
|
*/
|
|
68
|
-
GetBannerList: (data?: IGetBannerListRequest, options?:
|
|
73
|
+
GetBannerList: (data?: IGetBannerListRequest, options?: IRequestInit) => Promise<IApiResponse<IBannersResponse>>;
|
|
69
74
|
/**
|
|
70
75
|
* Banner konteyner listesini al.
|
|
71
76
|
*/
|
|
72
|
-
GetBannerContainerList: (data?: IGetBannerContainerListRequest, options?:
|
|
77
|
+
GetBannerContainerList: (data?: IGetBannerContainerListRequest, options?: IRequestInit) => Promise<IApiResponse<IBannerContainersResponse>>;
|
|
73
78
|
}
|
|
74
79
|
export {};
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { IBannerService } from './banner.types';
|
|
2
2
|
/**
|
|
3
3
|
* Banner servisi, banner ve banner konteyner verilerini alır.
|
|
4
|
+
* @description
|
|
5
|
+
* Microservice Kubernates içerisinden doğrudan iletişim sağlanabilmesi için aşağıdaki adresi kullanmalıdır.
|
|
6
|
+
* <service-name>.<namespace>.svc.cluster.local:<service-port>
|
|
7
|
+
* http://banner.emosv2service.svc.cluster.local
|
|
4
8
|
*/
|
|
5
9
|
export declare const BannerService: IBannerService;
|
|
@@ -17,46 +17,74 @@ const urls_1 = __importDefault(require("../urls"));
|
|
|
17
17
|
const __1 = require("../..");
|
|
18
18
|
/**
|
|
19
19
|
* Banner servisi, banner ve banner konteyner verilerini alır.
|
|
20
|
+
* @description
|
|
21
|
+
* Microservice Kubernates içerisinden doğrudan iletişim sağlanabilmesi için aşağıdaki adresi kullanmalıdır.
|
|
22
|
+
* <service-name>.<namespace>.svc.cluster.local:<service-port>
|
|
23
|
+
* http://banner.emosv2service.svc.cluster.local
|
|
20
24
|
*/
|
|
21
25
|
exports.BannerService = {
|
|
26
|
+
/**
|
|
27
|
+
* Bu servise ait local adres
|
|
28
|
+
*/
|
|
29
|
+
ServiceUrl: "http://banner.emosv2service.svc.cluster.local",
|
|
30
|
+
GetURL: function (isClient) {
|
|
31
|
+
if (process.env.API_URL && (process.env.USE_API_URL === 'true' || isClient))
|
|
32
|
+
return process.env.API_URL;
|
|
33
|
+
return this.ServiceUrl;
|
|
34
|
+
},
|
|
22
35
|
/**
|
|
23
36
|
* ID'ye göre banner al.
|
|
24
37
|
* @param data - Banner ID'si ve dil bilgisi.
|
|
25
38
|
* @param options - İsteğe bağlı ek seçenekler.
|
|
26
39
|
*/
|
|
27
|
-
GetBannerById: (data, options)
|
|
28
|
-
return
|
|
29
|
-
|
|
40
|
+
GetBannerById: function (data, options) {
|
|
41
|
+
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 }));
|
|
44
|
+
});
|
|
45
|
+
},
|
|
30
46
|
/**
|
|
31
47
|
* İsme göre banner al.
|
|
32
48
|
* @param data - Banner ismi ve dil bilgisi.
|
|
33
49
|
* @param options - İsteğe bağlı ek seçenekler.
|
|
34
50
|
*/
|
|
35
|
-
GetBannerByName: (data, options)
|
|
36
|
-
return
|
|
37
|
-
|
|
51
|
+
GetBannerByName: function (data, options) {
|
|
52
|
+
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 }));
|
|
55
|
+
});
|
|
56
|
+
},
|
|
38
57
|
/**
|
|
39
58
|
* Anahtara göre banner al.
|
|
40
59
|
* @param data - Banner anahtarı ve dil bilgisi.
|
|
41
60
|
* @param options - İsteğe bağlı ek seçenekler.
|
|
42
61
|
*/
|
|
43
|
-
GetBannerByKey: (data, options)
|
|
44
|
-
return
|
|
45
|
-
|
|
62
|
+
GetBannerByKey: function (data, options) {
|
|
63
|
+
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 }));
|
|
66
|
+
});
|
|
67
|
+
},
|
|
46
68
|
/**
|
|
47
69
|
* Banner listesini al.
|
|
48
70
|
* @param data - Banner filtreleme kriterleri ve dil bilgisi.
|
|
49
71
|
* @param options - İsteğe bağlı ek seçenekler.
|
|
50
72
|
*/
|
|
51
|
-
GetBannerList: (data, options)
|
|
52
|
-
return
|
|
53
|
-
|
|
73
|
+
GetBannerList: function (data, options) {
|
|
74
|
+
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 }));
|
|
77
|
+
});
|
|
78
|
+
},
|
|
54
79
|
/**
|
|
55
80
|
* Banner konteyner listesini al.
|
|
56
81
|
* @param data - Banner konteyner filtreleme kriterleri ve dil bilgisi.
|
|
57
82
|
* @param options - İsteğe bağlı ek seçenekler.
|
|
58
83
|
*/
|
|
59
|
-
GetBannerContainerList: (data, options)
|
|
60
|
-
return
|
|
61
|
-
|
|
84
|
+
GetBannerContainerList: function (data, options) {
|
|
85
|
+
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 }));
|
|
88
|
+
});
|
|
89
|
+
},
|
|
62
90
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IApiResponse, IBlogPostResponse, IBlogPostsResponse, IGetBlogCategoriesResponse, IGetBlogCategoryHierarchyResponse, IGetBlogCategoryResponse, IGetBlogCategoryTreeResponse, IGetBlogTagResponse, IGetBlogTagsResponse } from '../..';
|
|
1
|
+
import { IApiResponse, IBlogPostResponse, IBlogPostsResponse, IGetBlogCategoriesResponse, IGetBlogCategoryHierarchyResponse, IGetBlogCategoryResponse, IGetBlogCategoryTreeResponse, IGetBlogTagResponse, IGetBlogTagsResponse, IRequestInit } from '../..';
|
|
2
2
|
/**
|
|
3
3
|
* Aggregation filtreleme için arayüz
|
|
4
4
|
*/
|
|
@@ -104,37 +104,42 @@ interface IGetBlogTagRequest {
|
|
|
104
104
|
* Blog servis arayüzü
|
|
105
105
|
*/
|
|
106
106
|
export interface IBlogService {
|
|
107
|
+
/**
|
|
108
|
+
* Service URL'i
|
|
109
|
+
*/
|
|
110
|
+
ServiceUrl: string;
|
|
111
|
+
GetURL: (isClient: boolean) => string;
|
|
107
112
|
/**
|
|
108
113
|
* Blog gönderilerini almak için istek fonksiyonu
|
|
109
114
|
*/
|
|
110
|
-
GetBlogPostsRequest: (data?: IGetBlogPostsRequest, options?:
|
|
115
|
+
GetBlogPostsRequest: (data?: IGetBlogPostsRequest, options?: IRequestInit) => Promise<IApiResponse<IBlogPostsResponse>>;
|
|
111
116
|
/**
|
|
112
117
|
* Tek bir blog gönderisini almak için istek fonksiyonu
|
|
113
118
|
*/
|
|
114
|
-
GetBlogPostRequest: (data: IGetBlogPostRequest, options?:
|
|
119
|
+
GetBlogPostRequest: (data: IGetBlogPostRequest, options?: IRequestInit) => Promise<IApiResponse<IBlogPostResponse>>;
|
|
115
120
|
/**
|
|
116
121
|
* Blog kategorilerini almak için istek fonksiyonu
|
|
117
122
|
*/
|
|
118
|
-
GetBlogCategoriesRequest: (data?: IGetBlogCategoriesRequest, options?:
|
|
123
|
+
GetBlogCategoriesRequest: (data?: IGetBlogCategoriesRequest, options?: IRequestInit) => Promise<IApiResponse<IGetBlogCategoriesResponse>>;
|
|
119
124
|
/**
|
|
120
125
|
* Tek bir blog kategorisini almak için istek fonksiyonu
|
|
121
126
|
*/
|
|
122
|
-
GetBlogCategoryRequest: (data: IGetBlogCategoryRequest, options?:
|
|
127
|
+
GetBlogCategoryRequest: (data: IGetBlogCategoryRequest, options?: IRequestInit) => Promise<IApiResponse<IGetBlogCategoryResponse>>;
|
|
123
128
|
/**
|
|
124
129
|
* Blog kategorisi hiyerarşisini almak için istek fonksiyonu
|
|
125
130
|
*/
|
|
126
|
-
GetBlogCategoryHierarchyRequest: (data: IGetBlogCategoryHierarchyRequest, options?:
|
|
131
|
+
GetBlogCategoryHierarchyRequest: (data: IGetBlogCategoryHierarchyRequest, options?: IRequestInit) => Promise<IApiResponse<IGetBlogCategoryHierarchyResponse>>;
|
|
127
132
|
/**
|
|
128
133
|
* Blog kategori ağacını almak için istek fonksiyonu
|
|
129
134
|
*/
|
|
130
|
-
GetBlogCategoryTreeRequest: (data: IGetBlogCategoryTreeRequest, options?:
|
|
135
|
+
GetBlogCategoryTreeRequest: (data: IGetBlogCategoryTreeRequest, options?: IRequestInit) => Promise<IApiResponse<IGetBlogCategoryTreeResponse>>;
|
|
131
136
|
/**
|
|
132
137
|
* Tek bir blog etiketini almak için istek fonksiyonu
|
|
133
138
|
*/
|
|
134
|
-
GetBlogTagRequest: (data: IGetBlogTagRequest, options?:
|
|
139
|
+
GetBlogTagRequest: (data: IGetBlogTagRequest, options?: IRequestInit) => Promise<IApiResponse<IGetBlogTagResponse>>;
|
|
135
140
|
/**
|
|
136
141
|
* Blog etiketlerini almak için istek fonksiyonu
|
|
137
142
|
*/
|
|
138
|
-
GetBlogTagsRequest: (data: IGetBlogTagsRequest, options?:
|
|
143
|
+
GetBlogTagsRequest: (data: IGetBlogTagsRequest, options?: IRequestInit) => Promise<IApiResponse<IGetBlogTagsResponse>>;
|
|
139
144
|
}
|
|
140
145
|
export {};
|
|
@@ -1,2 +1,8 @@
|
|
|
1
1
|
import { IBlogService } from './blog.types';
|
|
2
|
+
/** BlogService adlı nesneyi oluşturur ve IBlogService arayüzünü uygular
|
|
3
|
+
* @description
|
|
4
|
+
* Microservice Kubernates içerisinden doğrudan iletişim sağlanabilmesi için aşağıdaki adresi kullanmalıdır.
|
|
5
|
+
* <service-name>.<namespace>.svc.cluster.local:<service-port>
|
|
6
|
+
* http://blog.emosv2service.svc.cluster.local
|
|
7
|
+
*/
|
|
2
8
|
export declare const BlogService: IBlogService;
|
|
@@ -17,80 +17,118 @@ exports.BlogService = void 0;
|
|
|
17
17
|
const urls_1 = __importDefault(require("../urls"));
|
|
18
18
|
// Farklı blog cevap arayüzlerini ve fetchRequest fonksiyonunu içe aktarır
|
|
19
19
|
const __1 = require("../..");
|
|
20
|
-
|
|
20
|
+
/** BlogService adlı nesneyi oluşturur ve IBlogService arayüzünü uygular
|
|
21
|
+
* @description
|
|
22
|
+
* Microservice Kubernates içerisinden doğrudan iletişim sağlanabilmesi için aşağıdaki adresi kullanmalıdır.
|
|
23
|
+
* <service-name>.<namespace>.svc.cluster.local:<service-port>
|
|
24
|
+
* http://blog.emosv2service.svc.cluster.local
|
|
25
|
+
*/
|
|
21
26
|
exports.BlogService = {
|
|
27
|
+
/**
|
|
28
|
+
* Bu servise ait local adres
|
|
29
|
+
*/
|
|
30
|
+
ServiceUrl: "http://blog.emosv2service.svc.cluster.local",
|
|
31
|
+
GetURL: function (isClient) {
|
|
32
|
+
if (process.env.API_URL && (process.env.USE_API_URL === 'true' || isClient))
|
|
33
|
+
return process.env.API_URL;
|
|
34
|
+
return this.ServiceUrl;
|
|
35
|
+
},
|
|
22
36
|
/**
|
|
23
37
|
* Blog gönderilerini almak için istek fonksiyonu
|
|
24
38
|
* @param data İstek verilerini içeren nesne (varsayılan boş nesne)
|
|
25
39
|
* @param options İstek seçeneklerini içeren nesne
|
|
26
40
|
* @returns Blog gönderilerini içeren cevap nesnesi
|
|
27
41
|
*/
|
|
28
|
-
GetBlogPostsRequest:
|
|
29
|
-
return
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
42
|
+
GetBlogPostsRequest: function () {
|
|
43
|
+
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) }));
|
|
48
|
+
});
|
|
49
|
+
},
|
|
33
50
|
/**
|
|
34
51
|
* Tek bir blog gönderisini almak için istek fonksiyonu
|
|
35
52
|
* @param data Gönderi verilerini içeren nesne
|
|
36
53
|
* @param options İstek seçeneklerini içeren nesne
|
|
37
54
|
* @returns Blog gönderisini içeren cevap nesnesi
|
|
38
55
|
*/
|
|
39
|
-
GetBlogPostRequest: (data, options)
|
|
40
|
-
return
|
|
41
|
-
|
|
56
|
+
GetBlogPostRequest: function (data, options) {
|
|
57
|
+
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
|
+
});
|
|
61
|
+
},
|
|
42
62
|
/**
|
|
43
63
|
* Blog kategorilerini almak için istek fonksiyonu
|
|
44
64
|
* @param data İstek verilerini içeren nesne (varsayılan boş nesne)
|
|
45
65
|
* @param options İstek seçeneklerini içeren nesne
|
|
46
66
|
* @returns Blog kategorilerini içeren cevap nesnesi
|
|
47
67
|
*/
|
|
48
|
-
GetBlogCategoriesRequest:
|
|
49
|
-
return
|
|
50
|
-
|
|
68
|
+
GetBlogCategoriesRequest: function () {
|
|
69
|
+
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) }));
|
|
72
|
+
});
|
|
73
|
+
},
|
|
51
74
|
/**
|
|
52
75
|
* Belirli bir blog kategorisini almak için istek fonksiyonu
|
|
53
76
|
* @param data Kategori verilerini içeren nesne
|
|
54
77
|
* @param options İstek seçeneklerini içeren nesne
|
|
55
78
|
* @returns Blog kategorisini içeren cevap nesnesi
|
|
56
79
|
*/
|
|
57
|
-
GetBlogCategoryRequest: (data, options)
|
|
58
|
-
return
|
|
59
|
-
|
|
80
|
+
GetBlogCategoryRequest: function (data, options) {
|
|
81
|
+
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) }));
|
|
84
|
+
});
|
|
85
|
+
},
|
|
60
86
|
/**
|
|
61
87
|
* Blog kategorisi hiyerarşisini almak için istek fonksiyonu
|
|
62
88
|
* @param data Hiyerarşi verilerini içeren nesne
|
|
63
89
|
* @param options İstek seçeneklerini içeren nesne
|
|
64
90
|
* @returns Blog kategorisi hiyerarşisini içeren cevap nesnesi
|
|
65
91
|
*/
|
|
66
|
-
GetBlogCategoryHierarchyRequest: (data, options)
|
|
67
|
-
return
|
|
68
|
-
|
|
92
|
+
GetBlogCategoryHierarchyRequest: function (data, options) {
|
|
93
|
+
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) }));
|
|
96
|
+
});
|
|
97
|
+
},
|
|
69
98
|
/**
|
|
70
99
|
* Blog kategori ağacını almak için istek fonksiyonu
|
|
71
100
|
* @param data Kategori ağacı verilerini içeren nesne
|
|
72
101
|
* @param options İstek seçeneklerini içeren nesne
|
|
73
102
|
* @returns Blog kategori ağacını içeren cevap nesnesi
|
|
74
103
|
*/
|
|
75
|
-
GetBlogCategoryTreeRequest: (data, options)
|
|
76
|
-
return
|
|
77
|
-
|
|
104
|
+
GetBlogCategoryTreeRequest: function (data, options) {
|
|
105
|
+
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) }));
|
|
108
|
+
});
|
|
109
|
+
},
|
|
78
110
|
/**
|
|
79
111
|
* Belirli bir blog etiketini almak için istek fonksiyonu
|
|
80
112
|
* @param data Etiket verilerini içeren nesne
|
|
81
113
|
* @param options İstek seçeneklerini içeren nesne
|
|
82
114
|
* @returns Blog etiketini içeren cevap nesnesi
|
|
83
115
|
*/
|
|
84
|
-
GetBlogTagRequest: (data, options)
|
|
85
|
-
return
|
|
86
|
-
|
|
116
|
+
GetBlogTagRequest: function (data, options) {
|
|
117
|
+
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) }));
|
|
120
|
+
});
|
|
121
|
+
},
|
|
87
122
|
/**
|
|
88
123
|
* Blog etiketlerini almak için istek fonksiyonu
|
|
89
124
|
* @param data İstek verilerini içeren nesne
|
|
90
125
|
* @param options İstek seçeneklerini içeren nesne
|
|
91
126
|
* @returns Blog etiketlerini içeren cevap nesnesi
|
|
92
127
|
*/
|
|
93
|
-
GetBlogTagsRequest: (data, options)
|
|
94
|
-
return
|
|
95
|
-
|
|
128
|
+
GetBlogTagsRequest: function (data, options) {
|
|
129
|
+
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) }));
|
|
132
|
+
});
|
|
133
|
+
},
|
|
96
134
|
};
|
package/dist/services/urls.js
CHANGED
|
@@ -1,25 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const API_URL = process.env.API_URL;
|
|
4
3
|
exports.default = {
|
|
5
4
|
Banner: {
|
|
6
|
-
GetBannerById:
|
|
7
|
-
GetBannerByName:
|
|
8
|
-
GetBannerByKey:
|
|
9
|
-
GetBannerList:
|
|
10
|
-
GetBannerContainerList:
|
|
5
|
+
GetBannerById: '/{language}/Banner/v1/GetBannerById',
|
|
6
|
+
GetBannerByName: '/{language}/Banner/v1/GetBannerByName',
|
|
7
|
+
GetBannerByKey: '/{language}/Banner/v1/GetBannerByKey',
|
|
8
|
+
GetBannerList: '/{language}/Banner/v1/GetBannerList',
|
|
9
|
+
GetBannerContainerList: '/{language}/Banner/v1/GetBannerContainerList',
|
|
11
10
|
},
|
|
12
11
|
Blog: {
|
|
13
12
|
// BlogPosts
|
|
14
|
-
GetBlogPostsRequest:
|
|
15
|
-
GetBlogPostRequest:
|
|
13
|
+
GetBlogPostsRequest: '/{language}/BlogPosts/v1/GetBlogPostsRequest',
|
|
14
|
+
GetBlogPostRequest: '/{language}/BlogPosts/v1/GetBlogPostRequest',
|
|
16
15
|
// BlogTags
|
|
17
|
-
GetBlogTagsRequest:
|
|
18
|
-
GetBlogTagRequest:
|
|
16
|
+
GetBlogTagsRequest: '/{language}/BlogTags/v1/GetBlogTagsRequest',
|
|
17
|
+
GetBlogTagRequest: '/{language}/BlogTags/v1/GetBlogTagRequest',
|
|
19
18
|
// BlogCategories
|
|
20
|
-
GetBlogCategoriesRequest:
|
|
21
|
-
GetBlogCategoryRequest:
|
|
22
|
-
GetBlogCategoryHierarchyRequest:
|
|
23
|
-
GetBlogCategoryTreeRequest:
|
|
19
|
+
GetBlogCategoriesRequest: '/{language}/BlogCategories/v1/GetBlogCategoriesRequest',
|
|
20
|
+
GetBlogCategoryRequest: '/{language}/BlogCategories/v1/GetBlogCategoryRequest',
|
|
21
|
+
GetBlogCategoryHierarchyRequest: '/{language}/BlogCategories/v1/GetBlogCategoryHierarchyRequest',
|
|
22
|
+
GetBlogCategoryTreeRequest: '/{language}/BlogCategories/v1/GetBlogCategoryTreeRequest',
|
|
24
23
|
}
|
|
25
24
|
};
|
package/dist/test.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = test;
|
|
3
4
|
const hooks_1 = require("./hooks");
|
|
4
5
|
const services_1 = require("./services");
|
|
5
6
|
function test() {
|
|
@@ -15,4 +16,3 @@ function test() {
|
|
|
15
16
|
});
|
|
16
17
|
return;
|
|
17
18
|
}
|
|
18
|
-
exports.default = test;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nextemos",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.1",
|
|
4
4
|
"description": "For helpers and hooks used in NextJS projects",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -44,5 +44,8 @@
|
|
|
44
44
|
"nextjs",
|
|
45
45
|
"typescript",
|
|
46
46
|
"nextemos"
|
|
47
|
-
]
|
|
47
|
+
],
|
|
48
|
+
"dependencies": {
|
|
49
|
+
"pino": "^9.3.2"
|
|
50
|
+
}
|
|
48
51
|
}
|