@trpc/server 11.0.0-rc.359 → 11.0.0-rc.362
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/dist/@trpc/server/http.d.ts +7 -6
- package/dist/@trpc/server/http.d.ts.map +1 -1
- package/dist/@trpc/server/index.d.ts +1 -1
- package/dist/@trpc/server/index.d.ts.map +1 -1
- package/dist/adapters/aws-lambda/getPlanner.d.ts +13 -0
- package/dist/adapters/aws-lambda/getPlanner.d.ts.map +1 -0
- package/dist/adapters/aws-lambda/getPlanner.js +143 -0
- package/dist/adapters/aws-lambda/getPlanner.mjs +141 -0
- package/dist/adapters/aws-lambda/index.d.ts +12 -9
- package/dist/adapters/aws-lambda/index.d.ts.map +1 -1
- package/dist/adapters/aws-lambda/index.js +6 -65
- package/dist/adapters/aws-lambda/index.mjs +8 -61
- package/dist/adapters/express.d.ts.map +1 -1
- package/dist/adapters/express.js +1 -1
- package/dist/adapters/express.mjs +1 -1
- package/dist/adapters/fastify/fastifyRequestHandler.d.ts +10 -1
- package/dist/adapters/fastify/fastifyRequestHandler.d.ts.map +1 -1
- package/dist/adapters/fastify/fastifyRequestHandler.js +12 -55
- package/dist/adapters/fastify/fastifyRequestHandler.mjs +13 -56
- package/dist/adapters/fastify/fastifyTRPCPlugin.d.ts +1 -1
- package/dist/adapters/fastify/fastifyTRPCPlugin.d.ts.map +1 -1
- package/dist/adapters/fetch/fetchRequestHandler.d.ts +1 -5
- package/dist/adapters/fetch/fetchRequestHandler.d.ts.map +1 -1
- package/dist/adapters/fetch/fetchRequestHandler.js +28 -71
- package/dist/adapters/fetch/fetchRequestHandler.mjs +29 -72
- package/dist/adapters/fetch/types.d.ts +9 -12
- package/dist/adapters/fetch/types.d.ts.map +1 -1
- package/dist/adapters/next-app-dir/nextAppDirCaller.d.ts +2 -7
- package/dist/adapters/next-app-dir/nextAppDirCaller.d.ts.map +1 -1
- package/dist/adapters/next.d.ts.map +1 -1
- package/dist/adapters/next.js +1 -2
- package/dist/adapters/next.mjs +1 -2
- package/dist/adapters/node-http/incomingMessageToRequest.d.ts +18 -0
- package/dist/adapters/node-http/incomingMessageToRequest.d.ts.map +1 -0
- package/dist/adapters/node-http/incomingMessageToRequest.js +71 -0
- package/dist/adapters/node-http/incomingMessageToRequest.mjs +69 -0
- package/dist/adapters/node-http/index.d.ts +1 -0
- package/dist/adapters/node-http/index.d.ts.map +1 -1
- package/dist/adapters/node-http/index.js +2 -0
- package/dist/adapters/node-http/index.mjs +1 -0
- package/dist/adapters/node-http/nodeHTTPRequestHandler.d.ts +1 -1
- package/dist/adapters/node-http/nodeHTTPRequestHandler.d.ts.map +1 -1
- package/dist/adapters/node-http/nodeHTTPRequestHandler.js +27 -72
- package/dist/adapters/node-http/nodeHTTPRequestHandler.mjs +28 -73
- package/dist/adapters/node-http/types.d.ts +2 -14
- package/dist/adapters/node-http/types.d.ts.map +1 -1
- package/dist/adapters/standalone.d.ts.map +1 -1
- package/dist/adapters/standalone.js +0 -1
- package/dist/adapters/standalone.mjs +0 -1
- package/dist/adapters/ws.d.ts +2 -12
- package/dist/adapters/ws.d.ts.map +1 -1
- package/dist/adapters/ws.js +1 -1
- package/dist/adapters/ws.mjs +1 -1
- package/dist/bundle-analysis.json +173 -259
- package/dist/http.js +4 -4
- package/dist/http.mjs +2 -2
- package/dist/index.js +2 -2
- package/dist/index.mjs +1 -1
- package/dist/unstable-core-do-not-import/http/contentType.d.ts +8 -28
- package/dist/unstable-core-do-not-import/http/contentType.d.ts.map +1 -1
- package/dist/unstable-core-do-not-import/http/contentType.js +164 -38
- package/dist/unstable-core-do-not-import/http/contentType.mjs +164 -38
- package/dist/unstable-core-do-not-import/http/contentTypeParsers.d.ts +14 -0
- package/dist/unstable-core-do-not-import/http/contentTypeParsers.d.ts.map +1 -0
- package/dist/unstable-core-do-not-import/http/contentTypeParsers.js +14 -0
- package/dist/unstable-core-do-not-import/http/contentTypeParsers.mjs +12 -0
- package/dist/unstable-core-do-not-import/http/getHTTPStatusCode.d.ts +1 -1
- package/dist/unstable-core-do-not-import/http/getHTTPStatusCode.d.ts.map +1 -1
- package/dist/unstable-core-do-not-import/http/resolveHTTPResponse.d.ts +7 -43
- package/dist/unstable-core-do-not-import/http/resolveHTTPResponse.d.ts.map +1 -1
- package/dist/unstable-core-do-not-import/http/resolveHTTPResponse.js +115 -124
- package/dist/unstable-core-do-not-import/http/resolveHTTPResponse.mjs +116 -125
- package/dist/unstable-core-do-not-import/http/types.d.ts +25 -29
- package/dist/unstable-core-do-not-import/http/types.d.ts.map +1 -1
- package/dist/unstable-core-do-not-import/initTRPC.d.ts +1 -1
- package/dist/unstable-core-do-not-import/procedureBuilder.d.ts +1 -3
- package/dist/unstable-core-do-not-import/procedureBuilder.d.ts.map +1 -1
- package/dist/unstable-core-do-not-import/procedureBuilder.js +0 -2
- package/dist/unstable-core-do-not-import/procedureBuilder.mjs +1 -2
- package/dist/unstable-core-do-not-import/rootConfig.d.ts +12 -0
- package/dist/unstable-core-do-not-import/rootConfig.d.ts.map +1 -1
- package/dist/unstable-core-do-not-import/utils.d.ts +3 -0
- package/dist/unstable-core-do-not-import/utils.d.ts.map +1 -1
- package/dist/unstable-core-do-not-import/utils.js +2 -0
- package/dist/unstable-core-do-not-import/utils.mjs +2 -1
- package/dist/unstable-core-do-not-import.d.ts +9 -3
- package/dist/unstable-core-do-not-import.d.ts.map +1 -1
- package/dist/unstable-core-do-not-import.js +11 -9
- package/dist/unstable-core-do-not-import.mjs +7 -6
- package/package.json +3 -14
- package/src/@trpc/server/http.ts +7 -13
- package/src/@trpc/server/index.ts +1 -0
- package/src/adapters/aws-lambda/getPlanner.ts +191 -0
- package/src/adapters/aws-lambda/index.ts +43 -92
- package/src/adapters/express.ts +1 -6
- package/src/adapters/fastify/fastifyRequestHandler.ts +22 -77
- package/src/adapters/fastify/fastifyTRPCPlugin.ts +1 -1
- package/src/adapters/fetch/fetchRequestHandler.ts +34 -98
- package/src/adapters/fetch/types.ts +24 -15
- package/src/adapters/next-app-dir/nextAppDirCaller.ts +2 -9
- package/src/adapters/next.ts +1 -6
- package/src/adapters/node-http/incomingMessageToRequest.ts +94 -0
- package/src/adapters/node-http/index.ts +1 -0
- package/src/adapters/node-http/nodeHTTPRequestHandler.ts +31 -110
- package/src/adapters/node-http/types.ts +9 -19
- package/src/adapters/standalone.ts +1 -2
- package/src/adapters/ws.ts +9 -14
- package/src/unstable-core-do-not-import/http/contentType.ts +199 -82
- package/src/unstable-core-do-not-import/http/contentTypeParsers.ts +29 -0
- package/src/unstable-core-do-not-import/http/getHTTPStatusCode.ts +2 -2
- package/src/unstable-core-do-not-import/http/resolveHTTPResponse.ts +133 -205
- package/src/unstable-core-do-not-import/http/types.ts +25 -32
- package/src/unstable-core-do-not-import/procedureBuilder.ts +2 -4
- package/src/unstable-core-do-not-import/rootConfig.ts +21 -0
- package/src/unstable-core-do-not-import/utils.ts +4 -0
- package/src/unstable-core-do-not-import.ts +9 -3
- package/adapters/node-http/content-type/form-data/index.d.ts +0 -1
- package/adapters/node-http/content-type/form-data/index.js +0 -1
- package/adapters/node-http/content-type/json/index.d.ts +0 -1
- package/adapters/node-http/content-type/json/index.js +0 -1
- package/dist/adapters/aws-lambda/utils.d.ts +0 -40
- package/dist/adapters/aws-lambda/utils.d.ts.map +0 -1
- package/dist/adapters/aws-lambda/utils.js +0 -100
- package/dist/adapters/aws-lambda/utils.mjs +0 -93
- package/dist/adapters/node-http/content-type/form-data/fileUploadHandler.d.ts +0 -73
- package/dist/adapters/node-http/content-type/form-data/fileUploadHandler.d.ts.map +0 -1
- package/dist/adapters/node-http/content-type/form-data/fileUploadHandler.js +0 -161
- package/dist/adapters/node-http/content-type/form-data/fileUploadHandler.mjs +0 -157
- package/dist/adapters/node-http/content-type/form-data/index.d.ts +0 -26
- package/dist/adapters/node-http/content-type/form-data/index.d.ts.map +0 -1
- package/dist/adapters/node-http/content-type/form-data/index.js +0 -135
- package/dist/adapters/node-http/content-type/form-data/index.mjs +0 -108
- package/dist/adapters/node-http/content-type/form-data/memoryUploadHandler.d.ts +0 -31
- package/dist/adapters/node-http/content-type/form-data/memoryUploadHandler.d.ts.map +0 -1
- package/dist/adapters/node-http/content-type/form-data/memoryUploadHandler.js +0 -29
- package/dist/adapters/node-http/content-type/form-data/memoryUploadHandler.mjs +0 -27
- package/dist/adapters/node-http/content-type/form-data/streamSlice.d.ts +0 -16
- package/dist/adapters/node-http/content-type/form-data/streamSlice.d.ts.map +0 -1
- package/dist/adapters/node-http/content-type/form-data/streamSlice.js +0 -46
- package/dist/adapters/node-http/content-type/form-data/streamSlice.mjs +0 -44
- package/dist/adapters/node-http/content-type/form-data/uploadHandler.d.ts +0 -45
- package/dist/adapters/node-http/content-type/form-data/uploadHandler.d.ts.map +0 -1
- package/dist/adapters/node-http/content-type/form-data/uploadHandler.js +0 -30
- package/dist/adapters/node-http/content-type/form-data/uploadHandler.mjs +0 -26
- package/dist/adapters/node-http/content-type/json/getPostBody.d.ts +0 -7
- package/dist/adapters/node-http/content-type/json/getPostBody.d.ts.map +0 -1
- package/dist/adapters/node-http/content-type/json/getPostBody.js +0 -53
- package/dist/adapters/node-http/content-type/json/getPostBody.mjs +0 -51
- package/dist/adapters/node-http/content-type/json/index.d.ts +0 -2
- package/dist/adapters/node-http/content-type/json/index.d.ts.map +0 -1
- package/dist/adapters/node-http/content-type/json/index.js +0 -16
- package/dist/adapters/node-http/content-type/json/index.mjs +0 -14
- package/dist/adapters/node-http/internals/contentType.d.ts +0 -9
- package/dist/adapters/node-http/internals/contentType.d.ts.map +0 -1
- package/dist/adapters/node-http/internals/contentType.js +0 -8
- package/dist/adapters/node-http/internals/contentType.mjs +0 -6
- package/dist/unstable-core-do-not-import/http/index.d.ts +0 -12
- package/dist/unstable-core-do-not-import/http/index.d.ts.map +0 -1
- package/src/adapters/aws-lambda/utils.ts +0 -164
- package/src/adapters/node-http/content-type/form-data/fileUploadHandler.ts +0 -277
- package/src/adapters/node-http/content-type/form-data/index.ts +0 -163
- package/src/adapters/node-http/content-type/form-data/memoryUploadHandler.ts +0 -56
- package/src/adapters/node-http/content-type/form-data/streamSlice.ts +0 -56
- package/src/adapters/node-http/content-type/form-data/uploadHandler.ts +0 -89
- package/src/adapters/node-http/content-type/json/getPostBody.ts +0 -58
- package/src/adapters/node-http/content-type/json/index.ts +0 -11
- package/src/adapters/node-http/internals/contentType.ts +0 -31
- package/src/unstable-core-do-not-import/http/index.ts +0 -29
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
export { getHTTPStatusCode, getHTTPStatusCodeFromError, } from '../../unstable-core-do-not-import';
|
|
2
|
-
export {
|
|
3
|
-
|
|
1
|
+
export { getHTTPStatusCode, getHTTPStatusCodeFromError, resolveResponse, } from '../../unstable-core-do-not-import';
|
|
2
|
+
export type { BaseHandlerOptions, HTTPBaseHandlerOptions, HTTPErrorHandler,
|
|
3
|
+
/**
|
|
4
|
+
* @deprecated Use `HTTPErrorHandler` instead
|
|
5
|
+
*/
|
|
6
|
+
HTTPErrorHandler as OnErrorFunction, ResolveHTTPRequestOptionsContextFn, ResponseMeta, ResponseMetaFn, TRPCRequestInfo, } from '../../unstable-core-do-not-import';
|
|
4
7
|
export { getBatchStreamFormatter } from '../../unstable-core-do-not-import';
|
|
5
|
-
export
|
|
6
|
-
export { getJsonContentTypeInputs } from '../../unstable-core-do-not-import';
|
|
7
|
-
export { toURL } from '../../unstable-core-do-not-import';
|
|
8
|
+
export { octetInputParser, toURL } from '../../unstable-core-do-not-import';
|
|
8
9
|
//# sourceMappingURL=http.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../../src/@trpc/server/http.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,0BAA0B,
|
|
1
|
+
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../../src/@trpc/server/http.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,0BAA0B,EAC1B,eAAe,GAChB,MAAM,mCAAmC,CAAC;AAC3C,YAAY,EACV,kBAAkB,EAClB,sBAAsB,EACtB,gBAAgB;AAChB;;GAEG;AACH,gBAAgB,IAAI,eAAe,EACnC,kCAAkC,EAClC,YAAY,EACZ,cAAc,EACd,eAAe,GAChB,MAAM,mCAAmC,CAAC;AAE3C,OAAO,EAAE,uBAAuB,EAAE,MAAM,mCAAmC,CAAC;AAC5E,OAAO,EAAE,gBAAgB,EAAE,KAAK,EAAE,MAAM,mCAAmC,CAAC"}
|
|
@@ -2,7 +2,7 @@ export { TRPCError,
|
|
|
2
2
|
/**
|
|
3
3
|
* @deprecated use `experimental_trpcMiddleware` instead
|
|
4
4
|
*/
|
|
5
|
-
experimental_standaloneMiddleware, experimental_standaloneMiddleware as experimental_trpcMiddleware, initTRPC, callProcedure as callTRPCProcedure, getTRPCErrorFromUnknown, transformTRPCResponse, createFlatProxy as createTRPCFlatProxy, type inferProcedureInput, type inferProcedureOutput, type inferProcedureBuilderResolverOptions, type inferRouterError, type inferRouterInputs, type inferRouterOutputs, type inferRouterContext, type inferClientTypes as inferTRPCClientTypes, type AnyClientTypes as AnyTRPCClientTypes, type inferTransformedProcedureOutput, type inferTransformedSubscriptionOutput, type AnyProcedure as AnyTRPCProcedure, type AnyRouter as AnyTRPCRouter, type AnyMiddlewareFunction as AnyTRPCMiddlewareFunction, type CombinedDataTransformer as TRPCCombinedDataTransformer, type ProcedureType as TRPCProcedureType, type AnyMutationProcedure as AnyTRPCMutationProcedure, type AnyQueryProcedure as AnyTRPCQueryProcedure, type RouterRecord as TRPCRouterRecord, type AnySubscriptionProcedure as AnyTRPCSubscriptionProcedure, type ProcedureOptions as TRPCProcedureOptions, type MutationProcedure as TRPCMutationProcedure, type QueryProcedure as TRPCQueryProcedure, type SubscriptionProcedure as TRPCSubscriptionProcedure, type TRPCBuilder, } from '../../unstable-core-do-not-import';
|
|
5
|
+
experimental_standaloneMiddleware, experimental_standaloneMiddleware as experimental_trpcMiddleware, initTRPC, callProcedure as callTRPCProcedure, getTRPCErrorFromUnknown, transformTRPCResponse, createFlatProxy as createTRPCFlatProxy, type inferProcedureInput, type inferProcedureOutput, type inferProcedureBuilderResolverOptions, type inferRouterError, type inferRouterInputs, type inferRouterOutputs, type inferRouterContext, type inferClientTypes as inferTRPCClientTypes, type AnyClientTypes as AnyTRPCClientTypes, type inferTransformedProcedureOutput, type inferTransformedSubscriptionOutput, type AnyProcedure as AnyTRPCProcedure, type AnyRouter as AnyTRPCRouter, type AnyMiddlewareFunction as AnyTRPCMiddlewareFunction, type CombinedDataTransformer as TRPCCombinedDataTransformer, type ProcedureType as TRPCProcedureType, type AnyMutationProcedure as AnyTRPCMutationProcedure, type AnyQueryProcedure as AnyTRPCQueryProcedure, type RouterRecord as TRPCRouterRecord, type AnySubscriptionProcedure as AnyTRPCSubscriptionProcedure, type ProcedureOptions as TRPCProcedureOptions, type CreateContextCallback, type MutationProcedure as TRPCMutationProcedure, type QueryProcedure as TRPCQueryProcedure, type SubscriptionProcedure as TRPCSubscriptionProcedure, type TRPCBuilder, } from '../../unstable-core-do-not-import';
|
|
6
6
|
export type {
|
|
7
7
|
/**
|
|
8
8
|
* @deprecated use `AnyTRPCProcedure` instead
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/@trpc/server/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS;AACT;;GAEG;AACH,iCAAiC,EACjC,iCAAiC,IAAI,2BAA2B,EAChE,QAAQ,EAER,aAAa,IAAI,iBAAiB,EAClC,uBAAuB,EACvB,qBAAqB,EACrB,eAAe,IAAI,mBAAmB,EACtC,KAAK,mBAAmB,EACxB,KAAK,oBAAoB,EACzB,KAAK,oCAAoC,EACzC,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACvB,KAAK,gBAAgB,IAAI,oBAAoB,EAC7C,KAAK,cAAc,IAA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mCAAmC,CAAC;AAE3C;;;GAGG;AACH,MAAM,MAAM,oBAAoB,CAAC,SAAS,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,IACxE,OAAO,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { APIGatewayProxyEvent, APIGatewayProxyEventV2, APIGatewayProxyResult, APIGatewayProxyStructuredResultV2 } from 'aws-lambda';
|
|
2
|
+
export type LambdaEvent = APIGatewayProxyEvent | APIGatewayProxyEventV2;
|
|
3
|
+
export type APIGatewayResult = APIGatewayProxyResult | APIGatewayProxyStructuredResultV2;
|
|
4
|
+
/** 1:1 mapping of v1 or v2 input events, deduces which is which.
|
|
5
|
+
* @internal
|
|
6
|
+
**/
|
|
7
|
+
export type inferAPIGWReturn<TEvent> = TEvent extends APIGatewayProxyEvent ? APIGatewayProxyResult : TEvent extends APIGatewayProxyEventV2 ? APIGatewayProxyStructuredResultV2 : never;
|
|
8
|
+
export declare function getPlanner<TEvent extends LambdaEvent>(event: TEvent): {
|
|
9
|
+
path: string;
|
|
10
|
+
request: Request;
|
|
11
|
+
toResult: (response: Response) => Promise<inferAPIGWReturn<TEvent>>;
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=getPlanner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getPlanner.d.ts","sourceRoot":"","sources":["../../../src/adapters/aws-lambda/getPlanner.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oBAAoB,EACpB,sBAAsB,EACtB,qBAAqB,EACrB,iCAAiC,EAClC,MAAM,YAAY,CAAC;AAEpB,MAAM,MAAM,WAAW,GAAG,oBAAoB,GAAG,sBAAsB,CAAC;AAExE,MAAM,MAAM,gBAAgB,GACxB,qBAAqB,GACrB,iCAAiC,CAAC;AActC;;IAEI;AACJ,MAAM,MAAM,gBAAgB,CAAC,MAAM,IAAI,MAAM,SAAS,oBAAoB,GACtE,qBAAqB,GACrB,MAAM,SAAS,sBAAsB,GACrC,iCAAiC,GACjC,KAAK,CAAC;AA0HV,wBAAgB,UAAU,CAAC,MAAM,SAAS,WAAW,EAAE,KAAK,EAAE,MAAM;;;;EAoCnE"}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
function determinePayloadFormat(event) {
|
|
4
|
+
// https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-develop-integrations-lambda.html
|
|
5
|
+
// According to AWS support, version is is extracted from the version property in the event.
|
|
6
|
+
// If there is no version property, then the version is implied as 1.0
|
|
7
|
+
const unknownEvent = event;
|
|
8
|
+
if (typeof unknownEvent.version === 'undefined') {
|
|
9
|
+
return '1.0';
|
|
10
|
+
} else {
|
|
11
|
+
return unknownEvent.version;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
const v1Processor = {
|
|
15
|
+
// same as getPath above
|
|
16
|
+
getTRPCPath: (event)=>{
|
|
17
|
+
if (!event.pathParameters) {
|
|
18
|
+
// Then this event was not triggered by a resource denoted with {proxy+}
|
|
19
|
+
return event.path.split('/').pop() ?? '';
|
|
20
|
+
}
|
|
21
|
+
const matches = event.resource.matchAll(/\{(.*?)\}/g);
|
|
22
|
+
for (const match of matches){
|
|
23
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
24
|
+
const group = match[1];
|
|
25
|
+
if (group.includes('+') && event.pathParameters) {
|
|
26
|
+
return event.pathParameters[group.replace('+', '')] ?? '';
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return event.path.slice(1);
|
|
30
|
+
},
|
|
31
|
+
url (event) {
|
|
32
|
+
const hostname = event.requestContext.domainName ?? event.headers['host'] ?? event.multiValueHeaders?.['host']?.[0] ?? 'localhost';
|
|
33
|
+
const searchParams = new URLSearchParams();
|
|
34
|
+
for (const [key, value] of Object.entries(event.queryStringParameters ?? {})){
|
|
35
|
+
if (value !== undefined) {
|
|
36
|
+
searchParams.append(key, value);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
const qs = searchParams.toString();
|
|
40
|
+
return {
|
|
41
|
+
hostname,
|
|
42
|
+
pathname: event.path,
|
|
43
|
+
search: qs && `?${qs}`
|
|
44
|
+
};
|
|
45
|
+
},
|
|
46
|
+
getHeaders: (event)=>{
|
|
47
|
+
const headers = new Headers();
|
|
48
|
+
for (const [key, value] of Object.entries(event.headers ?? {})){
|
|
49
|
+
if (value !== undefined) {
|
|
50
|
+
headers.append(key, value);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
for (const [k, values] of Object.entries(event.multiValueHeaders ?? {})){
|
|
54
|
+
if (values) {
|
|
55
|
+
values.forEach((v)=>headers.append(k, v));
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return headers;
|
|
59
|
+
},
|
|
60
|
+
getMethod: (event)=>event.httpMethod,
|
|
61
|
+
toResult: async (response)=>{
|
|
62
|
+
const result = {
|
|
63
|
+
statusCode: response.status,
|
|
64
|
+
body: await response.text(),
|
|
65
|
+
headers: Object.fromEntries(response.headers.entries())
|
|
66
|
+
};
|
|
67
|
+
return result;
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
const v2Processor = {
|
|
71
|
+
getTRPCPath: (event)=>{
|
|
72
|
+
const matches = event.routeKey.matchAll(/\{(.*?)\}/g);
|
|
73
|
+
for (const match of matches){
|
|
74
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
75
|
+
const group = match[1];
|
|
76
|
+
if (group.includes('+') && event.pathParameters) {
|
|
77
|
+
return event.pathParameters[group.replace('+', '')] ?? '';
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return event.rawPath.slice(1);
|
|
81
|
+
},
|
|
82
|
+
url (event) {
|
|
83
|
+
return {
|
|
84
|
+
hostname: event.requestContext.domainName,
|
|
85
|
+
pathname: event.rawPath,
|
|
86
|
+
search: event.rawQueryString && `?${event.rawQueryString}`
|
|
87
|
+
};
|
|
88
|
+
},
|
|
89
|
+
getHeaders: (event)=>{
|
|
90
|
+
const headers = new Headers();
|
|
91
|
+
for (const [key, value] of Object.entries(event.headers ?? {})){
|
|
92
|
+
if (value !== undefined) {
|
|
93
|
+
headers.append(key, value);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
if (event.cookies) {
|
|
97
|
+
headers.append('cookie', event.cookies.join('; '));
|
|
98
|
+
}
|
|
99
|
+
return headers;
|
|
100
|
+
},
|
|
101
|
+
getMethod: (event)=>event.requestContext.http.method,
|
|
102
|
+
toResult: async (response)=>{
|
|
103
|
+
const result = {
|
|
104
|
+
statusCode: response.status,
|
|
105
|
+
body: await response.text(),
|
|
106
|
+
headers: Object.fromEntries(response.headers.entries())
|
|
107
|
+
};
|
|
108
|
+
return result;
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
function getPlanner(event) {
|
|
112
|
+
const version = determinePayloadFormat(event);
|
|
113
|
+
let processor;
|
|
114
|
+
switch(version){
|
|
115
|
+
case '1.0':
|
|
116
|
+
processor = v1Processor;
|
|
117
|
+
break;
|
|
118
|
+
case '2.0':
|
|
119
|
+
processor = v2Processor;
|
|
120
|
+
break;
|
|
121
|
+
default:
|
|
122
|
+
throw new Error(`Unsupported version: ${version}`);
|
|
123
|
+
}
|
|
124
|
+
const urlParts = processor.url(event);
|
|
125
|
+
const url = `https://${urlParts.hostname}${urlParts.pathname}${urlParts.search}`;
|
|
126
|
+
const init = {
|
|
127
|
+
headers: processor.getHeaders(event),
|
|
128
|
+
method: processor.getMethod(event),
|
|
129
|
+
// @ts-expect-error this is fine
|
|
130
|
+
duplex: 'half'
|
|
131
|
+
};
|
|
132
|
+
if (event.body) {
|
|
133
|
+
init.body = event.isBase64Encoded ? Buffer.from(event.body, 'base64') : event.body;
|
|
134
|
+
}
|
|
135
|
+
const request = new Request(url, init);
|
|
136
|
+
return {
|
|
137
|
+
path: processor.getTRPCPath(event),
|
|
138
|
+
request,
|
|
139
|
+
toResult: processor.toResult
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
exports.getPlanner = getPlanner;
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
function determinePayloadFormat(event) {
|
|
2
|
+
// https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-develop-integrations-lambda.html
|
|
3
|
+
// According to AWS support, version is is extracted from the version property in the event.
|
|
4
|
+
// If there is no version property, then the version is implied as 1.0
|
|
5
|
+
const unknownEvent = event;
|
|
6
|
+
if (typeof unknownEvent.version === 'undefined') {
|
|
7
|
+
return '1.0';
|
|
8
|
+
} else {
|
|
9
|
+
return unknownEvent.version;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
const v1Processor = {
|
|
13
|
+
// same as getPath above
|
|
14
|
+
getTRPCPath: (event)=>{
|
|
15
|
+
if (!event.pathParameters) {
|
|
16
|
+
// Then this event was not triggered by a resource denoted with {proxy+}
|
|
17
|
+
return event.path.split('/').pop() ?? '';
|
|
18
|
+
}
|
|
19
|
+
const matches = event.resource.matchAll(/\{(.*?)\}/g);
|
|
20
|
+
for (const match of matches){
|
|
21
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
22
|
+
const group = match[1];
|
|
23
|
+
if (group.includes('+') && event.pathParameters) {
|
|
24
|
+
return event.pathParameters[group.replace('+', '')] ?? '';
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return event.path.slice(1);
|
|
28
|
+
},
|
|
29
|
+
url (event) {
|
|
30
|
+
const hostname = event.requestContext.domainName ?? event.headers['host'] ?? event.multiValueHeaders?.['host']?.[0] ?? 'localhost';
|
|
31
|
+
const searchParams = new URLSearchParams();
|
|
32
|
+
for (const [key, value] of Object.entries(event.queryStringParameters ?? {})){
|
|
33
|
+
if (value !== undefined) {
|
|
34
|
+
searchParams.append(key, value);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
const qs = searchParams.toString();
|
|
38
|
+
return {
|
|
39
|
+
hostname,
|
|
40
|
+
pathname: event.path,
|
|
41
|
+
search: qs && `?${qs}`
|
|
42
|
+
};
|
|
43
|
+
},
|
|
44
|
+
getHeaders: (event)=>{
|
|
45
|
+
const headers = new Headers();
|
|
46
|
+
for (const [key, value] of Object.entries(event.headers ?? {})){
|
|
47
|
+
if (value !== undefined) {
|
|
48
|
+
headers.append(key, value);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
for (const [k, values] of Object.entries(event.multiValueHeaders ?? {})){
|
|
52
|
+
if (values) {
|
|
53
|
+
values.forEach((v)=>headers.append(k, v));
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return headers;
|
|
57
|
+
},
|
|
58
|
+
getMethod: (event)=>event.httpMethod,
|
|
59
|
+
toResult: async (response)=>{
|
|
60
|
+
const result = {
|
|
61
|
+
statusCode: response.status,
|
|
62
|
+
body: await response.text(),
|
|
63
|
+
headers: Object.fromEntries(response.headers.entries())
|
|
64
|
+
};
|
|
65
|
+
return result;
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
const v2Processor = {
|
|
69
|
+
getTRPCPath: (event)=>{
|
|
70
|
+
const matches = event.routeKey.matchAll(/\{(.*?)\}/g);
|
|
71
|
+
for (const match of matches){
|
|
72
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
73
|
+
const group = match[1];
|
|
74
|
+
if (group.includes('+') && event.pathParameters) {
|
|
75
|
+
return event.pathParameters[group.replace('+', '')] ?? '';
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return event.rawPath.slice(1);
|
|
79
|
+
},
|
|
80
|
+
url (event) {
|
|
81
|
+
return {
|
|
82
|
+
hostname: event.requestContext.domainName,
|
|
83
|
+
pathname: event.rawPath,
|
|
84
|
+
search: event.rawQueryString && `?${event.rawQueryString}`
|
|
85
|
+
};
|
|
86
|
+
},
|
|
87
|
+
getHeaders: (event)=>{
|
|
88
|
+
const headers = new Headers();
|
|
89
|
+
for (const [key, value] of Object.entries(event.headers ?? {})){
|
|
90
|
+
if (value !== undefined) {
|
|
91
|
+
headers.append(key, value);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
if (event.cookies) {
|
|
95
|
+
headers.append('cookie', event.cookies.join('; '));
|
|
96
|
+
}
|
|
97
|
+
return headers;
|
|
98
|
+
},
|
|
99
|
+
getMethod: (event)=>event.requestContext.http.method,
|
|
100
|
+
toResult: async (response)=>{
|
|
101
|
+
const result = {
|
|
102
|
+
statusCode: response.status,
|
|
103
|
+
body: await response.text(),
|
|
104
|
+
headers: Object.fromEntries(response.headers.entries())
|
|
105
|
+
};
|
|
106
|
+
return result;
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
function getPlanner(event) {
|
|
110
|
+
const version = determinePayloadFormat(event);
|
|
111
|
+
let processor;
|
|
112
|
+
switch(version){
|
|
113
|
+
case '1.0':
|
|
114
|
+
processor = v1Processor;
|
|
115
|
+
break;
|
|
116
|
+
case '2.0':
|
|
117
|
+
processor = v2Processor;
|
|
118
|
+
break;
|
|
119
|
+
default:
|
|
120
|
+
throw new Error(`Unsupported version: ${version}`);
|
|
121
|
+
}
|
|
122
|
+
const urlParts = processor.url(event);
|
|
123
|
+
const url = `https://${urlParts.hostname}${urlParts.pathname}${urlParts.search}`;
|
|
124
|
+
const init = {
|
|
125
|
+
headers: processor.getHeaders(event),
|
|
126
|
+
method: processor.getMethod(event),
|
|
127
|
+
// @ts-expect-error this is fine
|
|
128
|
+
duplex: 'half'
|
|
129
|
+
};
|
|
130
|
+
if (event.body) {
|
|
131
|
+
init.body = event.isBase64Encoded ? Buffer.from(event.body, 'base64') : event.body;
|
|
132
|
+
}
|
|
133
|
+
const request = new Request(url, init);
|
|
134
|
+
return {
|
|
135
|
+
path: processor.getTRPCPath(event),
|
|
136
|
+
request,
|
|
137
|
+
toResult: processor.toResult
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
export { getPlanner };
|
|
@@ -7,13 +7,16 @@
|
|
|
7
7
|
* import type { HTTPBaseHandlerOptions } from '@trpc/server/http'
|
|
8
8
|
* ```
|
|
9
9
|
*/
|
|
10
|
-
import type {
|
|
11
|
-
import type { AnyRouter } from '../../@trpc/server';
|
|
12
|
-
import type {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
10
|
+
import type { Context as APIGWContext } from 'aws-lambda';
|
|
11
|
+
import type { AnyRouter, CreateContextCallback, inferRouterContext } from '../../@trpc/server';
|
|
12
|
+
import type { HTTPBaseHandlerOptions, TRPCRequestInfo } from '../../@trpc/server/http';
|
|
13
|
+
import type { inferAPIGWReturn, LambdaEvent } from './getPlanner';
|
|
14
|
+
export type CreateAWSLambdaContextOptions<TEvent extends LambdaEvent> = {
|
|
15
|
+
event: TEvent;
|
|
16
|
+
context: APIGWContext;
|
|
17
|
+
info: TRPCRequestInfo;
|
|
18
|
+
};
|
|
19
|
+
export type AWSLambdaOptions<TRouter extends AnyRouter, TEvent extends LambdaEvent> = HTTPBaseHandlerOptions<TRouter, TEvent> & CreateContextCallback<inferRouterContext<AnyRouter>, AWSLambdaCreateContextFn<TRouter, TEvent>>;
|
|
20
|
+
export type AWSLambdaCreateContextFn<TRouter extends AnyRouter, TEvent extends LambdaEvent> = ({ event, context, info, }: CreateAWSLambdaContextOptions<TEvent>) => inferRouterContext<TRouter> | Promise<inferRouterContext<TRouter>>;
|
|
21
|
+
export declare function awsLambdaRequestHandler<TRouter extends AnyRouter, TEvent extends LambdaEvent>(opts: AWSLambdaOptions<TRouter, TEvent>): (event: TEvent, context: APIGWContext) => Promise<inferAPIGWReturn<TEvent>>;
|
|
19
22
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/adapters/aws-lambda/index.ts"],"names":[],"mappings":"AAAA;;;;;;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E,YAAY,KAAK,OAAO,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC,CA0B7E"}
|
|
@@ -1,65 +1,12 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var TRPCError = require('../../unstable-core-do-not-import/error/TRPCError.js');
|
|
4
3
|
var resolveHTTPResponse = require('../../unstable-core-do-not-import/http/resolveHTTPResponse.js');
|
|
5
4
|
require('../../unstable-core-do-not-import/rootConfig.js');
|
|
6
|
-
var
|
|
5
|
+
var getPlanner = require('./getPlanner.js');
|
|
7
6
|
|
|
8
|
-
/**
|
|
9
|
-
* If you're making an adapter for tRPC and looking at this file for reference, you should import types and functions from `@trpc/server` and `@trpc/server/http`
|
|
10
|
-
*
|
|
11
|
-
* @example
|
|
12
|
-
* ```ts
|
|
13
|
-
* import type { AnyTRPCRouter } from '@trpc/server'
|
|
14
|
-
* import type { HTTPBaseHandlerOptions } from '@trpc/server/http'
|
|
15
|
-
* ```
|
|
16
|
-
*/ // @trpc/server
|
|
17
|
-
function lambdaEventToHTTPRequest(event) {
|
|
18
|
-
const query = new URLSearchParams();
|
|
19
|
-
for (const [key, value] of Object.entries(event.queryStringParameters ?? {})){
|
|
20
|
-
if (typeof value !== 'undefined') {
|
|
21
|
-
query.append(key, value);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
let body;
|
|
25
|
-
if (event.body && event.isBase64Encoded) {
|
|
26
|
-
body = Buffer.from(event.body, 'base64').toString('utf8');
|
|
27
|
-
} else {
|
|
28
|
-
body = event.body;
|
|
29
|
-
}
|
|
30
|
-
return {
|
|
31
|
-
method: utils.getHTTPMethod(event),
|
|
32
|
-
query: query,
|
|
33
|
-
headers: event.headers,
|
|
34
|
-
body: body
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
function tRPCOutputToAPIGatewayOutput(event, response) {
|
|
38
|
-
if (utils.isPayloadV1(event)) {
|
|
39
|
-
const resp = {
|
|
40
|
-
statusCode: response.status,
|
|
41
|
-
body: response.body ?? '',
|
|
42
|
-
headers: utils.transformHeaders(response.headers ?? {})
|
|
43
|
-
};
|
|
44
|
-
return resp;
|
|
45
|
-
} else if (utils.isPayloadV2(event)) {
|
|
46
|
-
const resp1 = {
|
|
47
|
-
statusCode: response.status,
|
|
48
|
-
body: response.body ?? undefined,
|
|
49
|
-
headers: utils.transformHeaders(response.headers ?? {})
|
|
50
|
-
};
|
|
51
|
-
return resp1;
|
|
52
|
-
} else {
|
|
53
|
-
throw new TRPCError.TRPCError({
|
|
54
|
-
code: 'INTERNAL_SERVER_ERROR',
|
|
55
|
-
message: utils.UNKNOWN_PAYLOAD_FORMAT_VERSION_ERROR_MESSAGE
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
7
|
function awsLambdaRequestHandler(opts) {
|
|
60
8
|
return async (event, context)=>{
|
|
61
|
-
const
|
|
62
|
-
const path = utils.getPath(event);
|
|
9
|
+
const planner = getPlanner.getPlanner(event);
|
|
63
10
|
const createContext = async (innerOpts)=>{
|
|
64
11
|
return await opts.createContext?.({
|
|
65
12
|
event,
|
|
@@ -67,11 +14,11 @@ function awsLambdaRequestHandler(opts) {
|
|
|
67
14
|
...innerOpts
|
|
68
15
|
});
|
|
69
16
|
};
|
|
70
|
-
const response = await resolveHTTPResponse.
|
|
17
|
+
const response = await resolveHTTPResponse.resolveResponse({
|
|
71
18
|
...opts,
|
|
72
19
|
createContext,
|
|
73
|
-
req,
|
|
74
|
-
path,
|
|
20
|
+
req: planner.request,
|
|
21
|
+
path: planner.path,
|
|
75
22
|
error: null,
|
|
76
23
|
onError (o) {
|
|
77
24
|
opts?.onError?.({
|
|
@@ -80,14 +27,8 @@ function awsLambdaRequestHandler(opts) {
|
|
|
80
27
|
});
|
|
81
28
|
}
|
|
82
29
|
});
|
|
83
|
-
return
|
|
30
|
+
return await planner.toResult(response);
|
|
84
31
|
};
|
|
85
32
|
}
|
|
86
33
|
|
|
87
|
-
exports.UNKNOWN_PAYLOAD_FORMAT_VERSION_ERROR_MESSAGE = utils.UNKNOWN_PAYLOAD_FORMAT_VERSION_ERROR_MESSAGE;
|
|
88
|
-
exports.getHTTPMethod = utils.getHTTPMethod;
|
|
89
|
-
exports.getPath = utils.getPath;
|
|
90
|
-
exports.isPayloadV1 = utils.isPayloadV1;
|
|
91
|
-
exports.isPayloadV2 = utils.isPayloadV2;
|
|
92
|
-
exports.transformHeaders = utils.transformHeaders;
|
|
93
34
|
exports.awsLambdaRequestHandler = awsLambdaRequestHandler;
|
|
@@ -1,63 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { resolveHTTPResponse } from '../../unstable-core-do-not-import/http/resolveHTTPResponse.mjs';
|
|
1
|
+
import { resolveResponse } from '../../unstable-core-do-not-import/http/resolveHTTPResponse.mjs';
|
|
3
2
|
import '../../unstable-core-do-not-import/rootConfig.mjs';
|
|
4
|
-
import {
|
|
3
|
+
import { getPlanner } from './getPlanner.mjs';
|
|
5
4
|
|
|
6
|
-
/**
|
|
7
|
-
* If you're making an adapter for tRPC and looking at this file for reference, you should import types and functions from `@trpc/server` and `@trpc/server/http`
|
|
8
|
-
*
|
|
9
|
-
* @example
|
|
10
|
-
* ```ts
|
|
11
|
-
* import type { AnyTRPCRouter } from '@trpc/server'
|
|
12
|
-
* import type { HTTPBaseHandlerOptions } from '@trpc/server/http'
|
|
13
|
-
* ```
|
|
14
|
-
*/ // @trpc/server
|
|
15
|
-
function lambdaEventToHTTPRequest(event) {
|
|
16
|
-
const query = new URLSearchParams();
|
|
17
|
-
for (const [key, value] of Object.entries(event.queryStringParameters ?? {})){
|
|
18
|
-
if (typeof value !== 'undefined') {
|
|
19
|
-
query.append(key, value);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
let body;
|
|
23
|
-
if (event.body && event.isBase64Encoded) {
|
|
24
|
-
body = Buffer.from(event.body, 'base64').toString('utf8');
|
|
25
|
-
} else {
|
|
26
|
-
body = event.body;
|
|
27
|
-
}
|
|
28
|
-
return {
|
|
29
|
-
method: getHTTPMethod(event),
|
|
30
|
-
query: query,
|
|
31
|
-
headers: event.headers,
|
|
32
|
-
body: body
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
function tRPCOutputToAPIGatewayOutput(event, response) {
|
|
36
|
-
if (isPayloadV1(event)) {
|
|
37
|
-
const resp = {
|
|
38
|
-
statusCode: response.status,
|
|
39
|
-
body: response.body ?? '',
|
|
40
|
-
headers: transformHeaders(response.headers ?? {})
|
|
41
|
-
};
|
|
42
|
-
return resp;
|
|
43
|
-
} else if (isPayloadV2(event)) {
|
|
44
|
-
const resp1 = {
|
|
45
|
-
statusCode: response.status,
|
|
46
|
-
body: response.body ?? undefined,
|
|
47
|
-
headers: transformHeaders(response.headers ?? {})
|
|
48
|
-
};
|
|
49
|
-
return resp1;
|
|
50
|
-
} else {
|
|
51
|
-
throw new TRPCError({
|
|
52
|
-
code: 'INTERNAL_SERVER_ERROR',
|
|
53
|
-
message: UNKNOWN_PAYLOAD_FORMAT_VERSION_ERROR_MESSAGE
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
5
|
function awsLambdaRequestHandler(opts) {
|
|
58
6
|
return async (event, context)=>{
|
|
59
|
-
const
|
|
60
|
-
const path = getPath(event);
|
|
7
|
+
const planner = getPlanner(event);
|
|
61
8
|
const createContext = async (innerOpts)=>{
|
|
62
9
|
return await opts.createContext?.({
|
|
63
10
|
event,
|
|
@@ -65,11 +12,11 @@ function awsLambdaRequestHandler(opts) {
|
|
|
65
12
|
...innerOpts
|
|
66
13
|
});
|
|
67
14
|
};
|
|
68
|
-
const response = await
|
|
15
|
+
const response = await resolveResponse({
|
|
69
16
|
...opts,
|
|
70
17
|
createContext,
|
|
71
|
-
req,
|
|
72
|
-
path,
|
|
18
|
+
req: planner.request,
|
|
19
|
+
path: planner.path,
|
|
73
20
|
error: null,
|
|
74
21
|
onError (o) {
|
|
75
22
|
opts?.onError?.({
|
|
@@ -78,8 +25,8 @@ function awsLambdaRequestHandler(opts) {
|
|
|
78
25
|
});
|
|
79
26
|
}
|
|
80
27
|
});
|
|
81
|
-
return
|
|
28
|
+
return await planner.toResult(response);
|
|
82
29
|
};
|
|
83
30
|
}
|
|
84
31
|
|
|
85
|
-
export {
|
|
32
|
+
export { awsLambdaRequestHandler };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"express.d.ts","sourceRoot":"","sources":["../../src/adapters/express.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,KAAK,OAAO,MAAM,SAAS,CAAC;AACxC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,KAAK,EACV,8BAA8B,EAC9B,sBAAsB,EACvB,MAAM,aAAa,CAAC;AAGrB,MAAM,MAAM,2BAA2B,GAAG,8BAA8B,CACtE,OAAO,CAAC,OAAO,EACf,OAAO,CAAC,QAAQ,CACjB,CAAC;AAEF,wBAAgB,uBAAuB,CAAC,OAAO,SAAS,SAAS,EAC/D,IAAI,EAAE,sBAAsB,CAAC,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,QAAQ,CAAC,GACvE,OAAO,CAAC,OAAO,
|
|
1
|
+
{"version":3,"file":"express.d.ts","sourceRoot":"","sources":["../../src/adapters/express.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,KAAK,OAAO,MAAM,SAAS,CAAC;AACxC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,KAAK,EACV,8BAA8B,EAC9B,sBAAsB,EACvB,MAAM,aAAa,CAAC;AAGrB,MAAM,MAAM,2BAA2B,GAAG,8BAA8B,CACtE,OAAO,CAAC,OAAO,EACf,OAAO,CAAC,QAAQ,CACjB,CAAC;AAEF,wBAAgB,uBAAuB,CAAC,OAAO,SAAS,SAAS,EAC/D,IAAI,EAAE,sBAAsB,CAAC,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,QAAQ,CAAC,GACvE,OAAO,CAAC,OAAO,CAWjB"}
|
package/dist/adapters/express.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var nodeHTTPRequestHandler = require('./node-http/nodeHTTPRequestHandler.js');
|
|
4
|
+
require('../unstable-core-do-not-import/rootConfig.js');
|
|
4
5
|
|
|
5
6
|
function createExpressMiddleware(opts) {
|
|
6
7
|
return async (req, res)=>{
|
|
7
8
|
const endpoint = req.path.slice(1);
|
|
8
9
|
await nodeHTTPRequestHandler.nodeHTTPRequestHandler({
|
|
9
|
-
// FIXME: no typecasting should be needed here
|
|
10
10
|
...opts,
|
|
11
11
|
req,
|
|
12
12
|
res,
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { nodeHTTPRequestHandler } from './node-http/nodeHTTPRequestHandler.mjs';
|
|
2
|
+
import '../unstable-core-do-not-import/rootConfig.mjs';
|
|
2
3
|
|
|
3
4
|
function createExpressMiddleware(opts) {
|
|
4
5
|
return async (req, res)=>{
|
|
5
6
|
const endpoint = req.path.slice(1);
|
|
6
7
|
await nodeHTTPRequestHandler({
|
|
7
|
-
// FIXME: no typecasting should be needed here
|
|
8
8
|
...opts,
|
|
9
9
|
req,
|
|
10
10
|
res,
|
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* If you're making an adapter for tRPC and looking at this file for reference, you should import types and functions from `@trpc/server` and `@trpc/server/http`
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* ```ts
|
|
6
|
+
* import type { AnyTRPCRouter } from '@trpc/server'
|
|
7
|
+
* import type { HTTPBaseHandlerOptions } from '@trpc/server/http'
|
|
8
|
+
* ```
|
|
9
|
+
*/
|
|
1
10
|
import type { FastifyReply, FastifyRequest } from 'fastify';
|
|
2
11
|
import type { AnyRouter } from '../../@trpc/server';
|
|
3
12
|
import type { HTTPBaseHandlerOptions } from '../../@trpc/server/http';
|
|
@@ -8,6 +17,6 @@ type FastifyRequestHandlerOptions<TRouter extends AnyRouter, TRequest extends Fa
|
|
|
8
17
|
res: TResponse;
|
|
9
18
|
path: string;
|
|
10
19
|
};
|
|
11
|
-
export declare function fastifyRequestHandler<TRouter extends AnyRouter, TRequest extends FastifyRequest, TResponse extends FastifyReply>(opts: FastifyRequestHandlerOptions<TRouter, TRequest, TResponse>): Promise<
|
|
20
|
+
export declare function fastifyRequestHandler<TRouter extends AnyRouter, TRequest extends FastifyRequest, TResponse extends FastifyReply>(opts: FastifyRequestHandlerOptions<TRouter, TRequest, TResponse>): Promise<void>;
|
|
12
21
|
export {};
|
|
13
22
|
//# sourceMappingURL=fastifyRequestHandler.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fastifyRequestHandler.d.ts","sourceRoot":"","sources":["../../../src/adapters/fastify/fastifyRequestHandler.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"fastifyRequestHandler.d.ts","sourceRoot":"","sources":["../../../src/adapters/fastify/fastifyRequestHandler.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAE5D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,KAAK,EACV,sBAAsB,EAEvB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,KAAK,EAEV,2BAA2B,EAC5B,MAAM,cAAc,CAAC;AAGtB,MAAM,MAAM,qBAAqB,CAC/B,OAAO,SAAS,SAAS,EACzB,QAAQ,SAAS,cAAc,EAC/B,SAAS,SAAS,YAAY,IAC5B,sBAAsB,CAAC,OAAO,EAAE,QAAQ,CAAC,GAC3C,2BAA2B,CAAC,OAAO,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC;AAE5D,KAAK,4BAA4B,CAC/B,OAAO,SAAS,SAAS,EACzB,QAAQ,SAAS,cAAc,EAC/B,SAAS,SAAS,YAAY,IAC5B,qBAAqB,CAAC,OAAO,EAAE,QAAQ,EAAE,SAAS,CAAC,GAAG;IACxD,GAAG,EAAE,QAAQ,CAAC;IACd,GAAG,EAAE,SAAS,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,wBAAsB,qBAAqB,CACzC,OAAO,SAAS,SAAS,EACzB,QAAQ,SAAS,cAAc,EAC/B,SAAS,SAAS,YAAY,EAC9B,IAAI,EAAE,4BAA4B,CAAC,OAAO,EAAE,QAAQ,EAAE,SAAS,CAAC,iBAkCjE"}
|