Skip to content

TypeScript

To add coding intellisense to your editor, install the types package:

Terminal window
pnpm add kyushu-types -D

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;

The incoming HTTP request passed to the fetch handler.

FieldTypeDescription
methodWorkerMethodHTTP method (GET, POST, etc.)
urlstringFull request URL
headersRecord<string, string> | undefinedRequest headers
bodystring | ArrayBuffer | Uint8Array | undefinedRequest body

The HTTP response returned by the fetch handler.

FieldTypeDescription
statusnumber | undefinedHTTP status code (default: 200)
bodystring | ArrayBuffer | Uint8Array | undefinedResponse body
headersRecord<string, string> | undefinedResponse headers
type WorkerMethod = "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "HEAD" | "OPTIONS";

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";