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.
90 lines (88 loc) • 2.99 kB
text/typescript
import { InngestEndpointAdapter } from "./components/InngestEndpointAdapter.cjs";
import { SupportedFrameworkName } from "./types.cjs";
import { ServeHandlerOptions, SyncHandlerOptions } from "./components/InngestCommHandler.cjs";
//#region src/edge.d.ts
/**
* The name of the framework, used to identify the framework in Inngest
* dashboards and during testing.
*/
declare const frameworkName: SupportedFrameworkName;
type EdgeHandler = (req: Request) => Promise<Response>;
/**
* In an edge runtime, serve and register any declared functions with Inngest,
* making them available to be triggered by events.
*
* The edge runtime is a generic term for any serverless runtime that supports
* only standard Web APIs such as `fetch`, `Request`, and `Response`, such as
* Cloudflare Workers, Vercel Edge Functions, and AWS Lambda@Edge.
*
* @example
* ```ts
* import { serve } from "inngest/edge";
* import functions from "~/inngest";
*
* export const handler = serve({ id: "my-edge-app", functions });
* ```
*
* @public
*/
declare const serve: (options: ServeHandlerOptions) => EdgeHandler;
/**
* In an edge runtime, create a function that can wrap any endpoint to be able
* to use steps seamlessly within that API.
*
* The edge runtime is a generic term for any serverless runtime that supports
* only standard Web APIs such as `fetch`, `Request`, and `Response`, such as
* Cloudflare Workers, Vercel Edge Functions, and AWS Lambda@Edge.
*
* @example
* ```ts
* import { Inngest, step } from "inngest";
* import { endpointAdapter } from "inngest/edge";
*
* const inngest = new Inngest({
* id: "my-app",
* endpointAdapter,
* });
*
* Bun.serve({
* routes: {
* "/": inngest.endpoint(async (req) => {
* const foo = await step.run("my-step", () => ({ foo: "bar" }));
*
* return new Response(`Result: ${JSON.stringify(foo)}`);
* }),
* },
* });
* ```
*
* You can also configure a custom redirect URL and create a proxy endpoint:
*
* @example
* ```ts
* import { Inngest } from "inngest";
* import { endpointAdapter } from "inngest/edge";
*
* const inngest = new Inngest({
* id: "my-app",
* endpointAdapter: endpointAdapter.withOptions({
* asyncRedirectUrl: "/api/inngest/poll",
* }),
* });
*
* // Your durable endpoint
* export const GET = inngest.endpoint(async (req) => {
* const result = await step.run("work", () => "done");
* return new Response(result);
* });
*
* // Proxy endpoint at /api/inngest/poll - handles CORS and decryption
* export const GET = inngest.endpointProxy();
* ```
*/
declare const endpointAdapter: ((options: SyncHandlerOptions) => (handler: (req: Request) => Promise<Response>) => (req: Request) => Promise<Response>) & InngestEndpointAdapter.Like & {
createProxyHandler: (options: InngestEndpointAdapter.ProxyHandlerOptions) => EdgeHandler;
};
//#endregion
export { EdgeHandler, endpointAdapter, frameworkName, serve };
//# sourceMappingURL=edge.d.cts.map