@forgepack/request 1.0.9 → 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 CHANGED
@@ -1,6 +1,4 @@
1
- <div align="center">
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
- ```typescript
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
- ```typescript
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/client'
84
+ import { api } from './api'
85
+ import { AppRoutes } from './routes'
83
86
 
84
87
  function App() {
85
88
  return (
86
- <AuthProvider api={api}>
87
- <YourApp />
88
- </AuthProvider>
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.9
73
- * @license Apache License 2.0
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.9
74
- * @license Apache License 2.0
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.9",
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": {
@@ -36,15 +36,14 @@
36
36
  "react-crud"
37
37
  ],
38
38
  "author": "Marcelo Gadelha",
39
- "type": "module",
40
- "main": "dist/index.cjs",
39
+ "type": "commonjs",
40
+ "main": "dist/index.js",
41
41
  "types": "dist/index.d.ts",
42
- "module": "dist/index.js",
43
42
  "exports": {
44
43
  ".": {
45
44
  "types": "./dist/index.d.ts",
46
- "import": "./dist/index.js",
47
- "require": "./dist/index.cjs"
45
+ "require": "./dist/index.js",
46
+ "default": "./dist/index.js"
48
47
  }
49
48
  },
50
49
  "sideEffects": false,
@@ -54,7 +53,8 @@
54
53
  "LICENSE"
55
54
  ],
56
55
  "scripts": {
57
- "build": "tsc",
56
+ "build": "npm run clean && tsc",
57
+ "clean": "rmdir /s /q dist 2>nul || true",
58
58
  "test": "echo \"Error: no test specified\" && exit 1"
59
59
  },
60
60
  "peerDependencies": {