inngest
Version:
Official SDK for Inngest.com. Inngest is the reliability layer for modern applications. Inngest combines durable execution, events, and queues into a zero-infra platform with built-in observability.
46 lines (44 loc) • 1.19 kB
JavaScript
import { InngestCommHandler } from "./InngestCommHandler.js";
//#region src/components/createWebApiCommHandler.ts
/**
* Creates an {@link InngestCommHandler} that uses Web API `Request`/`Response`.
*
* This is shared by the edge and Node.js adapters so the handler logic isn't
* duplicated.
*/
const createWebApiCommHandler = (frameworkName, options, syncOptions) => {
return new InngestCommHandler({
frameworkName,
...options,
syncOptions,
handler: (req) => {
return {
body: () => req.text(),
headers: (key) => req.headers.get(key),
method: () => req.method,
url: () => new URL(req.url, `https://${req.headers.get("host") || ""}`),
transformResponse: ({ body, status, headers }) => {
return new Response(body, {
status,
headers
});
},
experimentalTransformSyncResponse: async (data) => {
const res = data;
const headers = {};
res.headers.forEach((v, k) => {
headers[k] = v;
});
return {
headers,
status: res.status,
body: await res.clone().text()
};
}
};
}
});
};
//#endregion
export { createWebApiCommHandler };
//# sourceMappingURL=createWebApiCommHandler.js.map