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.
1 lines • 2.23 kB
Source Map (JSON)
{"version":3,"file":"bun.cjs","names":["frameworkName: SupportedFrameworkName","serveEdge"],"sources":["../src/bun.ts"],"sourcesContent":["/**\n * An adapter for Bun to serve and register any declared functions with Inngest,\n * making them available to be triggered by events.\n *\n * @example\n * ```ts\n * import { serve } from \"inngest/bun\";\n * import { functions, inngest } from \"./inngest\";\n *\n * Bun.serve({\n * port: 3000,\n * fetch(request: Request) {\n * const url = new URL(request.url);\n *\n * if (url.pathname === \"/api/inngest\") {\n * return serve({ client: inngest, functions })(request);\n * }\n *\n * return new Response(\"Not found\", { status: 404 });\n * },\n * });\n * ```\n *\n * @module\n */\n\nimport type {\n InternalServeHandlerOptions,\n ServeHandlerOptions,\n} from \"./components/InngestCommHandler.ts\";\nimport { serve as serveEdge } from \"./edge.ts\";\nimport type { SupportedFrameworkName } from \"./types.ts\";\n\n/**\n * The name of the framework, used to identify the framework in Inngest\n * dashboards and during testing.\n */\nexport const frameworkName: SupportedFrameworkName = \"bun\";\n\n/**\n * Using `Bun.serve()`, serve and register any declared functions with Inngest,\n * making them available to be triggered by events.\n *\n * @example\n * ```ts\n * import { serve } from \"inngest/bun\";\n * import { functions, inngest } from \"./inngest\";\n *\n * Bun.serve({\n * port: 3000,\n * fetch(request: Request) {\n * const url = new URL(request.url);\n *\n * if (url.pathname === \"/api/inngest\") {\n * return serve({ client: inngest, functions })(request);\n * }\n *\n * return new Response(\"Not found\", { status: 404 });\n * },\n * });\n * ```\n *\n * @public\n */\n// Has explicit return type to avoid JSR-defined \"slow types\"\nexport const serve = (\n options: ServeHandlerOptions,\n): ((req: Request) => Promise<Response>) => {\n const optsOverrides: InternalServeHandlerOptions = {\n ...options,\n frameworkName,\n };\n\n return serveEdge(optsOverrides);\n};\n"],"mappings":";;;;;;;AAqCA,MAAaA,gBAAwC;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BrD,MAAa,SACX,YAC0C;AAM1C,QAAOC,mBAL4C;EACjD,GAAG;EACH;EACD,CAE8B"}