@geostrategists/react-router-aws 2.2.0 → 2.3.0-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +67 -0
- package/dist/index.cjs +352 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +661 -0
- package/dist/index.d.mts +583 -24
- package/dist/index.mjs +302 -305
- package/dist/index.mjs.map +1 -0
- package/package.json +43 -84
- package/biome.json +0 -47
- package/dist/index.d.ts +0 -102
- package/dist/index.js +0 -378
- package/test/alb.test.ts +0 -95
- package/test/apigw-v1.test.ts +0 -101
- package/test/apigw-v2.test.ts +0 -107
- package/test/function-url-streaming.test.ts +0 -107
- package/test/function-url.test.ts +0 -107
- package/test/lambda-stream/HttpResponseStream.ts +0 -34
- package/test/lambda-stream/ResponseStream.ts +0 -44
- package/test/lambda-stream/index.ts +0 -56
- package/test/setup.ts +0 -7
- package/test/utils.ts +0 -69
- package/vitest.config.ts +0 -12
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["createReactRouterRequestHandler"],"sources":["../src/binaryTypes.ts","../src/adapters/host.ts","../src/adapters/api-gateway-v1.ts","../src/adapters/api-gateway-v2.ts","../src/adapters/application-load-balancer.ts","../src/adapters/function-url-streaming.ts","../src/server.ts","../src/legacy.ts"],"sourcesContent":["// TODO: check if we can replace this with https://www.npmjs.com/package/mime-types\n\n/**\n * Common binary MIME types\n * @see https://github.com/architect/functions/blob/45254fc1936a1794c185aac07e9889b241a2e5c6/src/http/helpers/binary-types.js\n */\nconst binaryTypes = [\n \"application/octet-stream\",\n // Docs\n \"application/epub+zip\",\n \"application/msword\",\n \"application/pdf\",\n \"application/rtf\",\n \"application/vnd.amazon.ebook\",\n \"application/vnd.ms-excel\",\n \"application/vnd.ms-powerpoint\",\n \"application/vnd.openxmlformats-officedocument.presentationml.presentation\",\n \"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet\",\n \"application/vnd.openxmlformats-officedocument.wordprocessingml.document\",\n // Fonts\n \"font/otf\",\n \"font/woff\",\n \"font/woff2\",\n // Images\n \"image/avif\",\n \"image/bmp\",\n \"image/gif\",\n \"image/jpeg\",\n \"image/png\",\n \"image/tiff\",\n \"image/vnd.microsoft.icon\",\n \"image/webp\",\n // Audio\n \"audio/3gpp\",\n \"audio/aac\",\n \"audio/basic\",\n \"audio/mpeg\",\n \"audio/ogg\",\n \"audio/wav\",\n \"audio/webm\",\n \"audio/x-aiff\",\n \"audio/x-midi\",\n \"audio/x-wav\",\n // Video\n \"video/3gpp\",\n \"video/mp2t\",\n \"video/mpeg\",\n \"video/ogg\",\n \"video/quicktime\",\n \"video/webm\",\n \"video/x-msvideo\",\n // Archives\n \"application/java-archive\",\n \"application/vnd.apple.installer+xml\",\n \"application/x-7z-compressed\",\n \"application/x-apple-diskimage\",\n \"application/x-bzip\",\n \"application/x-bzip2\",\n \"application/x-gzip\",\n \"application/x-java-archive\",\n \"application/x-rar-compressed\",\n \"application/x-tar\",\n \"application/x-zip\",\n \"application/zip\",\n];\n\nexport function isBinaryType(contentType: string | null | undefined): boolean {\n if (!contentType) {\n return false;\n }\n const [test] = contentType.split(\";\");\n return binaryTypes.includes(test);\n}\n","/**\n * Resolves the host used to build the `Request` URL from a raw host value\n * (e.g. an `x-forwarded-host`/`host` header or an API Gateway domain name).\n *\n * React Router derives the host for its built-in cross-origin (CSRF) check on\n * action requests from `new URL(request.url).host`, so the host constructed\n * here must be trustworthy and well-formed. Invalid characters are stripped and\n * the port is validated to avoid constructing a malformed URL (or leaking a\n * spoofed host) from a garbled header value.\n *\n * Mirrors the hardening done by the upstream `@react-router/architect` adapter.\n */\nexport function resolveHost(rawHost: string | undefined | null): string {\n const [rawHostname = \"\", portStr] = (rawHost ?? \"\").split(\":\");\n const hostname = rawHostname.split(/[\\\\/?#@]/)[0] || \"localhost\";\n const hostPort = Number.parseInt(portStr ?? \"\", 10);\n const port = Number.isSafeInteger(hostPort) ? hostPort : undefined;\n return `${hostname}${port ? `:${port}` : \"\"}`;\n}\n","import { readableStreamToString } from \"@react-router/node\";\nimport type { APIGatewayProxyEvent, APIGatewayProxyEventHeaders, APIGatewayProxyResult } from \"aws-lambda\";\nimport { URLSearchParams } from \"url\";\n\nimport { isBinaryType } from \"../binaryTypes\";\nimport { resolveHost } from \"./host\";\nimport type { GetHostFunction, ReactRouterAdapter } from \"./index\";\n\nfunction createReactRouterRequestAPIGatewayV1(\n event: APIGatewayProxyEvent,\n getHost?: GetHostFunction<APIGatewayProxyEvent>,\n): Request {\n const rawHost = getHost?.(event) ?? (event.headers[\"x-forwarded-host\"] || event.headers.Host);\n const host = resolveHost(rawHost);\n const scheme = event.headers[\"x-forwarded-proto\"] || \"http\";\n\n const rawQueryString = new URLSearchParams(event.queryStringParameters as Record<string, string>).toString();\n const search = rawQueryString.length > 0 ? `?${rawQueryString}` : \"\";\n const url = new URL(event.path + search, `${scheme}://${host}`);\n\n const isFormData = event.headers[\"content-type\"]?.includes(\"multipart/form-data\");\n // Note: No current way to abort these for AWS, but our router expects\n // requests to contain a signal, so it can detect aborted requests\n const controller = new AbortController();\n\n return new Request(url.href, {\n method: event.requestContext.httpMethod,\n headers: createReactRouterHeadersAPIGatewayV1(event.headers),\n signal: controller.signal,\n body:\n event.body && event.isBase64Encoded\n ? isFormData\n ? Buffer.from(event.body, \"base64\")\n : Buffer.from(event.body, \"base64\").toString()\n : event.body || undefined,\n });\n}\n\nfunction createReactRouterHeadersAPIGatewayV1(requestHeaders: APIGatewayProxyEventHeaders): Headers {\n const headers = new Headers();\n\n for (const [header, value] of Object.entries(requestHeaders)) {\n if (value) {\n headers.append(header, value);\n }\n }\n\n return headers;\n}\n\nasync function sendReactRouterResponseAPIGatewayV1(nodeResponse: Response): Promise<APIGatewayProxyResult> {\n const contentType = nodeResponse.headers.get(\"Content-Type\");\n const isBase64Encoded = isBinaryType(contentType);\n let body: string | undefined;\n\n if (nodeResponse.body) {\n if (isBase64Encoded) {\n body = await readableStreamToString(nodeResponse.body, \"base64\");\n } else {\n body = await nodeResponse.text();\n }\n }\n\n return {\n statusCode: nodeResponse.status,\n headers: Object.fromEntries(nodeResponse.headers.entries()),\n body: body || \"\",\n isBase64Encoded,\n };\n}\n\nexport type ApiGatewayV1Adapter = ReactRouterAdapter<APIGatewayProxyEvent, APIGatewayProxyResult>;\n\nexport const apiGatewayV1Adapter: ApiGatewayV1Adapter = {\n wrapHandler: (handler) => (e) => handler(e),\n createReactRouterRequest: createReactRouterRequestAPIGatewayV1,\n sendReactRouterResponse: sendReactRouterResponseAPIGatewayV1,\n};\n","import { readableStreamToString } from \"@react-router/node\";\nimport type {\n APIGatewayProxyEventHeaders,\n APIGatewayProxyEventV2,\n APIGatewayProxyStructuredResultV2,\n} from \"aws-lambda\";\n\nimport { isBinaryType } from \"../binaryTypes\";\nimport { resolveHost } from \"./host\";\nimport type { GetHostFunction, ReactRouterAdapter } from \"./index\";\n\nexport function createReactRouterRequestAPIGateywayV2(\n event: APIGatewayProxyEventV2,\n getHost?: GetHostFunction<APIGatewayProxyEventV2>,\n): Request {\n const rawHost = getHost?.(event) ?? (event.headers[\"x-forwarded-host\"] || event.headers.host);\n const host = resolveHost(rawHost);\n const search = event.rawQueryString.length ? `?${event.rawQueryString}` : \"\";\n const scheme = event.headers[\"x-forwarded-proto\"] || \"http\";\n\n const url = new URL(event.rawPath + search, `${scheme}://${host}`);\n const isFormData = event.headers[\"content-type\"]?.includes(\"multipart/form-data\");\n // Note: No current way to abort these for AWS, but our router expects\n // requests to contain a signal, so it can detect aborted requests\n const controller = new AbortController();\n\n return new Request(url.href, {\n method: event.requestContext.http.method,\n headers: createReactRouterHeadersAPIGatewayV2(event.headers, event.cookies),\n signal: controller.signal,\n body:\n event.body && event.isBase64Encoded\n ? isFormData\n ? Buffer.from(event.body, \"base64\")\n : Buffer.from(event.body, \"base64\").toString()\n : event.body,\n });\n}\n\nfunction createReactRouterHeadersAPIGatewayV2(\n requestHeaders: APIGatewayProxyEventHeaders,\n requestCookies?: string[],\n): Headers {\n const headers = new Headers();\n\n for (const [header, value] of Object.entries(requestHeaders)) {\n if (value) {\n headers.append(header, value);\n }\n }\n\n if (requestCookies) {\n headers.append(\"Cookie\", requestCookies.join(\"; \"));\n }\n\n return headers;\n}\n\nexport function extractAPIGatewayV2ResponseMetadata(nodeResponse: Response): {\n statusCode: number;\n headers: Record<string, string>;\n cookies: string[];\n} {\n // AWS API Gateway will send back set-cookies outside of response headers.\n const cookies = nodeResponse.headers.getSetCookie();\n if (cookies.length) {\n nodeResponse.headers.delete(\"Set-Cookie\");\n }\n\n return {\n statusCode: nodeResponse.status,\n headers: Object.fromEntries(nodeResponse.headers.entries()),\n cookies,\n };\n}\n\nasync function sendReactRouterResponseAPIGatewayV2(nodeResponse: Response): Promise<APIGatewayProxyStructuredResultV2> {\n const result: APIGatewayProxyStructuredResultV2 = extractAPIGatewayV2ResponseMetadata(nodeResponse);\n\n const contentType = nodeResponse.headers.get(\"Content-Type\");\n\n result.isBase64Encoded = isBinaryType(contentType);\n\n if (nodeResponse.body) {\n if (result.isBase64Encoded) {\n result.body = await readableStreamToString(nodeResponse.body, \"base64\");\n } else {\n result.body = await nodeResponse.text();\n }\n }\n\n return result;\n}\n\nexport type ApiGatewayV2Adapter = ReactRouterAdapter<APIGatewayProxyEventV2, APIGatewayProxyStructuredResultV2>;\n\nexport const apiGatewayV2Adapter: ApiGatewayV2Adapter = {\n wrapHandler: (handler) => (e) => handler(e),\n createReactRouterRequest: createReactRouterRequestAPIGateywayV2,\n sendReactRouterResponse: sendReactRouterResponseAPIGatewayV2,\n};\n","import { readableStreamToString } from \"@react-router/node\";\nimport type { ALBEvent, ALBEventHeaders, ALBResult } from \"aws-lambda\";\nimport { URLSearchParams } from \"url\";\n\nimport { isBinaryType } from \"../binaryTypes\";\nimport { resolveHost } from \"./host\";\nimport type { GetHostFunction, ReactRouterAdapter } from \"./index\";\n\nfunction createReactRouterRequestALB(event: ALBEvent, getHost?: GetHostFunction<ALBEvent>): Request {\n const headers = event?.headers || {};\n const host = resolveHost(getHost?.(event) ?? (headers[\"x-forwarded-host\"] || headers.Host));\n const scheme = headers[\"x-forwarded-proto\"] || \"http\";\n\n const rawQueryString = new URLSearchParams(event.queryStringParameters as Record<string, string>).toString();\n const search = rawQueryString.length > 0 ? `?${rawQueryString}` : \"\";\n const url = new URL(event.path + search, `${scheme}://${host}`);\n\n const isFormData = headers[\"content-type\"]?.includes(\"multipart/form-data\");\n\n // Note: No current way to abort these for AWS, but our router expects\n // requests to contain a signal, so it can detect aborted requests\n const controller = new AbortController();\n\n return new Request(url.href, {\n method: event.httpMethod,\n headers: createReactRouterHeadersALB(headers),\n signal: controller.signal,\n body:\n event.body && event.isBase64Encoded\n ? isFormData\n ? Buffer.from(event.body, \"base64\")\n : Buffer.from(event.body, \"base64\").toString()\n : event.body || undefined,\n });\n}\n\nfunction createReactRouterHeadersALB(requestHeaders: ALBEventHeaders): Headers {\n const headers = new Headers();\n\n for (const [header, value] of Object.entries(requestHeaders)) {\n if (value) {\n headers.append(header, value);\n }\n }\n\n return headers;\n}\n\nasync function sendReactRouterResponseALB(nodeResponse: Response): Promise<ALBResult> {\n const contentType = nodeResponse.headers.get(\"Content-Type\");\n const isBase64Encoded = isBinaryType(contentType);\n let body: string | undefined;\n\n if (nodeResponse.body) {\n if (isBase64Encoded) {\n body = await readableStreamToString(nodeResponse.body, \"base64\");\n } else {\n body = await nodeResponse.text();\n }\n }\n\n return {\n statusCode: nodeResponse.status,\n headers: Object.fromEntries(nodeResponse.headers.entries()),\n body: body || \"\",\n isBase64Encoded,\n };\n}\n\nexport type ApplicationLoadBalancerAdapter = ReactRouterAdapter<ALBEvent, ALBResult>;\n\nexport const applicationLoadBalancerAdapter: ApplicationLoadBalancerAdapter = {\n wrapHandler: (handler) => (e) => handler(e),\n createReactRouterRequest: createReactRouterRequestALB,\n sendReactRouterResponse: sendReactRouterResponseALB,\n};\n","import { writeReadableStreamToWritable } from \"@react-router/node\";\nimport type { LambdaFunctionURLEvent } from \"aws-lambda\";\nimport type { StreamifyHandler } from \"aws-lambda/handler\";\n\nimport { createReactRouterRequestAPIGateywayV2, extractAPIGatewayV2ResponseMetadata } from \"./api-gateway-v2\";\nimport type { ReactRouterAdapter } from \"./index\";\n\nconst emptyStream = () =>\n new ReadableStream({\n start(controller) {\n controller.enqueue(\"\");\n controller.close();\n },\n });\n\nconst sendReactRouterResponseFunctionUrlStreaming = async (\n response: Response,\n responseStream: awslambda.HttpResponseStream,\n) => {\n const metadata = extractAPIGatewayV2ResponseMetadata(response);\n\n let body = response.body;\n if (!body) {\n // Function URL needs a write to happen on the stream, otherwise it won't send headers.\n // See https://github.com/fastify/aws-lambda-fastify/issues/154#issuecomment-2614521719\n body = emptyStream();\n }\n\n const httpResponseStream = awslambda.HttpResponseStream.from(responseStream, metadata);\n\n await writeReadableStreamToWritable(body, httpResponseStream);\n};\n\nexport type FunctionUrlStreamingAdapter = ReactRouterAdapter<\n LambdaFunctionURLEvent,\n void,\n awslambda.HttpResponseStream,\n StreamifyHandler<LambdaFunctionURLEvent, void>\n>;\n\nexport const functionUrlStreamingAdapter: FunctionUrlStreamingAdapter = {\n wrapHandler: awslambda.streamifyResponse,\n createReactRouterRequest: createReactRouterRequestAPIGateywayV2,\n sendReactRouterResponse: sendReactRouterResponseFunctionUrlStreaming,\n};\n","import type {\n ALBEvent,\n ALBHandler,\n APIGatewayProxyEvent,\n APIGatewayProxyEventV2,\n APIGatewayProxyHandler,\n APIGatewayProxyHandlerV2,\n LambdaFunctionURLEvent,\n LambdaFunctionURLHandler,\n} from \"aws-lambda\";\nimport type { StreamifyHandler } from \"aws-lambda/handler\";\nimport {\n type AppLoadContext,\n createRequestHandler as createReactRouterRequestHandler,\n type RouterContextProvider,\n type ServerBuild,\n type UNSAFE_MiddlewareEnabled as MiddlewareEnabled,\n} from \"react-router\";\n\nimport type { GetHostFunction, ReactRouterAdapter } from \"./adapters\";\nimport { apiGatewayV1Adapter } from \"./adapters/api-gateway-v1\";\nimport { apiGatewayV2Adapter } from \"./adapters/api-gateway-v2\";\nimport { applicationLoadBalancerAdapter } from \"./adapters/application-load-balancer\";\nimport { functionUrlStreamingAdapter } from \"./adapters/function-url-streaming\";\n\ntype MaybePromise<T> = T | Promise<T>;\n\n/**\n * A function that returns the value to use as `context` in route `loader` and\n * `action` functions.\n *\n * You can think of this as an escape hatch that allows you to pass\n * environment/platform-specific values through to your loader/action.\n */\nexport type GetLoadContextFunction<E> = (\n event: E,\n) => MiddlewareEnabled extends true ? MaybePromise<RouterContextProvider> : MaybePromise<AppLoadContext>;\n\nexport type CreateRequestHandlerArgs<T> = {\n build: ServerBuild;\n getLoadContext?: GetLoadContextFunction<T>;\n mode?: string;\n /**\n * Override how the host for the request URL is derived from the Lambda event.\n *\n * React Router uses the request URL host (`new URL(request.url).host`) for its\n * built-in cross-origin (CSRF) check on action requests, comparing it against\n * the incoming `Origin` header. The returned value is sanitized (invalid\n * characters stripped, port validated) before use.\n *\n * Return `undefined`/`null` to fall back to the default: the\n * `x-forwarded-host` header (falling back to the `host`/`Host` header).\n *\n * Use this when the default forwarded host is not the host the browser sees.\n * For example, a Lambda Function URL behind CloudFront cannot use its\n * request-context domain name (always the internal `*.lambda-url` host), and\n * CloudFront does not forward the viewer host by default. Forward it yourself\n * (e.g. a CloudFront Function copying the viewer `Host` into a custom header)\n * and read that header here:\n *\n * ```ts\n * createFunctionURLRequestHandler({\n * build,\n * getHost: (event) => event.headers[\"x-viewer-host\"],\n * });\n * ```\n *\n * @remarks\n * The default currently uses the `x-forwarded-host` header, which is\n * client-controlled and can be spoofed. Because that host drives the CSRF\n * check, trusting it should be deliberate: the default will change to the\n * AWS-provided, non-spoofable request-context domain name\n * (`event.requestContext.domainName`) in the next major version (aligning with\n * the upstream `@react-router/architect` adapter), after which relying on a\n * forwarded header becomes an explicit opt-in via `getHost`. Setups where the\n * request-context host is not the browser-facing host (e.g. Function URLs\n * behind CloudFront) must set `getHost`.\n */\n getHost?: GetHostFunction<T>;\n};\n\n/**\n * Returns a request handler for AWS API Gateway V1\n *\n */\n/**\n * Returns a request handler for AWS API Gateway V1 events.\n *\n * @param options - The handler options, including the React Router server build,\n * optional getLoadContext function, and mode string.\n * @returns An AWS API Gateway V1 handler compatible with APIGatewayProxyHandler.\n */\nexport function createAPIGatewayV1RequestHandler(\n options: CreateRequestHandlerArgs<APIGatewayProxyEvent>,\n): APIGatewayProxyHandler {\n return createRequestHandlerForAdapter(apiGatewayV1Adapter, options);\n}\n\n/**\n * Returns a request handler for AWS API Gateway V2 events.\n *\n * @param options - The handler options, including the React Router server build,\n * optional getLoadContext function, and mode string.\n * @returns An AWS API Gateway V2 handler compatible with APIGatewayProxyHandlerV2.\n */\nexport function createAPIGatewayV2RequestHandler(\n options: CreateRequestHandlerArgs<APIGatewayProxyEventV2>,\n): APIGatewayProxyHandlerV2 {\n return createRequestHandlerForAdapter(apiGatewayV2Adapter, options);\n}\n\n/**\n * Returns a request handler for AWS Application Load Balancer events.\n *\n * @param options - The handler options, including the React Router server build,\n * optional getLoadContext function, and mode string.\n * @returns An AWS ALB handler compatible with ALBHandler.\n */\nexport function createALBRequestHandler(options: CreateRequestHandlerArgs<ALBEvent>): ALBHandler {\n return createRequestHandlerForAdapter(applicationLoadBalancerAdapter, options);\n}\n\n/**\n * Returns a request handler for AWS Lambda Function URL events (invoke mode BUFFERED).\n *\n * @param options - The handler options, including the React Router server build,\n * optional getLoadContext function, and mode string.\n * @returns An AWS Lambda Function URL handler compatible with Lambda Function URLs with InvokeMode BUFFERED.\n */\nexport function createFunctionURLRequestHandler(\n options: CreateRequestHandlerArgs<LambdaFunctionURLEvent>,\n): LambdaFunctionURLHandler {\n return createRequestHandlerForAdapter(apiGatewayV2Adapter, options);\n}\n\n/**\n * Returns a request handler for AWS Lambda Function URL events (invoke mode RESPONSE_STREAM).\n *\n * @param options - The handler options, including the React Router server build,\n * optional getLoadContext function, and mode string.\n * @returns A streaming AWS Lambda Function URL handler compatible with Lambda Function URLs with InvokeMode RESPONSE_STREAM.\n */\nexport function createFunctionURLStreamingRequestHandler(\n options: CreateRequestHandlerArgs<LambdaFunctionURLEvent>,\n): StreamifyHandler<LambdaFunctionURLEvent, void> {\n return createRequestHandlerForAdapter(functionUrlStreamingAdapter, options);\n}\n\nfunction createRequestHandlerForAdapter<E, Ret, Res, H>(\n awsAdapter: ReactRouterAdapter<E, Ret, Res, H>,\n { build, getLoadContext, mode = process.env.NODE_ENV, getHost }: CreateRequestHandlerArgs<E>,\n) {\n const handleRequest = createReactRouterRequestHandler(build, mode);\n\n return awsAdapter.wrapHandler(async (event, res) => {\n let request: Request;\n\n try {\n request = awsAdapter.createReactRouterRequest(event, getHost);\n } catch (e: unknown) {\n return await awsAdapter.sendReactRouterResponse(\n new Response(`Bad Request: ${e instanceof Error ? e.message : e}`, { status: 400 }),\n res,\n );\n }\n\n const loadContext = await getLoadContext?.(event);\n\n const response = await handleRequest(request, loadContext);\n\n return await awsAdapter.sendReactRouterResponse(response, res);\n });\n}\n","import type { ALBEvent, APIGatewayProxyEvent, APIGatewayProxyEventV2, LambdaFunctionURLEvent } from \"aws-lambda\";\n\nimport type { ReactRouterAdapter } from \"./adapters\";\n/* eslint-disable @typescript-eslint/no-explicit-any -- we need the any in extends parameters */\nimport type { ApiGatewayV1Adapter } from \"./adapters/api-gateway-v1\";\nimport type { ApiGatewayV2Adapter } from \"./adapters/api-gateway-v2\";\nimport type { ApplicationLoadBalancerAdapter } from \"./adapters/application-load-balancer\";\nimport type { FunctionUrlStreamingAdapter } from \"./adapters/function-url-streaming\";\nimport type { CreateRequestHandlerArgs } from \"./server\";\nimport {\n createALBRequestHandler,\n createAPIGatewayV1RequestHandler,\n createAPIGatewayV2RequestHandler,\n createFunctionURLRequestHandler,\n createFunctionURLStreamingRequestHandler,\n} from \"./server\";\n\nexport enum AWSProxy {\n APIGatewayV1 = \"APIGatewayV1\",\n APIGatewayV2 = \"APIGatewayV2\",\n ALB = \"ALB\",\n FunctionURL = \"FunctionURL\",\n FunctionURLStreaming = \"FunctionURLStreaming\",\n}\n\nexport type InferAdapter<T extends AWSProxy> = T extends AWSProxy.APIGatewayV1\n ? ApiGatewayV1Adapter\n : T extends AWSProxy.APIGatewayV2 | AWSProxy.FunctionURL\n ? ApiGatewayV2Adapter\n : T extends AWSProxy.ALB\n ? ApplicationLoadBalancerAdapter\n : T extends AWSProxy.FunctionURLStreaming\n ? FunctionUrlStreamingAdapter\n : never;\n\ntype InferEventType<T extends AWSProxy> =\n InferAdapter<T> extends ReactRouterAdapter<infer E, any, any, any> ? E : never;\ntype InferHandlerType<T extends AWSProxy> =\n InferAdapter<T> extends ReactRouterAdapter<any, any, any, infer H> ? H : never;\n\n/**\n * Returns a request handler for AWS that serves the response using React Router.\n *\n * @deprecated Use one of the gateway-specific create*RequestHandler methods instead for better tree-shaking.\n * - `createAPIGatewayV1RequestHandler`\n * - `createAPIGatewayV2RequestHandler`\n * - `createALBRequestHandler`\n * - `createFunctionURLRequestHandler`\n * - `createFunctionURLStreamingRequestHandler`\n */\nexport function createRequestHandler<T extends AWSProxy>(\n options: CreateRequestHandlerArgs<InferEventType<T>> & {\n awsProxy?: T;\n },\n): InferHandlerType<T> {\n const { awsProxy = AWSProxy.APIGatewayV2 as T, ...opts } = options;\n switch (awsProxy) {\n case AWSProxy.APIGatewayV1:\n return createAPIGatewayV1RequestHandler(\n opts as CreateRequestHandlerArgs<APIGatewayProxyEvent>,\n ) as InferHandlerType<T>;\n case AWSProxy.APIGatewayV2:\n return createAPIGatewayV2RequestHandler(\n opts as CreateRequestHandlerArgs<APIGatewayProxyEventV2>,\n ) as InferHandlerType<T>;\n case AWSProxy.ALB:\n return createALBRequestHandler(opts as CreateRequestHandlerArgs<ALBEvent>) as InferHandlerType<T>;\n case AWSProxy.FunctionURL:\n return createFunctionURLRequestHandler(\n opts as CreateRequestHandlerArgs<LambdaFunctionURLEvent>,\n ) as InferHandlerType<T>;\n case AWSProxy.FunctionURLStreaming:\n return createFunctionURLStreamingRequestHandler(\n opts as CreateRequestHandlerArgs<LambdaFunctionURLEvent>,\n ) as InferHandlerType<T>;\n default:\n return assertNever(awsProxy, `Unsupported buffered AWS Proxy type: ${awsProxy}`);\n }\n}\n\nfunction assertNever(_x: never, message: string): never {\n throw new Error(message);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAMA,MAAM,cAAc;CAClB;CAEA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CAEA;CACA;CACA;CAEA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CAEA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CAEA;CACA;CACA;CACA;CACA;CACA;CACA;CAEA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAEA,SAAgB,aAAa,aAAiD;CAC5E,IAAI,CAAC,aACH,OAAO;CAET,MAAM,CAAC,QAAQ,YAAY,MAAM,GAAG;CACpC,OAAO,YAAY,SAAS,IAAI;AAClC;;;;;;;;;;;;;;;AC5DA,SAAgB,YAAY,SAA4C;CACtE,MAAM,CAAC,cAAc,IAAI,YAAY,WAAW,GAAA,CAAI,MAAM,GAAG;CAC7D,MAAM,WAAW,YAAY,MAAM,UAAU,CAAC,CAAC,MAAM;CACrD,MAAM,WAAW,OAAO,SAAS,WAAW,IAAI,EAAE;CAClD,MAAM,OAAO,OAAO,cAAc,QAAQ,IAAI,WAAW,KAAA;CACzD,OAAO,GAAG,WAAW,OAAO,IAAI,SAAS;AAC3C;;;ACVA,SAAS,qCACP,OACA,SACS;CAET,MAAM,OAAO,YADG,UAAU,KAAK,MAAM,MAAM,QAAQ,uBAAuB,MAAM,QAAQ,KACxD;CAChC,MAAM,SAAS,MAAM,QAAQ,wBAAwB;CAErD,MAAM,iBAAiB,IAAI,gBAAgB,MAAM,qBAA+C,CAAC,CAAC,SAAS;CAC3G,MAAM,SAAS,eAAe,SAAS,IAAI,IAAI,mBAAmB;CAClE,MAAM,MAAM,IAAI,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I,SAAS,gBAAgB,aAAa,QAAQ,EAAE,UAAU,KAAK,EAAE,QAAQ,IAAI,CAAC,GAClF,GACF;EACF;EAEA,MAAM,cAAc,MAAM,iBAAiB,KAAK;EAEhD,MAAM,WAAW,MAAM,cAAc,SAAS,WAAW;EAEzD,OAAO,MAAM,WAAW,wBAAwB,UAAU,GAAG;CAC/D,CAAC;AACH;;;AC3JA,IAAY,WAAL,yBAAA,UAAA;CACL,SAAA,kBAAA;CACA,SAAA,kBAAA;CACA,SAAA,SAAA;CACA,SAAA,iBAAA;CACA,SAAA,0BAAA;;AACF,EAAA,CAAA,CAAA;;;;;;;;;;;AA2BA,SAAgB,qBACd,SAGqB;CACrB,MAAM,EAAE,WAAA,gBAAuC,GAAG,SAAS;CAC3D,QAAQ,UAAR;EACE,KAAA,gBACE,OAAO,iCACL,IACF;EACF,KAAA,gBACE,OAAO,iCACL,IACF;EACF,KAAA,OACE,OAAO,wBAAwB,IAA0C;EAC3E,KAAA,eACE,OAAO,gCACL,IACF;EACF,KAAA,wBACE,OAAO,yCACL,IACF;EACF,SACE,OAAO,YAAY,UAAU,wCAAwC,UAAU;CACnF;AACF;AAEA,SAAS,YAAY,IAAW,SAAwB;CACtD,MAAM,IAAI,MAAM,OAAO;AACzB"}
|
package/package.json
CHANGED
|
@@ -1,113 +1,72 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@geostrategists/react-router-aws",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.0-rc.0",
|
|
4
4
|
"description": "AWS adapter for React Router v7",
|
|
5
|
-
"
|
|
5
|
+
"homepage": "https://github.com/geostrategists/react-router-aws#readme",
|
|
6
6
|
"bugs": {
|
|
7
7
|
"url": "https://github.com/geostrategists/react-router-aws/issues"
|
|
8
8
|
},
|
|
9
|
+
"license": "MIT",
|
|
9
10
|
"repository": {
|
|
10
11
|
"type": "git",
|
|
11
12
|
"url": "git+https://github.com/geostrategists/react-router-aws.git"
|
|
12
13
|
},
|
|
14
|
+
"files": [
|
|
15
|
+
"dist"
|
|
16
|
+
],
|
|
17
|
+
"type": "module",
|
|
18
|
+
"sideEffects": false,
|
|
19
|
+
"main": "./dist/index.cjs",
|
|
20
|
+
"module": "./dist/index.mjs",
|
|
21
|
+
"types": "./dist/index.d.mts",
|
|
13
22
|
"exports": {
|
|
14
23
|
".": {
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
"default": "./dist/index.js"
|
|
19
|
-
},
|
|
20
|
-
"import": {
|
|
21
|
-
"types": "./dist/index.d.mts",
|
|
22
|
-
"default": "./dist/index.mjs"
|
|
24
|
+
"types": {
|
|
25
|
+
"import": "./dist/index.d.mts",
|
|
26
|
+
"require": "./dist/index.d.cts"
|
|
23
27
|
},
|
|
24
|
-
"
|
|
25
|
-
|
|
26
|
-
"default": "./dist/index.js"
|
|
27
|
-
}
|
|
28
|
+
"import": "./dist/index.mjs",
|
|
29
|
+
"require": "./dist/index.cjs"
|
|
28
30
|
},
|
|
29
31
|
"./package.json": "./package.json"
|
|
30
32
|
},
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
"format": "biome format --write .",
|
|
34
|
-
"format:check": "biome format .",
|
|
35
|
-
"typecheck": "tsc --noEmit",
|
|
36
|
-
"build": "tsc && tsup",
|
|
37
|
-
"prepack": "yarn build && yarn npmignore --auto",
|
|
38
|
-
"prepare": "husky",
|
|
39
|
-
"release": "semantic-release",
|
|
40
|
-
"test": "vitest run",
|
|
41
|
-
"test:watch": "vitest"
|
|
42
|
-
},
|
|
43
|
-
"peerDependencies": {
|
|
44
|
-
"@react-router/dev": "^7.9.1",
|
|
45
|
-
"@react-router/node": "^7.9.1",
|
|
46
|
-
"react-router": "^7.9.1"
|
|
33
|
+
"publishConfig": {
|
|
34
|
+
"access": "public"
|
|
47
35
|
},
|
|
48
36
|
"devDependencies": {
|
|
49
|
-
"@
|
|
50
|
-
"@eslint/js": "^9.22.0",
|
|
51
|
-
"@react-router/dev": "^7.9.1",
|
|
52
|
-
"@react-router/node": "^7.9.1",
|
|
53
|
-
"@semantic-release/exec": "^7.0.3",
|
|
37
|
+
"@react-router/node": "^7.18.0",
|
|
54
38
|
"@types/aws-lambda": "^8.10.152",
|
|
55
|
-
"@types/node": "^
|
|
39
|
+
"@types/node": "^22.19.21",
|
|
56
40
|
"@types/react": "^19",
|
|
57
41
|
"@types/react-dom": "^19",
|
|
58
42
|
"@vitest/coverage-v8": "^3.2.4",
|
|
59
|
-
"
|
|
60
|
-
"
|
|
61
|
-
"
|
|
62
|
-
"npmignore": "^0.3.1",
|
|
63
|
-
"prettier": "3.5.3",
|
|
43
|
+
"lefthook": "^2.1.9",
|
|
44
|
+
"oxfmt": "^0.54.0",
|
|
45
|
+
"oxlint": "^1.69.0",
|
|
64
46
|
"react": "^19.1.1",
|
|
65
47
|
"react-dom": "^19.1.1",
|
|
66
|
-
"react-router": "^7.
|
|
67
|
-
"
|
|
68
|
-
"
|
|
69
|
-
"typescript": "^5.9.
|
|
70
|
-
"typescript-eslint": "^8.41.0",
|
|
48
|
+
"react-router": "^7.18.0",
|
|
49
|
+
"rimraf": "^6.1.2",
|
|
50
|
+
"tsdown": "^0.22.2",
|
|
51
|
+
"typescript": "^5.9.3",
|
|
71
52
|
"vitest": "^3.2.4"
|
|
72
53
|
},
|
|
73
|
-
"
|
|
74
|
-
|
|
75
|
-
"
|
|
76
|
-
"@semantic-release/commit-analyzer",
|
|
77
|
-
"@semantic-release/release-notes-generator",
|
|
78
|
-
[
|
|
79
|
-
"@semantic-release/exec",
|
|
80
|
-
{
|
|
81
|
-
"verifyConditionsCmd": "echo //npm.pkg.github.com/:_authToken=${process.env.GITHUB_TOKEN} > /tmp/github.npmrc && npm whoami --userconfig /tmp/github.npmrc --registry https://npm.pkg.github.com/",
|
|
82
|
-
"publishCmd": "npm publish --userconfig /tmp/github.npmrc --tag ${nextRelease.channel || 'latest'} --registry https://npm.pkg.github.com/ --no-git-tag-version",
|
|
83
|
-
"successCmd": "rm /tmp/github.npmrc",
|
|
84
|
-
"failCmd": "rm /tmp/github.npmrc"
|
|
85
|
-
}
|
|
86
|
-
],
|
|
87
|
-
"@semantic-release/npm",
|
|
88
|
-
"@semantic-release/github"
|
|
89
|
-
]
|
|
90
|
-
},
|
|
91
|
-
"publishConfig": {
|
|
92
|
-
"ignore": [
|
|
93
|
-
"!dist/**",
|
|
94
|
-
"src/",
|
|
95
|
-
".*",
|
|
96
|
-
"tsconfig.json",
|
|
97
|
-
"tsup.config.ts"
|
|
98
|
-
],
|
|
99
|
-
"access": "public",
|
|
100
|
-
"provenance": true
|
|
54
|
+
"peerDependencies": {
|
|
55
|
+
"@react-router/node": "^7.18.0",
|
|
56
|
+
"react-router": "^7.18.0"
|
|
101
57
|
},
|
|
102
|
-
"
|
|
103
|
-
"
|
|
104
|
-
"eslint --fix",
|
|
105
|
-
"prettier --write"
|
|
106
|
-
],
|
|
107
|
-
"!(*.ts|*.tsx|*.js|*.cjs|*.mjs)": "prettier --ignore-unknown --write"
|
|
58
|
+
"engines": {
|
|
59
|
+
"node": ">=22"
|
|
108
60
|
},
|
|
109
|
-
"
|
|
110
|
-
"
|
|
111
|
-
"
|
|
61
|
+
"scripts": {
|
|
62
|
+
"build": "tsdown",
|
|
63
|
+
"clean": "rimraf dist",
|
|
64
|
+
"lint": "oxlint",
|
|
65
|
+
"lint:fix": "oxlint --fix",
|
|
66
|
+
"format": "oxfmt . '!**/*.yml' '!**/*.yaml'",
|
|
67
|
+
"format:check": "oxfmt --check . '!**/*.yml' '!**/*.yaml'",
|
|
68
|
+
"typecheck": "tsc --noEmit",
|
|
69
|
+
"test": "vitest run",
|
|
70
|
+
"test:watch": "vitest"
|
|
112
71
|
}
|
|
113
|
-
}
|
|
72
|
+
}
|
package/biome.json
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "https://biomejs.dev/schemas/2.2.2/schema.json",
|
|
3
|
-
"vcs": {
|
|
4
|
-
"enabled": true,
|
|
5
|
-
"clientKind": "git",
|
|
6
|
-
"useIgnoreFile": true
|
|
7
|
-
},
|
|
8
|
-
"files": {
|
|
9
|
-
"ignoreUnknown": false
|
|
10
|
-
},
|
|
11
|
-
"formatter": {
|
|
12
|
-
"enabled": true,
|
|
13
|
-
"indentStyle": "space",
|
|
14
|
-
"lineWidth": 120
|
|
15
|
-
},
|
|
16
|
-
"linter": {
|
|
17
|
-
"enabled": true,
|
|
18
|
-
"rules": {
|
|
19
|
-
"recommended": true
|
|
20
|
-
}
|
|
21
|
-
},
|
|
22
|
-
"javascript": {
|
|
23
|
-
"formatter": {
|
|
24
|
-
"quoteStyle": "double"
|
|
25
|
-
}
|
|
26
|
-
},
|
|
27
|
-
"assist": {
|
|
28
|
-
"enabled": true,
|
|
29
|
-
"actions": {
|
|
30
|
-
"source": {
|
|
31
|
-
"organizeImports": "on"
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
},
|
|
35
|
-
"overrides": [
|
|
36
|
-
{
|
|
37
|
-
"includes": ["test/**"],
|
|
38
|
-
"linter": {
|
|
39
|
-
"rules": {
|
|
40
|
-
"suspicious": {
|
|
41
|
-
"noExplicitAny": "off"
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
]
|
|
47
|
-
}
|
package/dist/index.d.ts
DELETED
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import { UNSAFE_MiddlewareEnabled, RouterContextProvider, AppLoadContext, ServerBuild } from 'react-router';
|
|
2
|
-
import { ALBEvent, ALBHandler, APIGatewayProxyEvent, APIGatewayProxyHandler, APIGatewayProxyEventV2, APIGatewayProxyHandlerV2, LambdaFunctionURLEvent, LambdaFunctionURLHandler, Handler, APIGatewayProxyResult, APIGatewayProxyStructuredResultV2, ALBResult } from 'aws-lambda';
|
|
3
|
-
import { StreamifyHandler } from 'aws-lambda/handler';
|
|
4
|
-
|
|
5
|
-
type MaybePromise<T> = T | Promise<T>;
|
|
6
|
-
/**
|
|
7
|
-
* A function that returns the value to use as `context` in route `loader` and
|
|
8
|
-
* `action` functions.
|
|
9
|
-
*
|
|
10
|
-
* You can think of this as an escape hatch that allows you to pass
|
|
11
|
-
* environment/platform-specific values through to your loader/action.
|
|
12
|
-
*/
|
|
13
|
-
type GetLoadContextFunction<E> = (event: E) => UNSAFE_MiddlewareEnabled extends true ? MaybePromise<RouterContextProvider> : MaybePromise<AppLoadContext>;
|
|
14
|
-
type CreateRequestHandlerArgs<T> = {
|
|
15
|
-
build: ServerBuild;
|
|
16
|
-
getLoadContext?: GetLoadContextFunction<T>;
|
|
17
|
-
mode?: string;
|
|
18
|
-
};
|
|
19
|
-
/**
|
|
20
|
-
* Returns a request handler for AWS API Gateway V1
|
|
21
|
-
*
|
|
22
|
-
*/
|
|
23
|
-
/**
|
|
24
|
-
* Returns a request handler for AWS API Gateway V1 events.
|
|
25
|
-
*
|
|
26
|
-
* @param options - The handler options, including the React Router server build,
|
|
27
|
-
* optional getLoadContext function, and mode string.
|
|
28
|
-
* @returns An AWS API Gateway V1 handler compatible with APIGatewayProxyHandler.
|
|
29
|
-
*/
|
|
30
|
-
declare function createAPIGatewayV1RequestHandler(options: CreateRequestHandlerArgs<APIGatewayProxyEvent>): APIGatewayProxyHandler;
|
|
31
|
-
/**
|
|
32
|
-
* Returns a request handler for AWS API Gateway V2 events.
|
|
33
|
-
*
|
|
34
|
-
* @param options - The handler options, including the React Router server build,
|
|
35
|
-
* optional getLoadContext function, and mode string.
|
|
36
|
-
* @returns An AWS API Gateway V2 handler compatible with APIGatewayProxyHandlerV2.
|
|
37
|
-
*/
|
|
38
|
-
declare function createAPIGatewayV2RequestHandler(options: CreateRequestHandlerArgs<APIGatewayProxyEventV2>): APIGatewayProxyHandlerV2;
|
|
39
|
-
/**
|
|
40
|
-
* Returns a request handler for AWS Application Load Balancer events.
|
|
41
|
-
*
|
|
42
|
-
* @param options - The handler options, including the React Router server build,
|
|
43
|
-
* optional getLoadContext function, and mode string.
|
|
44
|
-
* @returns An AWS ALB handler compatible with ALBHandler.
|
|
45
|
-
*/
|
|
46
|
-
declare function createALBRequestHandler(options: CreateRequestHandlerArgs<ALBEvent>): ALBHandler;
|
|
47
|
-
/**
|
|
48
|
-
* Returns a request handler for AWS Lambda Function URL events (invoke mode BUFFERED).
|
|
49
|
-
*
|
|
50
|
-
* @param options - The handler options, including the React Router server build,
|
|
51
|
-
* optional getLoadContext function, and mode string.
|
|
52
|
-
* @returns An AWS Lambda Function URL handler compatible with Lambda Function URLs with InvokeMode BUFFERED.
|
|
53
|
-
*/
|
|
54
|
-
declare function createFunctionURLRequestHandler(options: CreateRequestHandlerArgs<LambdaFunctionURLEvent>): LambdaFunctionURLHandler;
|
|
55
|
-
/**
|
|
56
|
-
* Returns a request handler for AWS Lambda Function URL events (invoke mode RESPONSE_STREAM).
|
|
57
|
-
*
|
|
58
|
-
* @param options - The handler options, including the React Router server build,
|
|
59
|
-
* optional getLoadContext function, and mode string.
|
|
60
|
-
* @returns A streaming AWS Lambda Function URL handler compatible with Lambda Function URLs with InvokeMode RESPONSE_STREAM.
|
|
61
|
-
*/
|
|
62
|
-
declare function createFunctionURLStreamingRequestHandler(options: CreateRequestHandlerArgs<LambdaFunctionURLEvent>): StreamifyHandler<LambdaFunctionURLEvent, void>;
|
|
63
|
-
|
|
64
|
-
interface ReactRouterAdapter<E, Ret, Res = void, H = Handler<E, Ret>> {
|
|
65
|
-
wrapHandler: (handler: (event: E, res: Res) => Promise<Ret>) => H;
|
|
66
|
-
createReactRouterRequest: (event: E) => Request;
|
|
67
|
-
sendReactRouterResponse: (nodeResponse: Response, response: Res) => Promise<Ret>;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
type ApiGatewayV1Adapter = ReactRouterAdapter<APIGatewayProxyEvent, APIGatewayProxyResult>;
|
|
71
|
-
|
|
72
|
-
type ApiGatewayV2Adapter = ReactRouterAdapter<APIGatewayProxyEventV2, APIGatewayProxyStructuredResultV2>;
|
|
73
|
-
|
|
74
|
-
type ApplicationLoadBalancerAdapter = ReactRouterAdapter<ALBEvent, ALBResult>;
|
|
75
|
-
|
|
76
|
-
type FunctionUrlStreamingAdapter = ReactRouterAdapter<LambdaFunctionURLEvent, void, awslambda.HttpResponseStream, StreamifyHandler<LambdaFunctionURLEvent, void>>;
|
|
77
|
-
|
|
78
|
-
declare enum AWSProxy {
|
|
79
|
-
APIGatewayV1 = "APIGatewayV1",
|
|
80
|
-
APIGatewayV2 = "APIGatewayV2",
|
|
81
|
-
ALB = "ALB",
|
|
82
|
-
FunctionURL = "FunctionURL",
|
|
83
|
-
FunctionURLStreaming = "FunctionURLStreaming"
|
|
84
|
-
}
|
|
85
|
-
type InferAdapter<T extends AWSProxy> = T extends AWSProxy.APIGatewayV1 ? ApiGatewayV1Adapter : T extends AWSProxy.APIGatewayV2 | AWSProxy.FunctionURL ? ApiGatewayV2Adapter : T extends AWSProxy.ALB ? ApplicationLoadBalancerAdapter : T extends AWSProxy.FunctionURLStreaming ? FunctionUrlStreamingAdapter : never;
|
|
86
|
-
type InferEventType<T extends AWSProxy> = InferAdapter<T> extends ReactRouterAdapter<infer E, any, any, any> ? E : never;
|
|
87
|
-
type InferHandlerType<T extends AWSProxy> = InferAdapter<T> extends ReactRouterAdapter<any, any, any, infer H> ? H : never;
|
|
88
|
-
/**
|
|
89
|
-
* Returns a request handler for AWS that serves the response using React Router.
|
|
90
|
-
*
|
|
91
|
-
* @deprecated Use one of the gateway-specific create*RequestHandler methods instead for better tree-shaking.
|
|
92
|
-
* - `createAPIGatewayV1RequestHandler`
|
|
93
|
-
* - `createAPIGatewayV2RequestHandler`
|
|
94
|
-
* - `createALBRequestHandler`
|
|
95
|
-
* - `createFunctionURLRequestHandler`
|
|
96
|
-
* - `createFunctionURLStreamingRequestHandler`
|
|
97
|
-
*/
|
|
98
|
-
declare function createRequestHandler<T extends AWSProxy>(options: CreateRequestHandlerArgs<InferEventType<T>> & {
|
|
99
|
-
awsProxy?: T;
|
|
100
|
-
}): InferHandlerType<T>;
|
|
101
|
-
|
|
102
|
-
export { AWSProxy, type GetLoadContextFunction, createALBRequestHandler, createAPIGatewayV1RequestHandler, createAPIGatewayV2RequestHandler, createFunctionURLRequestHandler, createFunctionURLStreamingRequestHandler, createRequestHandler };
|