@@ -19,26 +19,24 @@ yarn add fileforge
19
19
## Usage
20
20
21
21
``` typescript
22
- import { FileForgeClient , FileForge } from ' guesty' ;
22
+ import { FileForgeClient , FileForge } from " guesty" ;
23
23
import * as fs from " fs" ;
24
24
25
25
const fileforge = new FileForgeClient ({
26
- apiKey: " ..." ,
26
+ apiKey: " ..." ,
27
27
});
28
28
29
29
await fileforge .generate ({
30
- files: [
31
- fs .readStream (" index.html" ),
32
- ],
30
+ files: [fs .readStream (" index.html" )],
33
31
options: {
34
- fileName: " output.pdf"
35
- }
32
+ fileName: " output.pdf" ,
33
+ },
36
34
});
37
35
```
38
36
39
37
## Exception Handling
40
38
41
- When the API returns a non-success status code (4xx or 5xx response),
39
+ When the API returns a non-success status code (4xx or 5xx response),
42
40
a subclass of [ FileForgeError] ( ./src/errors/FileForgeError.ts ) will be thrown:
43
41
44
42
``` ts
48
46
await fileforge .generate (... );
49
47
} catch (err ) {
50
48
if (err instanceof FileForgeError ) {
51
- console .log (err .statusCode );
49
+ console .log (err .statusCode );
52
50
console .log (err .message );
53
- console .log (err .body );
51
+ console .log (err .body );
54
52
}
55
53
}
56
54
```
@@ -63,11 +61,11 @@ than the configured retry limit (default: 2).
63
61
64
62
A request is deemed retriable when any of the following HTTP status codes is returned:
65
63
66
- - [ 408] ( https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/408 ) (Timeout)
67
- - [ 429] ( https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429 ) (Too Many Requests)
68
- - [ 5XX] ( https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/500 ) (Internal Server Errors)
69
-
70
- Use the ` maxRetries ` request option to configure this behavior.
64
+ - [ 408] ( https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/408 ) (Timeout)
65
+ - [ 429] ( https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429 ) (Too Many Requests)
66
+ - [ 5XX] ( https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/500 ) (Internal Server Errors)
67
+
68
+ Use the ` maxRetries ` request option to configure this behavior.
71
69
72
70
``` ts
73
71
const response = await fileforge .generate (... , {
@@ -77,8 +75,8 @@ const response = await fileforge.generate(..., {
77
75
78
76
## Timeouts
79
77
80
- The SDK defaults to a 60 second timout. Use the ` timeoutInSeconds ` option to
81
- configure this behavior.
78
+ The SDK defaults to a 60 second timout. Use the ` timeoutInSeconds ` option to
79
+ configure this behavior.
82
80
83
81
``` ts
84
82
const response = await fileforge .generate (... , {
@@ -88,23 +86,23 @@ const response = await fileforge.generate(..., {
88
86
89
87
## Runtime compatiblity
90
88
91
- The SDK defaults to ` node-fetch ` but will use the global fetch client if present. The SDK
92
- works in the following runtimes:
89
+ The SDK defaults to ` node-fetch ` but will use the global fetch client if present. The SDK
90
+ works in the following runtimes:
93
91
94
92
The following runtimes are supported:
95
93
96
- - Node.js 18+
97
- - Vercel
98
- - Cloudflare Workers
99
- - Deno v1.25+
100
- - Bun 1.0+
101
- - React Native
94
+ - Node.js 18+
95
+ - Vercel
96
+ - Cloudflare Workers
97
+ - Deno v1.25+
98
+ - Bun 1.0+
99
+ - React Native
102
100
103
101
### Customizing Fetch client
104
102
105
- The SDK provides a way for you to customize the underlying HTTP client / Fetch function. If you're
106
- running in an unsupported environment, this provides a way for you to break the glass and
107
- ensure the SDK works.
103
+ The SDK provides a way for you to customize the underlying HTTP client / Fetch function. If you're
104
+ running in an unsupported environment, this provides a way for you to break the glass and
105
+ ensure the SDK works.
108
106
109
107
``` ts
110
108
import { FileForge } from ' fileforge' ;
@@ -117,16 +115,16 @@ const guesty = new FileForge({
117
115
118
116
## Beta status
119
117
120
- This SDK is in beta, and there may be breaking changes between versions without a major version update.
121
- Therefore, we recommend pinning the package version to a specific version in your package.json file.
122
- This way, you can install the same version each time without breaking changes unless you are
118
+ This SDK is in beta, and there may be breaking changes between versions without a major version update.
119
+ Therefore, we recommend pinning the package version to a specific version in your package.json file.
120
+ This way, you can install the same version each time without breaking changes unless you are
123
121
intentionally looking for the latest version.
124
122
125
123
## Contributing
126
124
127
- While we value open-source contributions to this SDK, this library is generated programmatically.
128
- Additions made directly to this library would have to be moved over to our generation code,
129
- otherwise they would be overwritten upon the next generated release. Feel free to open a
130
- PR as a proof of concept, but know that we will not be able to merge it as-is.
125
+ While we value open-source contributions to this SDK, this library is generated programmatically.
126
+ Additions made directly to this library would have to be moved over to our generation code,
127
+ otherwise they would be overwritten upon the next generated release. Feel free to open a
128
+ PR as a proof of concept, but know that we will not be able to merge it as-is.
131
129
132
130
We suggest [ opening an issue] ( https://github.com/FlatFilers/flatfile-node/issues ) first to discuss with us!
0 commit comments