@xapi-js/adaptor-fetch 1.0.0 → 1.1.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.
Files changed (2) hide show
  1. package/README.md +119 -29
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -1,29 +1,119 @@
1
- # @xapi-ts/adaptor-fetch
2
-
3
- This package provides a Fetch API adaptor for X-API data.
4
-
5
- ## Installation
6
-
7
- ```bash
8
- pnpm add @xapi-ts/adaptor-fetch
9
- ```
10
-
11
- ## Usage
12
-
13
- (Add usage examples here)
14
-
15
- ---
16
-
17
- # @xapi-ts/adaptor-fetch
18
-
19
- 이 패키지는 X-API 데이터를 위한 Fetch API 어댑터를 제공합니다.
20
-
21
- ## 설치
22
-
23
- ```bash
24
- pnpm add @xapi-ts/adaptor-fetch
25
- ```
26
-
27
- ## 사용법
28
-
29
- (여기에 사용 예시를 추가하세요)
1
+ # @xapi-ts/adaptor-fetch
2
+
3
+ This package provides a Fetch API adaptor for X-API data.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ # npm
9
+ npm install @xapi-ts/adaptor-fetch
10
+
11
+ # yarn
12
+ yarn add @xapi-ts/adaptor-fetch
13
+
14
+ # pnpm
15
+ pnpm add @xapi-ts/adaptor-fetch
16
+
17
+ # bun
18
+ bun add @xapi-ts/adaptor-fetch
19
+
20
+ # deno
21
+ deno add @xapi-ts/adaptor-fetch
22
+ ```
23
+
24
+ ## Usage
25
+
26
+ Here's how to use `@xapi-ts/adaptor-fetch` to send and receive X-API data:
27
+
28
+ ```typescript
29
+ import { xapiFetch } from '@xapi-ts/adaptor-fetch';
30
+ import { XapiRoot } from '@xapi-ts/core';
31
+
32
+ async function sendXapiRequest() {
33
+ const requestXapi = new XapiRoot();
34
+ requestXapi.addParameter({ id: 'service', value: 'stock' });
35
+ requestXapi.addParameter({ id: 'method', value: 'search' });
36
+
37
+ try {
38
+ const responseXapi = await xapiFetch('http://localhost:3000/api/xapi', requestXapi);
39
+
40
+ // Access parameters from the response
41
+ const result = responseXapi.parameters.get('result')?.value;
42
+ console.log(`Result: ${result}`);
43
+
44
+ // Access datasets from the response
45
+ const stockDataset = responseXapi.getDataset('stockList');
46
+ if (stockDataset) {
47
+ console.log('Stock List:');
48
+ stockDataset.rows.forEach(row => {
49
+ console.log(` Code: ${row.get('stockCode')}, Price: ${row.get('currentPrice')}`);
50
+ });
51
+ }
52
+ } catch (error) {
53
+ console.error('Error sending X-API request:', error);
54
+ }
55
+ }
56
+
57
+ sendXapiRequest();
58
+ ```
59
+
60
+ ---
61
+
62
+ # @xapi-ts/adaptor-fetch
63
+
64
+ 이 패키지는 X-API 데이터를 위한 Fetch API 어댑터를 제공합니다.
65
+
66
+ ## 설치
67
+
68
+ ```bash
69
+ # npm
70
+ npm install @xapi-ts/adaptor-fetch
71
+
72
+ # yarn
73
+ yarn add @xapi-ts/adaptor-fetch
74
+
75
+ # pnpm
76
+ pnpm add @xapi-ts/adaptor-fetch
77
+
78
+ # bun
79
+ bun add @xapi-ts/adaptor-fetch
80
+
81
+ # deno
82
+ deno add @xapi-ts/adaptor-fetch
83
+ ```
84
+
85
+ ## 사용법
86
+
87
+ 다음은 `@xapi-ts/adaptor-fetch`를 사용하여 X-API 데이터를 송수신하는 방법입니다:
88
+
89
+ ```typescript
90
+ import { xapiFetch } from '@xapi-ts/adaptor-fetch';
91
+ import { XapiRoot } from '@xapi-ts/core';
92
+
93
+ async function sendXapiRequest() {
94
+ const requestXapi = new XapiRoot();
95
+ requestXapi.addParameter({ id: 'service', value: 'stock' });
96
+ requestXapi.addParameter({ id: 'method', value: 'search' });
97
+
98
+ try {
99
+ const responseXapi = await xapiFetch('http://localhost:3000/api/xapi', requestXapi);
100
+
101
+ // 응답에서 파라미터 접근
102
+ const result = responseXapi.parameters.get('result')?.value;
103
+ console.log(`결과: ${result}`);
104
+
105
+ // 응답에서 데이터셋 접근
106
+ const stockDataset = responseXapi.getDataset('stockList');
107
+ if (stockDataset) {
108
+ console.log('주식 목록:');
109
+ stockDataset.rows.forEach(row => {
110
+ console.log(` 코드: ${row.get('stockCode')}, 가격: ${row.get('currentPrice')}`);
111
+ });
112
+ }
113
+ } catch (error) {
114
+ console.error('X-API 요청 전송 오류:', error);
115
+ }
116
+ }
117
+
118
+ sendXapiRequest();
119
+ ```
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@xapi-js/adaptor-fetch",
3
3
  "type": "module",
4
- "version": "1.0.0",
4
+ "version": "1.1.0",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",
7
7
  "types": "./dist/index.d.ts",
@@ -31,7 +31,7 @@
31
31
  "author": "Clickin <josh87786@gmail.com>",
32
32
  "dependencies": {
33
33
  "vitest": "^3.2.4",
34
- "@xapi-js/core": "1.0.0"
34
+ "@xapi-js/core": "1.1.0"
35
35
  },
36
36
  "devDependencies": {
37
37
  "typescript": "^5.0.0",