api-def 0.12.0-alpha.31 → 0.12.0-alpha.33

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 CHANGED
@@ -4,30 +4,33 @@ Typed APIs with middleware support
4
4
 
5
5
  API def provides a unified way to type your endpoints allowing for compile time checking of query, body, response and even url parameters
6
6
 
7
- ``` npm i api-def ```
7
+ ```bash
8
+ npm i api-def
9
+ ```
8
10
 
9
11
  - [Documentation](https://censkh.github.io/api-def/)
10
12
 
11
13
  ```typescript
12
- import {Api} from "api-def";
14
+ import { Api } from "api-def";
13
15
 
14
16
  const api = new Api({
15
17
  baseUrl: "https://my-api/",
16
18
  name: "My API",
17
19
  });
18
20
 
19
- const fetchData = api.endpoint()
20
- .queryOf<{ includeAwesome: boolean; }>()
21
- .responseOf<{ data: {awesome: boolean; } }>()
22
- .build({
23
- id: "fetch_data",
24
- method: "get",
25
- path: "/data"
26
- });
21
+ const fetchData = api
22
+ .endpoint()
23
+ .queryOf<{ includeAwesome: boolean }>()
24
+ .responseOf<{ data: { awesome: boolean } }>()
25
+ .build({
26
+ id: "fetch_data",
27
+ method: "get",
28
+ path: "/data",
29
+ });
27
30
 
28
31
  // calls GET https://my-api/data?includeAwesome=true
29
32
  const res = await fetchData.submit({
30
- query: {includeAwesome: true}
33
+ query: { includeAwesome: true },
31
34
  });
32
35
 
33
36
  console.log(res.data); // { data: { awesome: true } }