UNPKG

@trpc/server

Version:

The tRPC server library

45 lines (44 loc) • 2.75 kB
import { Ln as TRPCRequestInfo, jn as HTTPBaseHandlerOptions, rr as inferRouterContext, ur as CreateContextCallback, zn as AnyRouter } from "../../unstable-core-do-not-import-Db2TnFh8.cjs"; import { APIGatewayProxyEvent, APIGatewayProxyEventV2, APIGatewayProxyResult, APIGatewayProxyStructuredResultV2, Context, StreamifyHandler } from "aws-lambda"; //#region src/adapters/aws-lambda/getPlanner.d.ts type LambdaEvent = APIGatewayProxyEvent | APIGatewayProxyEventV2; /** 1:1 mapping of v1 or v2 input events, deduces which is which. * @internal **/ type inferAPIGWReturn<TEvent> = TEvent extends APIGatewayProxyEvent ? APIGatewayProxyResult : TEvent extends APIGatewayProxyEventV2 ? APIGatewayProxyStructuredResultV2 : never; //#endregion //#region src/adapters/aws-lambda/index.d.ts /** * What `createContext` gets in the AWS Lambda adapter: the event, the * Lambda context and the request's `info`. * @see https://trpc.io/docs/server/adapters/aws-lambda#2-create-a-trpc-router */ export type CreateAWSLambdaContextOptions<TEvent extends LambdaEvent> = { /** The API Gateway or function URL event. */ event: TEvent; /** The Lambda invocation's context. */ context: Context; info: TRPCRequestInfo; }; /** * The options of `awsLambdaRequestHandler` and * `awsLambdaStreamingRequestHandler`. * @see https://trpc.io/docs/server/adapters/aws-lambda */ export type AWSLambdaOptions<TRouter extends AnyRouter, TEvent extends LambdaEvent> = HTTPBaseHandlerOptions<TRouter, TEvent> & CreateContextCallback<inferRouterContext<AnyRouter>, AWSLambdaCreateContextFn<TRouter, TEvent>>; /** The `createContext` function the AWS Lambda adapter takes. */ export type AWSLambdaCreateContextFn<TRouter extends AnyRouter, TEvent extends LambdaEvent> = ({ event, context, info }: CreateAWSLambdaContextOptions<TEvent>) => inferRouterContext<TRouter> | Promise<inferRouterContext<TRouter>>; /** * Creates a Lambda handler for a router, for API Gateway (REST and HTTP * APIs) and Lambda function URLs. * @see https://trpc.io/docs/server/adapters/aws-lambda#3-use-the-amazon-api-gateway-adapter */ export declare function awsLambdaRequestHandler<TRouter extends AnyRouter, TEvent extends LambdaEvent>(opts: AWSLambdaOptions<TRouter, TEvent>): (event: TEvent, context: Context) => Promise<inferAPIGWReturn<TEvent>>; /** * Creates a Lambda handler that streams its response, for use with * `awslambda.streamifyResponse()`. * @see https://trpc.io/docs/server/adapters/aws-lambda#aws-lambda-response-streaming-adapter */ export declare function awsLambdaStreamingRequestHandler<TRouter extends AnyRouter, TEvent extends LambdaEvent>(opts: AWSLambdaOptions<TRouter, TEvent>): StreamifyHandler<TEvent>; //#endregion //# sourceMappingURL=index.d.cts.map