ApiExtensionModule
commercetools API extensions as a module: the extensions, the client they read with, and the route they answer on, composed like every other capability rather than wired by hand in each project.
It is transport-free at its core. getHttpConfig() mounts it on the
subgraph's own Fastify app, but dispatch and handle are public, so the
same module — the same extensions, constructed the same way — is what a
serverless entry point hands to toWebHandler or toLambdaHandler. A
function that
serves extensions therefore constructs this module alone rather than the
whole composition, and carries no GraphQL schema into its cold start.
init() is a no-op here, but a serverless entry point must still call it:
there is no Application in a function to do it, and a later version of this
module may have something to do in it.
import { ApiExtensionModule } from "@evolve-framework/commercetools";new ApiExtensionModule(options: ApiExtensionModuleOptions)| Option | Type | Description |
|---|---|---|
extensions | ApiExtensions | The extensions to run, keyed by resource and action. |
clientFactory | ClientFactory | Handed to every extension as |
secret? | string | The bearer token commercetools is configured to send. Absent means the route accepts anything, which is only safe where something in front of it authenticates. |
path? | string | Route to mount on. Defaults to |
timeout? | number | Milliseconds an extension is given before |
ApiExtensions5The fields of extensions.
| Field | Type | Description |
|---|---|---|
cart? | any | |
order? | any | |
product? | any | |
payment? | any | |
customer? | any |
| Method | Description |
|---|---|
dispatch(input: ExtensionInput): Promise<ExtensionOutput> | No auth and no HTTP: run the extensions for this input, collect their actions. |
handle(
request: ApiExtensionHttpRequest,
): Promise<ApiExtensionHttpResponse> | The secret check, the status codes and the response body. |
getTriggers(): ApiExtensionTrigger[] | The triggers these extensions have to be registered for. |
Extends AbstractModule<unknown>.

