@forgepack/request 1.0.11 → 1.0.12
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 +18 -11
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
<h1> @forgepack/request </h1>
|
|
3
|
-
</div>
|
|
1
|
+
# @forgepack/request
|
|
4
2
|
|
|
5
3
|
**Production-ready HTTP client with JWT authentication for React**
|
|
6
4
|
|
|
@@ -64,30 +62,39 @@ Make sure you have these installed:
|
|
|
64
62
|
## Quick Start
|
|
65
63
|
|
|
66
64
|
### Configure the API client
|
|
67
|
-
```
|
|
65
|
+
```ts
|
|
66
|
+
// src/api.ts
|
|
68
67
|
import { createApiClient } from "@forgepack/request"
|
|
69
68
|
|
|
70
69
|
export const api = createApiClient({
|
|
71
70
|
baseURL: "https://api.service.com",
|
|
72
|
-
/** Called on 401 errors */
|
|
71
|
+
/** Called on 401 errors (expired token) */
|
|
73
72
|
onUnauthorized: () => window.location.href = "/login",
|
|
74
|
-
/** Called on 403 errors */
|
|
73
|
+
/** Called on 403 errors (without permission) */
|
|
75
74
|
onForbidden: () => window.location.href = "/notAllowed"
|
|
76
75
|
})
|
|
77
76
|
```
|
|
78
77
|
|
|
79
78
|
### Configure the authentication provider
|
|
80
|
-
```
|
|
79
|
+
```tsx
|
|
80
|
+
// src/App.tsx
|
|
81
|
+
import React from 'react'
|
|
82
|
+
import { BrowserRouter } from 'react-router-dom'
|
|
81
83
|
import { AuthProvider } from '@forgepack/request'
|
|
82
|
-
import { api } from './api
|
|
84
|
+
import { api } from './api'
|
|
85
|
+
import { AppRoutes } from './routes'
|
|
83
86
|
|
|
84
87
|
function App() {
|
|
85
88
|
return (
|
|
86
|
-
<
|
|
87
|
-
<
|
|
88
|
-
|
|
89
|
+
<BrowserRouter>
|
|
90
|
+
<AuthProvider api={api}>
|
|
91
|
+
<AppRoutes />
|
|
92
|
+
</AuthProvider>
|
|
93
|
+
</BrowserRouter>
|
|
89
94
|
)
|
|
90
95
|
}
|
|
96
|
+
|
|
97
|
+
export default App
|
|
91
98
|
```
|
|
92
99
|
|
|
93
100
|
### Use in Components
|
package/dist/index.d.ts
CHANGED
|
@@ -69,8 +69,8 @@
|
|
|
69
69
|
*
|
|
70
70
|
* @fileoverview React package for managing HTTP requests with JWT authentication
|
|
71
71
|
* @author Marcelo Gadelha {@link https://github.com/gadelhati}
|
|
72
|
-
* @version 1.0.
|
|
73
|
-
* @license
|
|
72
|
+
* @version 1.0.12
|
|
73
|
+
* @license MIT License
|
|
74
74
|
*
|
|
75
75
|
* @remarks
|
|
76
76
|
* This package requires React 16.8+ (hooks support) and axios as peer dependencies
|
package/dist/index.js
CHANGED
|
@@ -70,8 +70,8 @@
|
|
|
70
70
|
*
|
|
71
71
|
* @fileoverview React package for managing HTTP requests with JWT authentication
|
|
72
72
|
* @author Marcelo Gadelha {@link https://github.com/gadelhati}
|
|
73
|
-
* @version 1.0.
|
|
74
|
-
* @license
|
|
73
|
+
* @version 1.0.12
|
|
74
|
+
* @license MIT License
|
|
75
75
|
*
|
|
76
76
|
* @remarks
|
|
77
77
|
* This package requires React 16.8+ (hooks support) and axios as peer dependencies
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@forgepack/request",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.12",
|
|
4
4
|
"description": "Opinionated Axios-based HTTP client for React applications with JWT support, interceptors, and API request standardization.",
|
|
5
5
|
"homepage": "https://forgepack.dev/packages/request",
|
|
6
6
|
"bugs": {
|