@nuxx/torn-fetch 0.3.1 → 1.1.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.
Files changed (4) hide show
  1. package/README.md +28 -12
  2. package/dist/index.d.ts +13484 -12984
  3. package/dist/index.js +1 -1
  4. package/package.json +14 -15
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
@@ -122,7 +139,7 @@ bun run build
122
139
  - `bun run build` - Builds the project using tsup
123
140
  - `bun run lint` - Runs ESLint on the codebase
124
141
  - `bun run type-check` - Runs TypeScript type checking
125
- - `bun run test` - Runs the test suite
142
+ - `bun test` - Runs the test suite
126
143
  - `bun run test:watch` - Runs tests in watch mode
127
144
  - `bun run test:coverage` - Runs tests with coverage reporting
128
145
  - `bun run ci` - Runs the complete CI pipeline (schema, lint, type-check, test, build)
@@ -163,7 +180,6 @@ torn-fetch/
163
180
  ├── package.json
164
181
  ├── tsconfig.json # TypeScript configuration
165
182
  ├── tsup.config.ts # Build configuration
166
- ├── vitest.config.ts # Test configuration
167
183
  ├── bun.lock # Bun lock file
168
184
  ├── TESTING.md # Testing documentation
169
185
  └── README.md