@kotodayori/fetch 0.1.0 → 0.1.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.
Files changed (2) hide show
  1. package/README.md +18 -0
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -86,10 +86,15 @@ function fetchAdapter<TEvent extends WebhookEvent>(
86
86
  options: {
87
87
  verifier: Verifier<TEvent>;
88
88
  onError?: (error: Error, event: TEvent) => Promise<void> | void;
89
+ logger?: Logger; // defaults to consoleLogger
89
90
  }
90
91
  ): (request: Request) => Promise<Response>
91
92
  ```
92
93
 
94
+ - **verifier** — Required. Verifies the request and returns the event (e.g. `createStripeVerifier`).
95
+ - **onError** — Optional. Called when a handler throws; errors thrown by `onError` itself are ignored and the response stays 500.
96
+ - **logger** — Optional. Receives adapter diagnostics, currently verification failures (`logger.error('Webhook verification failed:', err)`). Defaults to `consoleLogger`, which writes to `console`.
97
+
93
98
  The raw body is read with `request.text()` and passed to the verifier untouched, so signature verification sees the exact bytes that were signed.
94
99
 
95
100
  | Situation | Status | Body |
@@ -100,6 +105,19 @@ The raw body is read with `request.text()` and passed to the verifier untouched,
100
105
  | Handler threw | 500 | `{ "error": "Internal server error" }` |
101
106
  | Success | 200 | `{ "received": true }` |
102
107
 
108
+ ### Custom logger
109
+
110
+ Route verification failures to your own logger, or silence them:
111
+
112
+ ```typescript
113
+ import { silentLogger } from '@kotodayori/core';
114
+
115
+ const handle = fetchAdapter(router, {
116
+ verifier,
117
+ logger: silentLogger, // or any object with `warn` and `error` methods
118
+ });
119
+ ```
120
+
103
121
  Unlike the Hono adapter, non-POST requests are rejected with 405 because the handler may be mounted directly (e.g. `export default { fetch: handle }`) with no router in front of it.
104
122
 
105
123
  ## License
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kotodayori/fetch",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Web-standard fetch (Request/Response) adapter for Kotodayori Webhook Router",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",