@takumi-rs/image-response 1.6.0 → 1.7.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 +9 -2
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -124,10 +124,17 @@ await response.ready;
|
|
|
124
124
|
return response;
|
|
125
125
|
```
|
|
126
126
|
|
|
127
|
-
You can also provide `onError
|
|
127
|
+
You can also provide `onError`, a notification hook that runs after rendering fails. It's for side effects like logging; its return value is ignored and the response stream still errors, so it cannot substitute a fallback image. To serve a fallback, catch the `ready` rejection and return your own response.
|
|
128
128
|
|
|
129
129
|
```tsx
|
|
130
130
|
const response = new ImageResponse(<OgImage />, {
|
|
131
|
-
onError: () =>
|
|
131
|
+
onError: (error) => console.error(error),
|
|
132
132
|
});
|
|
133
|
+
|
|
134
|
+
try {
|
|
135
|
+
await response.ready;
|
|
136
|
+
return response;
|
|
137
|
+
} catch {
|
|
138
|
+
return new Response("Failed to generate image", { status: 500 });
|
|
139
|
+
}
|
|
133
140
|
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@takumi-rs/image-response",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.0",
|
|
4
4
|
"license": "(MIT OR Apache-2.0)",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Kane Wang",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"prepublishOnly": "jq '.dependencies[\"takumi-js\"] = .version' package.json > tmp.json && mv tmp.json package.json"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"takumi-js": "1.
|
|
39
|
+
"takumi-js": "1.7.0"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@types/bun": "catalog:",
|