@nuxx/torn-fetch 0.1.0 → 0.3.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 +12 -12
- package/dist/index.d.ts +3976 -1626
- package/dist/index.js +1 -1
- package/package.json +10 -10
- package/nuxx-torn-fetch-0.1.0.tgz +0 -0
package/README.md
CHANGED
|
@@ -12,7 +12,7 @@ A TypeScript wrapper around `openapi-fetch` that provides a better developer exp
|
|
|
12
12
|
## Installation
|
|
13
13
|
|
|
14
14
|
```bash
|
|
15
|
-
npm install @nuxx/torn-fetch
|
|
15
|
+
npm install @nuxx/use-torn-fetch
|
|
16
16
|
```
|
|
17
17
|
|
|
18
18
|
## Usage
|
|
@@ -20,10 +20,10 @@ npm install @nuxx/torn-fetch
|
|
|
20
20
|
### Basic Usage
|
|
21
21
|
|
|
22
22
|
```typescript
|
|
23
|
-
import {
|
|
23
|
+
import { useTornFetch } from '@nuxx/use-torn-fetch'
|
|
24
24
|
|
|
25
25
|
try {
|
|
26
|
-
const userAttacks = await
|
|
26
|
+
const userAttacks = await useTornFetch(
|
|
27
27
|
'your-api-key',
|
|
28
28
|
'/user/attacks'
|
|
29
29
|
)
|
|
@@ -34,10 +34,10 @@ try {
|
|
|
34
34
|
```
|
|
35
35
|
|
|
36
36
|
```typescript
|
|
37
|
-
import {
|
|
37
|
+
import { useTornFetch } from '@nuxx/use-torn-fetch'
|
|
38
38
|
|
|
39
39
|
// Use with path parameters
|
|
40
|
-
const attacks = await
|
|
40
|
+
const attacks = await useTornFetch(
|
|
41
41
|
'your-api-key',
|
|
42
42
|
'/faction/{id}/chain',
|
|
43
43
|
{
|
|
@@ -49,10 +49,10 @@ const attacks = await tornFetch(
|
|
|
49
49
|
```
|
|
50
50
|
|
|
51
51
|
```typescript
|
|
52
|
-
import {
|
|
52
|
+
import { useTornFetch } from '@nuxx/use-torn-fetch'
|
|
53
53
|
|
|
54
54
|
// Use with query parameters
|
|
55
|
-
const attacks = await
|
|
55
|
+
const attacks = await useTornFetch(
|
|
56
56
|
'your-api-key',
|
|
57
57
|
'/user/attacks',
|
|
58
58
|
{
|
|
@@ -69,10 +69,10 @@ const attacks = await tornFetch(
|
|
|
69
69
|
The library automatically throws JavaScript errors when the Torn API returns error responses:
|
|
70
70
|
|
|
71
71
|
```typescript
|
|
72
|
-
import {
|
|
72
|
+
import { useTornFetch } from '@nuxx/use-torn-fetch'
|
|
73
73
|
|
|
74
74
|
try {
|
|
75
|
-
const userAttacks = await
|
|
75
|
+
const userAttacks = await useTornFetch(
|
|
76
76
|
'invalid-key-abc123',
|
|
77
77
|
'/user/attacks'
|
|
78
78
|
)
|
|
@@ -84,7 +84,7 @@ try {
|
|
|
84
84
|
|
|
85
85
|
## API Reference
|
|
86
86
|
|
|
87
|
-
### `
|
|
87
|
+
### `useTornFetch<TPath>(apiKey: string, path: TPath, options?: TParams<TPath>): Promise<TResponse<TPath>>`
|
|
88
88
|
|
|
89
89
|
Creates a specialized fetcher function for a specific API endpoint.
|
|
90
90
|
|
|
@@ -148,7 +148,7 @@ See [TESTING.md](./TESTING.md) for detailed testing documentation.
|
|
|
148
148
|
## Project Structure
|
|
149
149
|
|
|
150
150
|
```
|
|
151
|
-
torn-fetch/
|
|
151
|
+
use-torn-fetch/
|
|
152
152
|
├── coverage/ # Test coverage reports
|
|
153
153
|
├── dist/ # Compiled output
|
|
154
154
|
├── src/
|
|
@@ -156,7 +156,7 @@ torn-fetch/
|
|
|
156
156
|
│ │ ├── index.test.ts # Main functionality tests
|
|
157
157
|
│ │ ├── error-detection.test.ts # Error detection logic tests
|
|
158
158
|
│ │ └── error-handling.test.ts # Error handling tests
|
|
159
|
-
│ ├── index.ts # Main export (
|
|
159
|
+
│ ├── index.ts # Main export (useTornFetch)
|
|
160
160
|
│ ├── openapi.json # Torn API OpenAPI schema
|
|
161
161
|
│ └── torn-api.ts # Generated TypeScript types
|
|
162
162
|
├── eslint.config.js # ESLint configuration
|