@yigityalim/next-router-client 1.0.0 → 1.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 +21 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -12,6 +12,22 @@ pnpm add @yigityalim/next-router-client
|
|
|
12
12
|
yarn add @yigityalim/next-router-client
|
|
13
13
|
```
|
|
14
14
|
|
|
15
|
+
## Setup
|
|
16
|
+
|
|
17
|
+
Add path mapping to your `tsconfig.json`:
|
|
18
|
+
|
|
19
|
+
```json
|
|
20
|
+
{
|
|
21
|
+
"compilerOptions": {
|
|
22
|
+
"paths": {
|
|
23
|
+
"myy/*": ["./.myy/route-handlers/*"]
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
This allows clean imports like `import { useGetUsers } from 'myy/hooks'` instead of relative paths.
|
|
30
|
+
|
|
15
31
|
## Usage
|
|
16
32
|
|
|
17
33
|
### CLI (Recommended)
|
|
@@ -19,7 +35,7 @@ yarn add @yigityalim/next-router-client
|
|
|
19
35
|
Use via [@yigityalim/next-router-cli](https://www.npmjs.com/package/@yigityalim/next-router-cli):
|
|
20
36
|
|
|
21
37
|
```bash
|
|
22
|
-
npx @yigityalim/next-router-cli generate-client -i ./openapi.json -o
|
|
38
|
+
npx @yigityalim/next-router-cli generate-client -i ./openapi.json -o ./.myy/route-handlers
|
|
23
39
|
```
|
|
24
40
|
|
|
25
41
|
### Programmatic API
|
|
@@ -29,7 +45,7 @@ import { generateClient } from '@yigityalim/next-router-client';
|
|
|
29
45
|
|
|
30
46
|
await generateClient({
|
|
31
47
|
openApiPath: './api-spec.json',
|
|
32
|
-
outputDir: '
|
|
48
|
+
outputDir: './.myy/route-handlers',
|
|
33
49
|
library: 'react-query', // 'react-query' | 'swr' | 'vanilla'
|
|
34
50
|
baseUrl: '/api/v1'
|
|
35
51
|
});
|
|
@@ -47,7 +63,7 @@ await generateClient({
|
|
|
47
63
|
### React Query Example
|
|
48
64
|
|
|
49
65
|
```typescript
|
|
50
|
-
import { useGetUsers, useCreateUser } from '
|
|
66
|
+
import { useGetUsers, useCreateUser } from 'myy/hooks';
|
|
51
67
|
|
|
52
68
|
function Users() {
|
|
53
69
|
const { data, isLoading } = useGetUsers();
|
|
@@ -60,7 +76,7 @@ function Users() {
|
|
|
60
76
|
### SWR Example
|
|
61
77
|
|
|
62
78
|
```typescript
|
|
63
|
-
import { useGetUsers, useCreateUser } from '
|
|
79
|
+
import { useGetUsers, useCreateUser } from 'myy/hooks';
|
|
64
80
|
|
|
65
81
|
function Users() {
|
|
66
82
|
const { data, error } = useGetUsers();
|
|
@@ -73,7 +89,7 @@ function Users() {
|
|
|
73
89
|
### Vanilla Example
|
|
74
90
|
|
|
75
91
|
```typescript
|
|
76
|
-
import { getUsers, createUser } from '
|
|
92
|
+
import { getUsers, createUser } from 'myy/fetchers';
|
|
77
93
|
|
|
78
94
|
const users = await getUsers();
|
|
79
95
|
const newUser = await createUser({ name: 'John' });
|
package/package.json
CHANGED