Skip to content

Commit ae537a8

Browse files
committed
docs: update README.md
1 parent 39a93fd commit ae537a8

File tree

1 file changed

+21
-54
lines changed

1 file changed

+21
-54
lines changed

README.md

Lines changed: 21 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@
66

77
This library is inspired by the HTTP interface in Spring 6 and provides a similar API for Nest.js.
88

9+
## Features
10+
11+
- Provides a simplified and declarative way of creating HTTP services.
12+
- Provides a concise syntax for handling query parameters, path variables, request headers, request bodies, and forms.
13+
- Offers integration with [class-transformer](https://github.com/typestack/class-transformer) to facilitate data transformation.
14+
- Uses promises instead of observables
15+
916
## Requirements
1017

1118
- Node.js 18 or later (because this library uses `fetch` internally)
@@ -65,63 +72,23 @@ export class AppModule {
6572

6673
## Decorators
6774

68-
- `@HttpInterface()`
69-
70-
This decorator is used to mark the class as an HTTP service.
71-
72-
- `@{HTTP Method}Exchange(path: string)`
73-
74-
These decorators are used to mark the method as an HTTP request method.
75-
`path` is the path or full URL of the request.
76-
77-
- `@ResponseBody(dto: ClassConstructor, options?: ClassTransformOptions)`
78-
79-
This decorator is used to specify the response DTO.
80-
It requires a class constructor and options from `class-transformer` library.
81-
82-
- `@PathVariable(name?: string)`
83-
84-
This decorator is used to specify the path variable.
85-
It requires the name of the path variable.
86-
87-
- `@RequestParam(key?: string)`
88-
89-
This decorator is used to specify the query string parameter.
90-
It requires the key of query string parameter.
91-
If `key` is not specified, it requires the parameter to be an object.
92-
93-
```ts
94-
// with key
95-
class TestService {
96-
request(@RequestParam('foo') query: string): string {
97-
return imitation();
98-
}
99-
}
100-
101-
// without key
102-
class TestService {
103-
request(@RequestParam() query: { foo: string }): string {
104-
return imitation();
105-
}
106-
}
107-
```
108-
109-
- `@RequestHeader(key?: string)`
110-
111-
This decorator is used to specify the request header.
112-
It requires the key of request header optionally.
113-
114-
- `@RequestBody(key?: string)`
75+
- `@HttpInterface()`: Marks the class as an HTTP service.
76+
77+
- `@{HTTP Method}Exchange(path: string)`: Marks the method as an HTTP request method, with `path` being the request's path or full URL.
78+
79+
- `@ResponseBody(dto: ClassConstructor, options?: ClassTransformOptions)`: Specifies the response DTO using a class constructor and options from the `class-transformer` library.
80+
81+
- `@PathVariable(name?: string)`: Specifies the path variable, requiring the name of the variable.
82+
83+
- `@RequestParam(key?: string)`: Specifies the query string parameter, requiring the key of the parameter. If `key` is not specified, the parameter must be an object. See examples below:
84+
- Example with key: `request(@RequestParam('foo') query: string): string`
85+
- Example without key: `request(@RequestParam() query: { foo: string }): string`
11586

116-
This decorator is used to specify the request body.
117-
`application/json` is used as the content type.
118-
It requires the key of request body optionally.
87+
- `@RequestHeader(key?: string)`: Specifies the request header, requiring the key of the header optionally.
11988

120-
- `@RequestForm(key?: string)`
89+
- `@RequestBody(key?: string)`: Specifies the request body using `application/json` as the content type, requiring the key of the body optionally.
12190

122-
This decorator is used to specify the request form.
123-
`application/x-www-form-urlencoded` is used as the content type.
124-
It requires the key of request body optionally.
91+
- `@RequestForm(key?: string)`: Specifies the request form using `application/x-www-form-urlencoded` as the content type, requiring the key of the body optionally.
12592

12693
## License
12794

0 commit comments

Comments
 (0)