TypeScript
To add coding intellisense to your editor, install the types package:
pnpm add kyushu-types -Dnpm install kyushu-types -Dyarn add kyushu-types -DExportedHandler
Section titled “ExportedHandler”The default export shape expected by Kyushu workers.
import type { ExportedHandler } from "kyushu-types";
export default { async fetch(request) { return { status: 200, body: "Hello, world!", }; },} satisfies ExportedHandler;WorkerRequest
Section titled “WorkerRequest”The incoming HTTP request passed to the fetch handler.
| Field | Type | Description |
|---|---|---|
method | WorkerMethod | HTTP method (GET, POST, etc.) |
url | string | Full request URL |
headers | Record<string, string> | undefined | Request headers |
body | string | ArrayBuffer | Uint8Array | undefined | Request body |
WorkerResponse
Section titled “WorkerResponse”The HTTP response returned by the fetch handler.
| Field | Type | Description |
|---|---|---|
status | number | undefined | HTTP status code (default: 200) |
body | string | ArrayBuffer | Uint8Array | undefined | Response body |
headers | Record<string, string> | undefined | Response headers |
WorkerMethod
Section titled “WorkerMethod”type WorkerMethod = "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "HEAD" | "OPTIONS";Runtime validation
Section titled “Runtime validation”The worker validates both the incoming request and outgoing response using Zod schemas at the Wasm boundary. If your handler returns an unexpected shape, you get a clear error rather than a silent failure.
The schemas are also exported from kyushu-types if you need them directly:
import { WorkerRequestSchema, WorkerResponseSchema, ExportedHandlerSchema } from "kyushu-types";