name: noony-custom-adapter description: Use ONLY when creating adapters for unsupported frameworks like Koa, Hapi, or NestJS. Fastify, Express, and Cloud Functions are already built-in — you do not need this skill for those.
skill:noony-custom-adapter
Does exactly this
Provides a template for creating adapters for any HTTP framework NOT already supported by Noony. Covers implementing GenericRequest<T> and GenericResponse interfaces, building handler wrappers, and testing adapters. Includes a complete Koa adapter as reference.
When to use
- "Add support for Koa/Hapi/NestJS/[framework]"
- "Create adapter for my framework"
- "Make Noony work with [framework]"
- "I want to use Noony outside of Cloud Functions and Fastify"
- "Implement GenericRequest or GenericResponse"
- "How does executeGeneric work"
Do not use this skill when
- Fastify -- built-in support via
createFastifyHandler(). Usenoony-create-fastify-serverornoony-convert-cloud-functions-to-fastifyskill instead. - Express -- built-in support via
handler.execute(). No adapter needed. - Google Cloud Functions -- built-in support via
handler.execute(). No adapter needed. - You want the standard Fastify + Cloud Functions dual-entry pattern -- use
noony-complete-dual-entryskill instead.
This skill is for Koa, Hapi, NestJS, or other frameworks that Noony does not natively support.
Steps
Implement
GenericRequest<T>adapter- Map framework's request to: method, url, path, headers, query, params, body, parsedBody
- CRITICAL: Set
parsedBodyfrom framework's parsed body --BodyValidationMiddlewarereads from this - Adapters need correct generics -- see
noony-type-inferenceskill for generic patterns -> See references/custom-adapter.md#step-1-define-adapter-interfaces
Implement
GenericResponseadapter- Implement:
status(),json(),send(),header(),headers(),end() - All methods MUST return
this(chainable) - Track
headersSentflag internally to prevent double-send - Expose read-only
statusCodeandheadersSentproperties -> See references/custom-adapter.md#step-1-define-adapter-interfaces
- Implement:
Create handler wrapper function
- Call
handler.executeGeneric(genericReq, genericRes)-- NOTexecute() - Handle
RESPONSE_SENTerrors gracefully (expected when response already sent by middleware) - Check
headersSentbefore sending error responses -> See references/custom-adapter.md#step-3-koa-route-handler-wrapper
- Call
Integrate with framework server and register routes -> See references/custom-adapter.md#step-4-koa-server-integration
Set up middleware chain in canonical order
- After creating the adapter, use
noony-middleware-orderingskill to verify handler middleware ordering
- After creating the adapter, use
Write unit tests for both request and response adaptation -> See references/custom-adapter.md#testing-the-adapter
Rules
GenericRequest<T>andGenericResponseMUST be fully implemented -- no partial implementations- Always track
headersSentflag to prevent double-send errors - Response methods MUST be chainable (return
this) - Never mutate the framework's native request/response during adaptation -- create new objects
- Always set
parsedBodyfrom framework's parsed body (required for BodyValidationMiddleware) - Handle
RESPONSE_SENTerrors gracefully -- response already sent is expected behavior - Use
executeGeneric(), neverexecute()-- the latter is for native GCP/Express req/res only
Anti-patterns
- Passing framework-native req/res directly to
executeGeneric()without adapting -- misses the interface contract, middleware will fail - Forgetting
headersSentcheck in response adapter -- causes double-send errors and crashes - Not setting
parsedBodyon adapted request -- validation middleware fails silently, body is always undefined - Breaking method chaining on response methods -- middleware pipeline breaks when
.status(200).json(data)fails - Using
execute()instead ofexecuteGeneric()--execute()expects native GCP/Express objects - Building a custom adapter for Fastify, Express, or Cloud Functions -- these are already built-in
Done when
- Both
GenericRequest<T>andGenericResponseadapters are fully implemented - Handler wrapper handles
RESPONSE_SENTerrors and checksheadersSentbefore error responses - Response adapter prevents double-send via
headersSenttracking - Unit tests verify request adaptation, response chaining, and double-send prevention
- Adapter checklist in resources is fully checked
- Middleware ordering verified against canonical order (
noony-middleware-orderingskill)
If you need more detail
- -> references/custom-adapter.md -- Complete Koa adapter (request adapter, response adapter, handler wrapper, server integration), unit tests with 3 test cases, adapter checklist, common gotchas with code examples
- ->
noony-type-inferenceskill -- Type inference patterns for generics in adapters - ->
noony-middleware-orderingskill -- Middleware ordering reference for any handler setup