@nuxx/torn-fetch 0.1.0 → 0.3.1
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 +27 -27
- package/dist/index.d.ts +3980 -1628
- package/dist/index.js +1 -1
- package/package.json +32 -15
- package/nuxx-torn-fetch-0.1.0.tgz +0 -0
package/README.md
CHANGED
|
@@ -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/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/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/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/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
|
|
|
@@ -104,28 +104,28 @@ Creates a specialized fetcher function for a specific API endpoint.
|
|
|
104
104
|
### Prerequisites
|
|
105
105
|
|
|
106
106
|
- Node.js 18+
|
|
107
|
-
-
|
|
107
|
+
- Bun
|
|
108
108
|
|
|
109
109
|
### Setup
|
|
110
110
|
|
|
111
111
|
```bash
|
|
112
112
|
# Install dependencies
|
|
113
|
-
|
|
113
|
+
bun install
|
|
114
114
|
|
|
115
115
|
# Get the latest Torn API schema and build
|
|
116
|
-
|
|
116
|
+
bun run build
|
|
117
117
|
```
|
|
118
118
|
|
|
119
119
|
### Scripts
|
|
120
120
|
|
|
121
|
-
- `
|
|
122
|
-
- `
|
|
123
|
-
- `
|
|
124
|
-
- `
|
|
125
|
-
- `
|
|
126
|
-
- `
|
|
127
|
-
- `
|
|
128
|
-
- `
|
|
121
|
+
- `bun run get-schema` - Downloads the latest Torn API OpenAPI schema and generates TypeScript types
|
|
122
|
+
- `bun run build` - Builds the project using tsup
|
|
123
|
+
- `bun run lint` - Runs ESLint on the codebase
|
|
124
|
+
- `bun run type-check` - Runs TypeScript type checking
|
|
125
|
+
- `bun run test` - Runs the test suite
|
|
126
|
+
- `bun run test:watch` - Runs tests in watch mode
|
|
127
|
+
- `bun run test:coverage` - Runs tests with coverage reporting
|
|
128
|
+
- `bun run ci` - Runs the complete CI pipeline (schema, lint, type-check, test, build)
|
|
129
129
|
|
|
130
130
|
## Testing
|
|
131
131
|
|
|
@@ -138,9 +138,9 @@ This package includes comprehensive tests with 100% code coverage. The test suit
|
|
|
138
138
|
|
|
139
139
|
Run tests with:
|
|
140
140
|
```bash
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
141
|
+
bun run test # Run tests once
|
|
142
|
+
bun run test:watch # Run tests in watch mode
|
|
143
|
+
bun run test:coverage # Run tests with coverage report
|
|
144
144
|
```
|
|
145
145
|
|
|
146
146
|
See [TESTING.md](./TESTING.md) for detailed testing documentation.
|
|
@@ -156,15 +156,15 @@ 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
|
|
163
163
|
├── package.json
|
|
164
|
-
├── pnpm-workspace.yaml # pnpm workspace configuration
|
|
165
164
|
├── tsconfig.json # TypeScript configuration
|
|
166
|
-
├── tsup.config.ts # Build configuration
|
|
165
|
+
├── tsup.config.ts # Build configuration
|
|
167
166
|
├── vitest.config.ts # Test configuration
|
|
167
|
+
├── bun.lock # Bun lock file
|
|
168
168
|
├── TESTING.md # Testing documentation
|
|
169
169
|
└── README.md
|
|
170
170
|
```
|
|
@@ -174,7 +174,7 @@ torn-fetch/
|
|
|
174
174
|
1. Fork the repository
|
|
175
175
|
2. Create a feature branch
|
|
176
176
|
3. Make your changes
|
|
177
|
-
4. Run the full CI pipeline: `
|
|
177
|
+
4. Run the full CI pipeline: `bun run ci`
|
|
178
178
|
5. Submit a pull request
|
|
179
179
|
|
|
180
180
|
All contributions should include appropriate tests and maintain 100% code coverage.
|