Skip to main content
Builds the one fetch handler that answers every route Tappify calls on your server.

Parameters

options

TappifyHandlerOptions

Returns

TappifyFetchHandler

Remarks

It routes the paths under /tappify, minus basePath when your framework mounts it under a prefix, and hands each matched handler a TappifyRequest. Every route but GET /tappify/health needs a bearer install token, which it verifies with verifyTappifyToken, and an X-Tappify-Event-Id header; a missing token is 401 TAP_TOKEN_MISSING, a missing id 400 TAP_EVENT_ID_MISSING, an unknown path 404 TAP_ROUTE_UNKNOWN and a declared name with no handler 404 TAP_HANDLER_MISSING. A body that is not JSON is 400 TAP_BODY_INVALID and one over 1 MB is 413 TAP_BODY_TOO_LARGE. A TapServerError a handler throws is answered with its own code and status, and a TapError other than the two token failures with its own code and 400; anything else becomes 500 TAP_INTERNAL_ERROR with a fixed message, so an internal failure never reaches the owner. An events route answers 204 with no body, and every other route answers the handler’s return value as JSON. Export the options object as well as the handler: createTestClient takes the options.

Example