@nuxx/torn-fetch 0.3.1 → 1.0.0

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
@@ -15,15 +15,32 @@ A TypeScript wrapper around `openapi-fetch` that provides a better developer exp
15
15
  npm install @nuxx/torn-fetch
16
16
  ```
17
17
 
18
+ ## Migration from v0.x
19
+
20
+ If you're upgrading from v0.x, the main export has been renamed from `useTornFetch` to `tornFetch`. The old name still works in v1.x with a deprecation warning, but will be removed in v2.0.0.
21
+
22
+ **Migration:**
23
+ ```typescript
24
+ // Old (v0.x)
25
+ import { useTornFetch } from '@nuxx/torn-fetch'
26
+ const data = await useTornFetch(apiKey, path)
27
+
28
+ // New (v1.0+)
29
+ import { tornFetch } from '@nuxx/torn-fetch'
30
+ const data = await tornFetch(apiKey, path)
31
+ ```
32
+
33
+ The function signature and behavior are identical.
34
+
18
35
  ## Usage
19
36
 
20
37
  ### Basic Usage
21
38
 
22
39
  ```typescript
23
- import { useTornFetch } from '@nuxx/torn-fetch'
40
+ import { tornFetch } from '@nuxx/torn-fetch'
24
41
 
25
42
  try {
26
- const userAttacks = await useTornFetch(
43
+ const userAttacks = await tornFetch(
27
44
  'your-api-key',
28
45
  '/user/attacks'
29
46
  )
@@ -34,10 +51,10 @@ try {
34
51
  ```
35
52
 
36
53
  ```typescript
37
- import { useTornFetch } from '@nuxx/torn-fetch'
54
+ import { tornFetch } from '@nuxx/torn-fetch'
38
55
 
39
56
  // Use with path parameters
40
- const attacks = await useTornFetch(
57
+ const attacks = await tornFetch(
41
58
  'your-api-key',
42
59
  '/faction/{id}/chain',
43
60
  {
@@ -49,10 +66,10 @@ const attacks = await useTornFetch(
49
66
  ```
50
67
 
51
68
  ```typescript
52
- import { useTornFetch } from '@nuxx/torn-fetch'
69
+ import { tornFetch } from '@nuxx/torn-fetch'
53
70
 
54
71
  // Use with query parameters
55
- const attacks = await useTornFetch(
72
+ const attacks = await tornFetch(
56
73
  'your-api-key',
57
74
  '/user/attacks',
58
75
  {
@@ -69,10 +86,10 @@ const attacks = await useTornFetch(
69
86
  The library automatically throws JavaScript errors when the Torn API returns error responses:
70
87
 
71
88
  ```typescript
72
- import { useTornFetch } from '@nuxx/torn-fetch'
89
+ import { tornFetch } from '@nuxx/torn-fetch'
73
90
 
74
91
  try {
75
- const userAttacks = await useTornFetch(
92
+ const userAttacks = await tornFetch(
76
93
  'invalid-key-abc123',
77
94
  '/user/attacks'
78
95
  )
@@ -84,9 +101,9 @@ try {
84
101
 
85
102
  ## API Reference
86
103
 
87
- ### `useTornFetch<TPath>(apiKey: string, path: TPath, options?: TParams<TPath>): Promise<TResponse<TPath>>`
104
+ ### `tornFetch<TPath>(apiKey: string, path: TPath, options?: TParams<TPath>): Promise<TResponse<TPath>>`
88
105
 
89
- Creates a specialized fetcher function for a specific API endpoint.
106
+ Makes a type-safe call to the Torn API with automatic error handling.
90
107
 
91
108
  **Parameters:**
92
109
  - `apiKey`: Your Torn API key