@xapi-js/adaptor-nestjs 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 +151 -29
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -1,29 +1,151 @@
1
- # @xapi-ts/adaptor-nestjs
2
-
3
- This package provides a NestJS adaptor for X-API data.
4
-
5
- ## Installation
6
-
7
- ```bash
8
- pnpm add @xapi-ts/adaptor-nestjs
9
- ```
10
-
11
- ## Usage
12
-
13
- (Add usage examples here)
14
-
15
- ---
16
-
17
- # @xapi-ts/adaptor-nestjs
18
-
19
- 이 패키지는 X-API 데이터를 위한 NestJS 어댑터를 제공합니다.
20
-
21
- ## 설치
22
-
23
- ```bash
24
- pnpm add @xapi-ts/adaptor-nestjs
25
- ```
26
-
27
- ## 사용법
28
-
29
- (여기에 사용 예시를 추가하세요)
1
+ # @xapi-ts/adaptor-nestjs
2
+
3
+ This package provides a NestJS adaptor for X-API data.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ # npm
9
+ npm install @xapi-ts/adaptor-nestjs
10
+
11
+ # yarn
12
+ yarn add @xapi-ts/adaptor-nestjs
13
+
14
+ # pnpm
15
+ pnpm add @xapi-ts/adaptor-nestjs
16
+
17
+ # bun
18
+ bun add @xapi-ts/adaptor-nestjs
19
+
20
+ # deno
21
+ deno add @xapi-ts/adaptor-nestjs
22
+ ```
23
+
24
+ ## Usage
25
+
26
+ `@xapi-ts/adaptor-nestjs` provides NestJS interceptors to automatically handle X-API request deserialization and response serialization.
27
+
28
+ ### XapiRequestInterceptor
29
+
30
+ Use `XapiRequestInterceptor` to automatically parse incoming `application/xml` requests into `XapiRoot` objects.
31
+
32
+ ```typescript
33
+ // app.controller.ts
34
+ import { Controller, Post, UseInterceptors, Body } from '@nestjs/common';
35
+ import { XapiRoot } from '@xapi-ts/core';
36
+ import { XapiRequestInterceptor } from '@xapi-ts/adaptor-nestjs';
37
+
38
+ @Controller('xapi')
39
+ export class AppController {
40
+ @Post('/')
41
+ @UseInterceptors(XapiRequestInterceptor)
42
+ handleXapi(@Body() xapi: XapiRoot): XapiRoot {
43
+ console.log('Received XapiRoot:', xapi.parameters.get('service')?.value);
44
+ // Process the XapiRoot object
45
+ const responseXapi = new XapiRoot();
46
+ responseXapi.addParameter({ id: 'result', value: 'success' });
47
+ return responseXapi;
48
+ }
49
+ }
50
+ ```
51
+
52
+ ### XapiResponseInterceptor
53
+
54
+ Use `XapiResponseInterceptor` to automatically serialize `XapiRoot` objects returned from your NestJS controllers into `application/xml` responses.
55
+
56
+ ```typescript
57
+ // app.controller.ts
58
+ import { Controller, Post, UseInterceptors, Body } from '@nestjs/common';
59
+ import { XapiRoot } from '@xapi-ts/core
60
+ import { XapiRequestInterceptor, XapiResponseInterceptor } from '@xapi-ts/adaptor-nestjs';
61
+
62
+ @Controller('xapi')
63
+ export class AppController {
64
+ @Post('/')
65
+ @UseInterceptors(XapiRequestInterceptor, XapiResponseInterceptor)
66
+ handleXapi(@Body() xapi: XapiRoot): XapiRoot {
67
+ console.log('Received XapiRoot:', xapi.parameters.get('service')?.value);
68
+ // Process the XapiRoot object
69
+ const responseXapi = new XapiRoot();
70
+ responseXapi.addParameter({ id: 'result', value: 'success' });
71
+ return responseXapi;
72
+ }
73
+ }
74
+ ```
75
+
76
+ ---
77
+
78
+ # @xapi-ts/adaptor-nestjs
79
+
80
+ 이 패키지는 X-API 데이터를 위한 NestJS 어댑터를 제공합니다.
81
+
82
+ ## 설치
83
+
84
+ ```bash
85
+ # npm
86
+ npm install @xapi-ts/adaptor-nestjs
87
+
88
+ # yarn
89
+ yarn add @xapi-ts/adaptor-nestjs
90
+
91
+ # pnpm
92
+ pnpm add @xapi-ts/adaptor-nestjs
93
+
94
+ # bun
95
+ bun add @xapi-ts/adaptor-nestjs
96
+
97
+ # deno
98
+ deno add @xapi-ts/adaptor-nestjs
99
+ ```
100
+
101
+ ## 사용법
102
+
103
+ `@xapi-ts/adaptor-nestjs`는 X-API 요청 역직렬화 및 응답 직렬화를 자동으로 처리하는 NestJS 인터셉터를 제공합니다.
104
+
105
+ ### XapiRequestInterceptor
106
+
107
+ 들어오는 `application/xml` 요청을 `XapiRoot` 객체로 자동 구문 분석하려면 `XapiRequestInterceptor`를 사용하십시오.
108
+
109
+ ```typescript
110
+ // app.controller.ts
111
+ import { Controller, Post, UseInterceptors, Body } from '@nestjs/common';
112
+ import { XapiRoot } from '@xapi-ts/core';
113
+ import { XapiRequestInterceptor } from '@xapi-ts/adaptor-nestjs';
114
+
115
+ @Controller('xapi')
116
+ export class AppController {
117
+ @Post('/')
118
+ @UseInterceptors(XapiRequestInterceptor)
119
+ handleXapi(@Body() xapi: XapiRoot): XapiRoot {
120
+ console.log('Received XapiRoot:', xapi.parameters.get('service')?.value);
121
+ // XapiRoot 객체 처리
122
+ const responseXapi = new XapiRoot();
123
+ responseXapi.addParameter({ id: 'result', value: 'success' });
124
+ return responseXapi;
125
+ }
126
+ }
127
+ ```
128
+
129
+ ### XapiResponseInterceptor
130
+
131
+ NestJS 컨트롤러에서 반환된 `XapiRoot` 객체를 `application/xml` 응답으로 자동 직렬화하려면 `XapiResponseInterceptor`를 사용하십시오.
132
+
133
+ ```typescript
134
+ // app.controller.ts
135
+ import { Controller, Post, UseInterceptors, Body } from '@nestjs/common';
136
+ import { XapiRoot } from '@xapi-ts/core
137
+ import { XapiRequestInterceptor, XapiResponseInterceptor } from '@xapi-ts/adaptor-nestjs';
138
+
139
+ @Controller('xapi')
140
+ export class AppController {
141
+ @Post('/')
142
+ @UseInterceptors(XapiRequestInterceptor, XapiResponseInterceptor)
143
+ handleXapi(@Body() xapi: XapiRoot): XapiRoot {
144
+ console.log('Received XapiRoot:', xapi.parameters.get('service')?.value);
145
+ // XapiRoot 객체 처리
146
+ const responseXapi = new XapiRoot();
147
+ responseXapi.addParameter({ id: 'result', value: 'success' });
148
+ return responseXapi;
149
+ }
150
+ }
151
+ ```
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@xapi-js/adaptor-nestjs",
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",
@@ -30,7 +30,7 @@
30
30
  "express": "^5.1.0",
31
31
  "rxjs": "^7.8.1",
32
32
  "@nestjs/common": "^10.3.10",
33
- "@xapi-js/core": "1.0.0"
33
+ "@xapi-js/core": "1.1.0"
34
34
  },
35
35
  "devDependencies": {},
36
36
  "scripts": {