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.93 kB
Source Map (JSON)
{"version":3,"file":"astro.cjs","names":["frameworkName: SupportedFrameworkName","InngestCommHandler"],"sources":["../src/astro.ts"],"sourcesContent":["/**\n * An adapter for Astro to serve and register any declared functions with\n * Inngest, making them available to be triggered by events.\n *\n * @example\n * ```ts\n * export const { GET, POST, PUT } = serve({\n * client: inngest,\n * functions: [fn1, fn2],\n * });\n * ```\n *\n * @module\n */\n\nimport {\n InngestCommHandler,\n type ServeHandlerOptions,\n} from \"./components/InngestCommHandler.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 = \"astro\";\n\n/**\n * In Astro, serve and register any declared functions with Inngest, making them\n * available to be triggered by events.\n *\n * @example\n * ```ts\n * export const { GET, POST, PUT } = serve({\n * client: inngest,\n * functions: [fn1, fn2],\n * });\n * ```\n *\n * @public\n */\n// Has explicit return type to avoid JSR-defined \"slow types\"\nexport const serve = (\n options: ServeHandlerOptions,\n): ((ctx: { request: Request }) => Promise<Response>) & {\n GET: (ctx: { request: Request }) => Promise<Response>;\n POST: (ctx: { request: Request }) => Promise<Response>;\n PUT: (ctx: { request: Request }) => Promise<Response>;\n} => {\n const commHandler = new InngestCommHandler({\n frameworkName,\n ...options,\n handler: ({ request: req }: { request: Request }) => {\n return {\n body: () => req.text(),\n headers: (key) => req.headers.get(key),\n method: () => req.method,\n url: () => new URL(req.url, `https://${req.headers.get(\"host\") || \"\"}`),\n transformResponse: ({ body, status, headers }) => {\n return new Response(body, { status, headers });\n },\n };\n },\n });\n\n const requestHandler = commHandler.createHandler();\n type RequestHandler = typeof requestHandler;\n\n return Object.defineProperties(requestHandler, {\n GET: { value: requestHandler },\n POST: { value: requestHandler },\n PUT: { value: requestHandler },\n }) as RequestHandler & {\n GET: RequestHandler;\n POST: RequestHandler;\n PUT: RequestHandler;\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAyBA,MAAaA,gBAAwC;;;;;;;;;;;;;;;AAiBrD,MAAa,SACX,YAKG;CAiBH,MAAM,iBAhBc,IAAIC,8CAAmB;EACzC;EACA,GAAG;EACH,UAAU,EAAE,SAAS,UAAgC;AACnD,UAAO;IACL,YAAY,IAAI,MAAM;IACtB,UAAU,QAAQ,IAAI,QAAQ,IAAI,IAAI;IACtC,cAAc,IAAI;IAClB,WAAW,IAAI,IAAI,IAAI,KAAK,WAAW,IAAI,QAAQ,IAAI,OAAO,IAAI,KAAK;IACvE,oBAAoB,EAAE,MAAM,QAAQ,cAAc;AAChD,YAAO,IAAI,SAAS,MAAM;MAAE;MAAQ;MAAS,CAAC;;IAEjD;;EAEJ,CAAC,CAEiC,eAAe;AAGlD,QAAO,OAAO,iBAAiB,gBAAgB;EAC7C,KAAK,EAAE,OAAO,gBAAgB;EAC9B,MAAM,EAAE,OAAO,gBAAgB;EAC/B,KAAK,EAAE,OAAO,gBAAgB;EAC/B,CAAC"}