@trpc/server 11.3.1 → 11.3.2-canary.2
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/adapters/aws-lambda/package.json +1 -0
- package/adapters/express/package.json +1 -0
- package/adapters/fastify/package.json +1 -0
- package/adapters/fetch/package.json +1 -0
- package/adapters/next/package.json +1 -0
- package/adapters/next-app-dir/package.json +1 -0
- package/adapters/node-http/package.json +1 -0
- package/adapters/standalone/package.json +1 -0
- package/adapters/ws/package.json +1 -0
- package/dist/adapters/aws-lambda/index.cjs +255 -0
- package/dist/adapters/aws-lambda/index.d.cts +31 -0
- package/dist/adapters/aws-lambda/index.d.cts.map +1 -0
- package/dist/adapters/aws-lambda/index.d.mts +31 -0
- package/dist/adapters/aws-lambda/index.d.mts.map +1 -0
- package/dist/adapters/aws-lambda/index.mjs +248 -57
- package/dist/adapters/aws-lambda/index.mjs.map +1 -0
- package/dist/adapters/express.cjs +34 -0
- package/dist/adapters/express.d.cts +15 -0
- package/dist/adapters/express.d.cts.map +1 -0
- package/dist/adapters/express.d.mts +15 -0
- package/dist/adapters/express.d.mts.map +1 -0
- package/dist/adapters/express.mjs +30 -32
- package/dist/adapters/express.mjs.map +1 -0
- package/dist/adapters/fastify/index.cjs +75 -0
- package/dist/adapters/fastify/index.d.cts +29 -0
- package/dist/adapters/fastify/index.d.cts.map +1 -0
- package/dist/adapters/fastify/index.d.mts +29 -0
- package/dist/adapters/fastify/index.d.mts.map +1 -0
- package/dist/adapters/fastify/index.mjs +75 -2
- package/dist/adapters/fastify/index.mjs.map +1 -0
- package/dist/adapters/fetch/index.cjs +58 -0
- package/dist/adapters/fetch/index.d.cts +30 -0
- package/dist/adapters/fetch/index.d.cts.map +1 -0
- package/dist/adapters/fetch/index.d.mts +30 -0
- package/dist/adapters/fetch/index.d.mts.map +1 -0
- package/dist/adapters/fetch/index.mjs +59 -1
- package/dist/adapters/fetch/index.mjs.map +1 -0
- package/dist/adapters/next-app-dir.cjs +3050 -0
- package/dist/adapters/next-app-dir.d.cts +58 -0
- package/dist/adapters/next-app-dir.d.cts.map +1 -0
- package/dist/adapters/next-app-dir.d.mts +58 -0
- package/dist/adapters/next-app-dir.d.mts.map +1 -0
- package/dist/adapters/next-app-dir.mjs +3048 -4
- package/dist/adapters/next-app-dir.mjs.map +1 -0
- package/dist/adapters/next.cjs +41 -0
- package/dist/adapters/next.d.cts +19 -0
- package/dist/adapters/next.d.cts.map +1 -0
- package/dist/adapters/next.d.mts +19 -0
- package/dist/adapters/next.d.mts.map +1 -0
- package/dist/adapters/next.mjs +37 -44
- package/dist/adapters/next.mjs.map +1 -0
- package/dist/adapters/node-http/index.cjs +15 -0
- package/dist/adapters/node-http/index.d.cts +5 -0
- package/dist/adapters/node-http/index.d.mts +5 -0
- package/dist/adapters/node-http/index.mjs +12 -2
- package/dist/adapters/standalone.cjs +52 -0
- package/dist/adapters/standalone.d.cts +33 -0
- package/dist/adapters/standalone.d.cts.map +1 -0
- package/dist/adapters/standalone.d.mts +33 -0
- package/dist/adapters/standalone.d.mts.map +1 -0
- package/dist/adapters/standalone.mjs +40 -34
- package/dist/adapters/standalone.mjs.map +1 -0
- package/dist/adapters/ws.cjs +17 -0
- package/dist/adapters/ws.d.cts +61 -0
- package/dist/adapters/ws.d.cts.map +1 -0
- package/dist/adapters/ws.d.mts +61 -0
- package/dist/adapters/ws.d.mts.map +1 -0
- package/dist/adapters/ws.mjs +14 -539
- package/dist/contentTypeParsers-SN4WL9ze.mjs +13 -0
- package/dist/contentTypeParsers-SN4WL9ze.mjs.map +1 -0
- package/dist/contentTypeParsers-iAFF_pJG.cjs +18 -0
- package/dist/getErrorShape-CsikfkAc.cjs +201 -0
- package/dist/getErrorShape-DyYil4aT.mjs +149 -0
- package/dist/getErrorShape-DyYil4aT.mjs.map +1 -0
- package/dist/http-CWyjOa1l.mjs +0 -0
- package/dist/http-DXy3XyhL.cjs +0 -0
- package/dist/http.cjs +14 -0
- package/dist/http.d.cts +3 -0
- package/dist/http.d.mts +3 -0
- package/dist/http.mjs +9 -8
- package/dist/index.cjs +22 -0
- package/dist/index.d-BiUz7kM_.d.cts +65 -0
- package/dist/index.d-BiUz7kM_.d.cts.map +1 -0
- package/dist/index.d-ChWYhXbd.d.cts +99 -0
- package/dist/index.d-ChWYhXbd.d.cts.map +1 -0
- package/dist/index.d-CvZXeEyR.d.cts +11 -0
- package/dist/index.d-CvZXeEyR.d.cts.map +1 -0
- package/dist/index.d-D4qZxQJh.d.mts +65 -0
- package/dist/index.d-D4qZxQJh.d.mts.map +1 -0
- package/dist/index.d-Ocy_AnXj.d.mts +99 -0
- package/dist/index.d-Ocy_AnXj.d.mts.map +1 -0
- package/dist/index.d-vq_QHko2.d.mts +11 -0
- package/dist/index.d-vq_QHko2.d.mts.map +1 -0
- package/dist/index.d.cts +4 -0
- package/dist/index.d.mts +4 -0
- package/dist/index.mjs +6 -13
- package/dist/initTRPC-COaJMShh.mjs +339 -0
- package/dist/initTRPC-COaJMShh.mjs.map +1 -0
- package/dist/initTRPC-DjEpHmY2.cjs +397 -0
- package/dist/node-http-BPR68yI4.cjs +243 -0
- package/dist/node-http-BUQnHuGI.mjs +221 -0
- package/dist/node-http-BUQnHuGI.mjs.map +1 -0
- package/dist/observable/index.cjs +13 -0
- package/dist/observable/index.d.cts +2 -0
- package/dist/observable/index.d.mts +2 -0
- package/dist/observable/index.mjs +4 -3
- package/dist/observable-B1orLHHI.mjs +155 -0
- package/dist/observable-B1orLHHI.mjs.map +1 -0
- package/dist/observable-BwdrSFZU.cjs +178 -0
- package/dist/observable-C6qq2Ydk.cjs +180 -0
- package/dist/observable-CFXA_tyK.mjs +146 -0
- package/dist/observable-CFXA_tyK.mjs.map +1 -0
- package/dist/parseTRPCMessage-ByQWigsq.cjs +73 -0
- package/dist/parseTRPCMessage-CNyYMSRB.mjs +63 -0
- package/dist/parseTRPCMessage-CNyYMSRB.mjs.map +1 -0
- package/dist/resolveResponse-B2CuaT_1.cjs +2042 -0
- package/dist/resolveResponse-DPbYgJDD.mjs +1912 -0
- package/dist/resolveResponse-DPbYgJDD.mjs.map +1 -0
- package/dist/rpc.cjs +6 -0
- package/dist/rpc.d.cts +3 -0
- package/dist/rpc.d.mts +3 -0
- package/dist/rpc.mjs +4 -5
- package/dist/shared.cjs +5 -0
- package/dist/shared.d.cts +4 -0
- package/dist/shared.d.mts +4 -0
- package/dist/shared.mjs +4 -6
- package/dist/tracked-Dl9sBZxY.cjs +483 -0
- package/dist/tracked-GEWPoL0C.mjs +383 -0
- package/dist/tracked-GEWPoL0C.mjs.map +1 -0
- package/dist/unstable-core-do-not-import-D89CaGtL.mjs +29 -0
- package/dist/unstable-core-do-not-import-D89CaGtL.mjs.map +1 -0
- package/dist/unstable-core-do-not-import-DFQys1IC.cjs +34 -0
- package/dist/unstable-core-do-not-import.cjs +83 -0
- package/dist/unstable-core-do-not-import.d-CSxj_rbP.d.cts +1974 -0
- package/dist/unstable-core-do-not-import.d-CSxj_rbP.d.cts.map +1 -0
- package/dist/unstable-core-do-not-import.d-ptrxwuSa.d.mts +1974 -0
- package/dist/unstable-core-do-not-import.d-ptrxwuSa.d.mts.map +1 -0
- package/dist/unstable-core-do-not-import.d.cts +3 -0
- package/dist/unstable-core-do-not-import.d.mts +3 -0
- package/dist/unstable-core-do-not-import.mjs +11 -30
- package/dist/utils-BHZJcBRv.mjs +137 -0
- package/dist/utils-BHZJcBRv.mjs.map +1 -0
- package/dist/utils-DVO6HZiR.cjs +220 -0
- package/dist/ws-C2nEUNk_.cjs +425 -0
- package/dist/ws-eIVIMTrw.mjs +409 -0
- package/dist/ws-eIVIMTrw.mjs.map +1 -0
- package/http/package.json +1 -0
- package/observable/package.json +1 -0
- package/package.json +131 -55
- package/rpc/package.json +1 -0
- package/shared/package.json +1 -0
- package/src/@trpc/server/index.ts +24 -0
- package/src/unstable-core-do-not-import/http/contentType.ts +5 -4
- package/src/unstable-core-do-not-import/initTRPC.ts +79 -4
- package/src/unstable-core-do-not-import/router.ts +36 -12
- package/src/unstable-core-do-not-import/utils.ts +3 -2
- package/unstable-core-do-not-import/package.json +1 -0
- package/adapters/aws-lambda/index.d.ts +0 -1
- package/adapters/aws-lambda/index.js +0 -1
- package/adapters/express/index.d.ts +0 -1
- package/adapters/express/index.js +0 -1
- package/adapters/fastify/index.d.ts +0 -1
- package/adapters/fastify/index.js +0 -1
- package/adapters/fetch/index.d.ts +0 -1
- package/adapters/fetch/index.js +0 -1
- package/adapters/next/index.d.ts +0 -1
- package/adapters/next/index.js +0 -1
- package/adapters/next-app-dir/index.d.ts +0 -1
- package/adapters/next-app-dir/index.js +0 -1
- 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/adapters/node-http/index.d.ts +0 -1
- package/adapters/node-http/index.js +0 -1
- package/adapters/standalone/index.d.ts +0 -1
- package/adapters/standalone/index.js +0 -1
- package/adapters/ws/index.d.ts +0 -1
- package/adapters/ws/index.js +0 -1
- package/dist/@trpc/server/http.d.ts +0 -8
- package/dist/@trpc/server/http.d.ts.map +0 -1
- package/dist/@trpc/server/index.d.ts +0 -65
- package/dist/@trpc/server/index.d.ts.map +0 -1
- package/dist/@trpc/server/rpc.d.ts +0 -3
- package/dist/@trpc/server/rpc.d.ts.map +0 -1
- package/dist/adapters/aws-lambda/getPlanner.d.ts +0 -15
- package/dist/adapters/aws-lambda/getPlanner.d.ts.map +0 -1
- package/dist/adapters/aws-lambda/getPlanner.js +0 -179
- package/dist/adapters/aws-lambda/getPlanner.mjs +0 -177
- package/dist/adapters/aws-lambda/index.d.ts +0 -23
- package/dist/adapters/aws-lambda/index.d.ts.map +0 -1
- package/dist/adapters/aws-lambda/index.js +0 -67
- package/dist/adapters/express.d.ts +0 -15
- package/dist/adapters/express.d.ts.map +0 -1
- package/dist/adapters/express.js +0 -39
- package/dist/adapters/fastify/fastifyRequestHandler.d.ts +0 -22
- package/dist/adapters/fastify/fastifyRequestHandler.d.ts.map +0 -1
- package/dist/adapters/fastify/fastifyRequestHandler.js +0 -49
- package/dist/adapters/fastify/fastifyRequestHandler.mjs +0 -47
- package/dist/adapters/fastify/fastifyTRPCPlugin.d.ts +0 -21
- package/dist/adapters/fastify/fastifyTRPCPlugin.d.ts.map +0 -1
- package/dist/adapters/fastify/fastifyTRPCPlugin.js +0 -56
- package/dist/adapters/fastify/fastifyTRPCPlugin.mjs +0 -54
- package/dist/adapters/fastify/index.d.ts +0 -3
- package/dist/adapters/fastify/index.d.ts.map +0 -1
- package/dist/adapters/fastify/index.js +0 -9
- package/dist/adapters/fetch/fetchRequestHandler.d.ts +0 -13
- package/dist/adapters/fetch/fetchRequestHandler.d.ts.map +0 -1
- package/dist/adapters/fetch/fetchRequestHandler.js +0 -77
- package/dist/adapters/fetch/fetchRequestHandler.mjs +0 -75
- package/dist/adapters/fetch/index.d.ts +0 -3
- package/dist/adapters/fetch/index.d.ts.map +0 -1
- package/dist/adapters/fetch/index.js +0 -7
- package/dist/adapters/fetch/types.d.ts +0 -27
- package/dist/adapters/fetch/types.d.ts.map +0 -1
- package/dist/adapters/next-app-dir/nextAppDirCaller.d.ts +0 -25
- package/dist/adapters/next-app-dir/nextAppDirCaller.d.ts.map +0 -1
- package/dist/adapters/next-app-dir/nextAppDirCaller.js +0 -94
- package/dist/adapters/next-app-dir/nextAppDirCaller.mjs +0 -92
- package/dist/adapters/next-app-dir/notFound.d.ts +0 -7
- package/dist/adapters/next-app-dir/notFound.d.ts.map +0 -1
- package/dist/adapters/next-app-dir/notFound.js +0 -18
- package/dist/adapters/next-app-dir/notFound.mjs +0 -16
- package/dist/adapters/next-app-dir/redirect.d.ts +0 -18
- package/dist/adapters/next-app-dir/redirect.d.ts.map +0 -1
- package/dist/adapters/next-app-dir/redirect.js +0 -49
- package/dist/adapters/next-app-dir/redirect.mjs +0 -46
- package/dist/adapters/next-app-dir/rethrowNextErrors.d.ts +0 -6
- package/dist/adapters/next-app-dir/rethrowNextErrors.d.ts.map +0 -1
- package/dist/adapters/next-app-dir/rethrowNextErrors.js +0 -70
- package/dist/adapters/next-app-dir/rethrowNextErrors.mjs +0 -49
- package/dist/adapters/next-app-dir.d.ts +0 -7
- package/dist/adapters/next-app-dir.d.ts.map +0 -1
- package/dist/adapters/next-app-dir.js +0 -13
- package/dist/adapters/next.d.ts +0 -19
- package/dist/adapters/next.d.ts.map +0 -1
- package/dist/adapters/next.js +0 -51
- package/dist/adapters/node-http/incomingMessageToRequest.d.ts +0 -12
- package/dist/adapters/node-http/incomingMessageToRequest.d.ts.map +0 -1
- package/dist/adapters/node-http/incomingMessageToRequest.js +0 -123
- package/dist/adapters/node-http/incomingMessageToRequest.mjs +0 -120
- package/dist/adapters/node-http/index.d.ts +0 -4
- package/dist/adapters/node-http/index.d.ts.map +0 -1
- package/dist/adapters/node-http/index.js +0 -11
- package/dist/adapters/node-http/nodeHTTPRequestHandler.d.ts +0 -20
- package/dist/adapters/node-http/nodeHTTPRequestHandler.d.ts.map +0 -1
- package/dist/adapters/node-http/nodeHTTPRequestHandler.js +0 -96
- package/dist/adapters/node-http/nodeHTTPRequestHandler.mjs +0 -93
- package/dist/adapters/node-http/types.d.ts +0 -81
- package/dist/adapters/node-http/types.d.ts.map +0 -1
- package/dist/adapters/node-http/writeResponse.d.ts +0 -18
- package/dist/adapters/node-http/writeResponse.d.ts.map +0 -1
- package/dist/adapters/node-http/writeResponse.js +0 -83
- package/dist/adapters/node-http/writeResponse.mjs +0 -80
- package/dist/adapters/standalone.d.ts +0 -36
- package/dist/adapters/standalone.d.ts.map +0 -1
- package/dist/adapters/standalone.js +0 -49
- package/dist/adapters/ws.d.ts +0 -54
- package/dist/adapters/ws.d.ts.map +0 -1
- package/dist/adapters/ws.js +0 -544
- package/dist/http.d.ts +0 -2
- package/dist/http.d.ts.map +0 -1
- package/dist/http.js +0 -19
- package/dist/index.d.ts +0 -2
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -35
- package/dist/node_modules/.pnpm/@rollup_plugin-typescript@12.1.2_rollup@4.34.8_tslib@2.8.1_typescript@5.8.2/node_modules/tslib/tslib.es6.js +0 -73
- package/dist/observable/behaviorSubject.d.ts +0 -15
- package/dist/observable/behaviorSubject.d.ts.map +0 -1
- package/dist/observable/behaviorSubject.js +0 -40
- package/dist/observable/behaviorSubject.mjs +0 -38
- package/dist/observable/index.d.ts +0 -5
- package/dist/observable/index.d.ts.map +0 -1
- package/dist/observable/index.js +0 -18
- package/dist/observable/observable.d.ts +0 -12
- package/dist/observable/observable.d.ts.map +0 -1
- package/dist/observable/observable.js +0 -180
- package/dist/observable/observable.mjs +0 -175
- package/dist/observable/operators.d.ts +0 -10
- package/dist/observable/operators.d.ts.map +0 -1
- package/dist/observable/operators.js +0 -134
- package/dist/observable/operators.mjs +0 -128
- package/dist/observable/types.d.ts +0 -26
- package/dist/observable/types.d.ts.map +0 -1
- package/dist/rpc.d.ts +0 -2
- package/dist/rpc.d.ts.map +0 -1
- package/dist/rpc.js +0 -13
- package/dist/shared.d.ts +0 -26
- package/dist/shared.d.ts.map +0 -1
- package/dist/shared.js +0 -13
- package/dist/unstable-core-do-not-import/clientish/inference.d.ts +0 -17
- package/dist/unstable-core-do-not-import/clientish/inference.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/clientish/inferrable.d.ts +0 -36
- package/dist/unstable-core-do-not-import/clientish/inferrable.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/clientish/serialize.d.ts +0 -69
- package/dist/unstable-core-do-not-import/clientish/serialize.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/createProxy.d.ts +0 -19
- package/dist/unstable-core-do-not-import/createProxy.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/createProxy.js +0 -76
- package/dist/unstable-core-do-not-import/createProxy.mjs +0 -73
- package/dist/unstable-core-do-not-import/error/TRPCError.d.ts +0 -13
- package/dist/unstable-core-do-not-import/error/TRPCError.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/error/TRPCError.js +0 -76
- package/dist/unstable-core-do-not-import/error/TRPCError.mjs +0 -72
- package/dist/unstable-core-do-not-import/error/formatter.d.ts +0 -38
- package/dist/unstable-core-do-not-import/error/formatter.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/error/formatter.js +0 -7
- package/dist/unstable-core-do-not-import/error/formatter.mjs +0 -5
- package/dist/unstable-core-do-not-import/error/getErrorShape.d.ts +0 -15
- package/dist/unstable-core-do-not-import/error/getErrorShape.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/error/getErrorShape.js +0 -31
- package/dist/unstable-core-do-not-import/error/getErrorShape.mjs +0 -29
- package/dist/unstable-core-do-not-import/http/abortError.d.ts +0 -5
- package/dist/unstable-core-do-not-import/http/abortError.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/http/abortError.js +0 -13
- package/dist/unstable-core-do-not-import/http/abortError.mjs +0 -10
- package/dist/unstable-core-do-not-import/http/contentType.d.ts +0 -13
- package/dist/unstable-core-do-not-import/http/contentType.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/http/contentType.js +0 -229
- package/dist/unstable-core-do-not-import/http/contentType.mjs +0 -227
- package/dist/unstable-core-do-not-import/http/contentTypeParsers.d.ts +0 -14
- package/dist/unstable-core-do-not-import/http/contentTypeParsers.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/http/contentTypeParsers.js +0 -14
- package/dist/unstable-core-do-not-import/http/contentTypeParsers.mjs +0 -12
- package/dist/unstable-core-do-not-import/http/formDataToObject.d.ts +0 -2
- package/dist/unstable-core-do-not-import/http/formDataToObject.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/http/formDataToObject.js +0 -40
- package/dist/unstable-core-do-not-import/http/formDataToObject.mjs +0 -38
- package/dist/unstable-core-do-not-import/http/getHTTPStatusCode.d.ts +0 -10
- package/dist/unstable-core-do-not-import/http/getHTTPStatusCode.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/http/getHTTPStatusCode.js +0 -85
- package/dist/unstable-core-do-not-import/http/getHTTPStatusCode.mjs +0 -78
- package/dist/unstable-core-do-not-import/http/parseConnectionParams.d.ts +0 -4
- package/dist/unstable-core-do-not-import/http/parseConnectionParams.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/http/parseConnectionParams.js +0 -42
- package/dist/unstable-core-do-not-import/http/parseConnectionParams.mjs +0 -39
- package/dist/unstable-core-do-not-import/http/resolveResponse.d.ts +0 -15
- package/dist/unstable-core-do-not-import/http/resolveResponse.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/http/resolveResponse.js +0 -572
- package/dist/unstable-core-do-not-import/http/resolveResponse.mjs +0 -570
- package/dist/unstable-core-do-not-import/http/types.d.ts +0 -138
- package/dist/unstable-core-do-not-import/http/types.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/initTRPC.d.ts +0 -94
- package/dist/unstable-core-do-not-import/initTRPC.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/initTRPC.js +0 -82
- package/dist/unstable-core-do-not-import/initTRPC.mjs +0 -80
- package/dist/unstable-core-do-not-import/middleware.d.ts +0 -107
- package/dist/unstable-core-do-not-import/middleware.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/middleware.js +0 -96
- package/dist/unstable-core-do-not-import/middleware.mjs +0 -90
- package/dist/unstable-core-do-not-import/parser.d.ts +0 -44
- package/dist/unstable-core-do-not-import/parser.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/parser.js +0 -54
- package/dist/unstable-core-do-not-import/parser.mjs +0 -52
- package/dist/unstable-core-do-not-import/procedure.d.ts +0 -77
- package/dist/unstable-core-do-not-import/procedure.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/procedure.js +0 -9
- package/dist/unstable-core-do-not-import/procedure.mjs +0 -7
- package/dist/unstable-core-do-not-import/procedureBuilder.d.ts +0 -161
- package/dist/unstable-core-do-not-import/procedureBuilder.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/procedureBuilder.js +0 -201
- package/dist/unstable-core-do-not-import/procedureBuilder.mjs +0 -199
- package/dist/unstable-core-do-not-import/rootConfig.d.ts +0 -98
- package/dist/unstable-core-do-not-import/rootConfig.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/rootConfig.js +0 -8
- package/dist/unstable-core-do-not-import/rootConfig.mjs +0 -6
- package/dist/unstable-core-do-not-import/router.d.ts +0 -98
- package/dist/unstable-core-do-not-import/router.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/router.js +0 -285
- package/dist/unstable-core-do-not-import/router.mjs +0 -278
- package/dist/unstable-core-do-not-import/rpc/codes.d.ts +0 -45
- package/dist/unstable-core-do-not-import/rpc/codes.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/rpc/codes.js +0 -69
- package/dist/unstable-core-do-not-import/rpc/codes.mjs +0 -65
- package/dist/unstable-core-do-not-import/rpc/envelopes.d.ts +0 -109
- package/dist/unstable-core-do-not-import/rpc/envelopes.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/rpc/index.d.ts +0 -5
- package/dist/unstable-core-do-not-import/rpc/index.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/rpc/parseTRPCMessage.d.ts +0 -5
- package/dist/unstable-core-do-not-import/rpc/parseTRPCMessage.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/rpc/parseTRPCMessage.js +0 -63
- package/dist/unstable-core-do-not-import/rpc/parseTRPCMessage.mjs +0 -61
- package/dist/unstable-core-do-not-import/stream/jsonl.d.ts +0 -119
- package/dist/unstable-core-do-not-import/stream/jsonl.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/stream/jsonl.js +0 -607
- package/dist/unstable-core-do-not-import/stream/jsonl.mjs +0 -603
- package/dist/unstable-core-do-not-import/stream/sse.d.ts +0 -108
- package/dist/unstable-core-do-not-import/stream/sse.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/stream/sse.js +0 -373
- package/dist/unstable-core-do-not-import/stream/sse.mjs +0 -369
- package/dist/unstable-core-do-not-import/stream/sse.types.d.ts +0 -31
- package/dist/unstable-core-do-not-import/stream/sse.types.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/stream/tracked.d.ts +0 -31
- package/dist/unstable-core-do-not-import/stream/tracked.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/stream/tracked.js +0 -29
- package/dist/unstable-core-do-not-import/stream/tracked.mjs +0 -25
- package/dist/unstable-core-do-not-import/stream/utils/asyncIterable.d.ts +0 -17
- package/dist/unstable-core-do-not-import/stream/utils/asyncIterable.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/stream/utils/asyncIterable.js +0 -174
- package/dist/unstable-core-do-not-import/stream/utils/asyncIterable.mjs +0 -170
- package/dist/unstable-core-do-not-import/stream/utils/createDeferred.d.ts +0 -7
- package/dist/unstable-core-do-not-import/stream/utils/createDeferred.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/stream/utils/createDeferred.js +0 -17
- package/dist/unstable-core-do-not-import/stream/utils/createDeferred.mjs +0 -15
- package/dist/unstable-core-do-not-import/stream/utils/disposable.d.ts +0 -17
- package/dist/unstable-core-do-not-import/stream/utils/disposable.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/stream/utils/disposable.js +0 -46
- package/dist/unstable-core-do-not-import/stream/utils/disposable.mjs +0 -43
- package/dist/unstable-core-do-not-import/stream/utils/mergeAsyncIterables.d.ts +0 -17
- package/dist/unstable-core-do-not-import/stream/utils/mergeAsyncIterables.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/stream/utils/mergeAsyncIterables.js +0 -241
- package/dist/unstable-core-do-not-import/stream/utils/mergeAsyncIterables.mjs +0 -239
- package/dist/unstable-core-do-not-import/stream/utils/readableStreamFrom.d.ts +0 -8
- package/dist/unstable-core-do-not-import/stream/utils/readableStreamFrom.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/stream/utils/readableStreamFrom.js +0 -25
- package/dist/unstable-core-do-not-import/stream/utils/readableStreamFrom.mjs +0 -23
- package/dist/unstable-core-do-not-import/stream/utils/timerResource.d.ts +0 -5
- package/dist/unstable-core-do-not-import/stream/utils/timerResource.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/stream/utils/timerResource.js +0 -26
- package/dist/unstable-core-do-not-import/stream/utils/timerResource.mjs +0 -23
- package/dist/unstable-core-do-not-import/stream/utils/withPing.d.ts +0 -7
- package/dist/unstable-core-do-not-import/stream/utils/withPing.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/stream/utils/withPing.js +0 -130
- package/dist/unstable-core-do-not-import/stream/utils/withPing.mjs +0 -127
- package/dist/unstable-core-do-not-import/transformer.d.ts +0 -99
- package/dist/unstable-core-do-not-import/transformer.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/transformer.js +0 -106
- package/dist/unstable-core-do-not-import/transformer.mjs +0 -101
- package/dist/unstable-core-do-not-import/types.d.ts +0 -127
- package/dist/unstable-core-do-not-import/types.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/utils.d.ts +0 -42
- package/dist/unstable-core-do-not-import/utils.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/utils.js +0 -96
- package/dist/unstable-core-do-not-import/utils.mjs +0 -83
- package/dist/unstable-core-do-not-import.d.ts +0 -47
- package/dist/unstable-core-do-not-import.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import.js +0 -109
- package/dist/vendor/cookie-es/set-cookie/split.d.ts +0 -18
- package/dist/vendor/cookie-es/set-cookie/split.d.ts.map +0 -1
- package/dist/vendor/cookie-es/set-cookie/split.js +0 -79
- package/dist/vendor/cookie-es/set-cookie/split.mjs +0 -77
- package/dist/vendor/standard-schema-v1/error.d.ts +0 -13
- package/dist/vendor/standard-schema-v1/error.d.ts.map +0 -1
- package/dist/vendor/standard-schema-v1/error.js +0 -28
- package/dist/vendor/standard-schema-v1/error.mjs +0 -26
- package/dist/vendor/standard-schema-v1/spec.d.ts +0 -60
- package/dist/vendor/standard-schema-v1/spec.d.ts.map +0 -1
- package/dist/vendor/unpromise/index.d.ts +0 -3
- package/dist/vendor/unpromise/index.d.ts.map +0 -1
- package/dist/vendor/unpromise/types.d.ts +0 -28
- package/dist/vendor/unpromise/types.d.ts.map +0 -1
- package/dist/vendor/unpromise/unpromise.d.ts +0 -121
- package/dist/vendor/unpromise/unpromise.d.ts.map +0 -1
- package/dist/vendor/unpromise/unpromise.js +0 -292
- package/dist/vendor/unpromise/unpromise.mjs +0 -289
- package/http/index.d.ts +0 -1
- package/http/index.js +0 -1
- package/observable/index.d.ts +0 -1
- package/observable/index.js +0 -1
- package/rpc/index.d.ts +0 -1
- package/rpc/index.js +0 -1
- package/shared/index.d.ts +0 -1
- package/shared/index.js +0 -1
- package/unstable-core-do-not-import/index.d.ts +0 -1
- package/unstable-core-do-not-import/index.js +0 -1
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
import '../../unstable-core-do-not-import/rpc/codes.mjs';
|
|
2
|
-
import { TRPCError } from '../../unstable-core-do-not-import/error/TRPCError.mjs';
|
|
3
|
-
import '../../vendor/unpromise/unpromise.mjs';
|
|
4
|
-
import '../../unstable-core-do-not-import/stream/utils/disposable.mjs';
|
|
5
|
-
import '../../unstable-core-do-not-import/rootConfig.mjs';
|
|
6
|
-
|
|
7
|
-
function createBody(req, opts) {
|
|
8
|
-
// Some adapters will pre-parse the body and add it to the request object
|
|
9
|
-
if ('body' in req) {
|
|
10
|
-
if (req.body === undefined) {
|
|
11
|
-
// If body property exists but is undefined, return undefined
|
|
12
|
-
return undefined;
|
|
13
|
-
}
|
|
14
|
-
// If the body is already a string, return it directly
|
|
15
|
-
if (typeof req.body === 'string') {
|
|
16
|
-
return req.body;
|
|
17
|
-
}
|
|
18
|
-
// If body exists but isn't a string, stringify it as JSON
|
|
19
|
-
return JSON.stringify(req.body);
|
|
20
|
-
}
|
|
21
|
-
let size = 0;
|
|
22
|
-
let hasClosed = false;
|
|
23
|
-
return new ReadableStream({
|
|
24
|
-
start (controller) {
|
|
25
|
-
const onData = (chunk)=>{
|
|
26
|
-
size += chunk.length;
|
|
27
|
-
if (!opts.maxBodySize || size <= opts.maxBodySize) {
|
|
28
|
-
controller.enqueue(new Uint8Array(chunk.buffer, chunk.byteOffset, chunk.byteLength));
|
|
29
|
-
return;
|
|
30
|
-
}
|
|
31
|
-
controller.error(new TRPCError({
|
|
32
|
-
code: 'PAYLOAD_TOO_LARGE'
|
|
33
|
-
}));
|
|
34
|
-
hasClosed = true;
|
|
35
|
-
req.off('data', onData);
|
|
36
|
-
req.off('end', onEnd);
|
|
37
|
-
};
|
|
38
|
-
const onEnd = ()=>{
|
|
39
|
-
if (hasClosed) {
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
hasClosed = true;
|
|
43
|
-
req.off('data', onData);
|
|
44
|
-
req.off('end', onEnd);
|
|
45
|
-
controller.close();
|
|
46
|
-
};
|
|
47
|
-
req.on('data', onData);
|
|
48
|
-
req.on('end', onEnd);
|
|
49
|
-
},
|
|
50
|
-
cancel () {
|
|
51
|
-
req.destroy();
|
|
52
|
-
}
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
function createURL(req) {
|
|
56
|
-
try {
|
|
57
|
-
const protocol = // http2
|
|
58
|
-
req.headers[':scheme'] && req.headers[':scheme'] === 'https' || // http1
|
|
59
|
-
req.socket && 'encrypted' in req.socket && req.socket.encrypted ? 'https:' : 'http:';
|
|
60
|
-
const host = req.headers.host ?? req.headers[':authority'] ?? 'localhost';
|
|
61
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
62
|
-
return new URL(req.url, `${protocol}//${host}`);
|
|
63
|
-
} catch (cause) {
|
|
64
|
-
throw new TRPCError({
|
|
65
|
-
code: 'BAD_REQUEST',
|
|
66
|
-
message: 'Invalid URL',
|
|
67
|
-
cause
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
function createHeaders(incoming) {
|
|
72
|
-
const headers = new Headers();
|
|
73
|
-
for(const key in incoming){
|
|
74
|
-
const value = incoming[key];
|
|
75
|
-
if (typeof key === 'string' && key.startsWith(':')) {
|
|
76
|
-
continue;
|
|
77
|
-
}
|
|
78
|
-
if (Array.isArray(value)) {
|
|
79
|
-
for (const item of value){
|
|
80
|
-
headers.append(key, item);
|
|
81
|
-
}
|
|
82
|
-
} else if (value != null) {
|
|
83
|
-
headers.append(key, value);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
return headers;
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* Convert an [`IncomingMessage`](https://nodejs.org/api/http.html#class-httpincomingmessage) to a [`Request`](https://developer.mozilla.org/en-US/docs/Web/API/Request)
|
|
90
|
-
*/ function incomingMessageToRequest(req, res, opts) {
|
|
91
|
-
const ac = new AbortController();
|
|
92
|
-
const onAbort = ()=>{
|
|
93
|
-
res.off('close', onAbort);
|
|
94
|
-
req.socket?.off?.('close', onAbort);
|
|
95
|
-
// abort the request
|
|
96
|
-
ac.abort();
|
|
97
|
-
};
|
|
98
|
-
res.once('close', onAbort);
|
|
99
|
-
req.socket?.once?.('close', onAbort);
|
|
100
|
-
// Get host from either regular header or HTTP/2 pseudo-header
|
|
101
|
-
const url = createURL(req);
|
|
102
|
-
const init = {
|
|
103
|
-
headers: createHeaders(req.headers),
|
|
104
|
-
method: req.method,
|
|
105
|
-
signal: ac.signal
|
|
106
|
-
};
|
|
107
|
-
if (req.method !== 'GET' && req.method !== 'HEAD') {
|
|
108
|
-
init.body = createBody(req, opts);
|
|
109
|
-
// init.duplex = 'half' must be set when body is a ReadableStream, and Node follows the spec.
|
|
110
|
-
// However, this property is not defined in the TypeScript types for RequestInit, so we have
|
|
111
|
-
// to cast it here in order to set it without a type error.
|
|
112
|
-
// See https://fetch.spec.whatwg.org/#dom-requestinit-duplex
|
|
113
|
-
// @ts-expect-error this is fine
|
|
114
|
-
init.duplex = 'half';
|
|
115
|
-
}
|
|
116
|
-
const request = new Request(url, init);
|
|
117
|
-
return request;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
export { createURL, incomingMessageToRequest };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/adapters/node-http/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC;AACzC,cAAc,SAAS,CAAC;AACxB,cAAc,4BAA4B,CAAC"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var nodeHTTPRequestHandler = require('./nodeHTTPRequestHandler.js');
|
|
4
|
-
var incomingMessageToRequest = require('./incomingMessageToRequest.js');
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
exports.internal_exceptionHandler = nodeHTTPRequestHandler.internal_exceptionHandler;
|
|
9
|
-
exports.nodeHTTPRequestHandler = nodeHTTPRequestHandler.nodeHTTPRequestHandler;
|
|
10
|
-
exports.createURL = incomingMessageToRequest.createURL;
|
|
11
|
-
exports.incomingMessageToRequest = incomingMessageToRequest.incomingMessageToRequest;
|
|
@@ -1,20 +0,0 @@
|
|
|
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
|
-
*/
|
|
10
|
-
import { type AnyRouter } from '../../@trpc/server';
|
|
11
|
-
import type { NodeHTTPRequest, NodeHTTPRequestHandlerOptions, NodeHTTPResponse } from './types';
|
|
12
|
-
/**
|
|
13
|
-
* @internal
|
|
14
|
-
*/
|
|
15
|
-
export declare function internal_exceptionHandler<TRouter extends AnyRouter, TRequest extends NodeHTTPRequest, TResponse extends NodeHTTPResponse>(opts: NodeHTTPRequestHandlerOptions<TRouter, TRequest, TResponse>): (cause: unknown) => void;
|
|
16
|
-
/**
|
|
17
|
-
* @remark the promise never rejects
|
|
18
|
-
*/
|
|
19
|
-
export declare function nodeHTTPRequestHandler<TRouter extends AnyRouter, TRequest extends NodeHTTPRequest, TResponse extends NodeHTTPResponse>(opts: NodeHTTPRequestHandlerOptions<TRouter, TRequest, TResponse>): Promise<void>;
|
|
20
|
-
//# sourceMappingURL=nodeHTTPRequestHandler.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"nodeHTTPRequestHandler.d.ts","sourceRoot":"","sources":["../../../src/adapters/node-http/nodeHTTPRequestHandler.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,OAAO,EAGL,KAAK,SAAS,EACf,MAAM,oBAAoB,CAAC;AAM5B,OAAO,KAAK,EACV,eAAe,EACf,6BAA6B,EAC7B,gBAAgB,EACjB,MAAM,SAAS,CAAC;AAGjB;;GAEG;AACH,wBAAgB,yBAAyB,CACvC,OAAO,SAAS,SAAS,EACzB,QAAQ,SAAS,eAAe,EAChC,SAAS,SAAS,gBAAgB,EAClC,IAAI,EAAE,6BAA6B,CAAC,OAAO,EAAE,QAAQ,EAAE,SAAS,CAAC,IACzD,OAAO,OAAO,UA6BvB;AAED;;GAEG;AACH,wBAAsB,sBAAsB,CAC1C,OAAO,SAAS,SAAS,EACzB,QAAQ,SAAS,eAAe,EAChC,SAAS,SAAS,gBAAgB,EAClC,IAAI,EAAE,6BAA6B,CAAC,OAAO,EAAE,QAAQ,EAAE,SAAS,CAAC,iBA6ClE"}
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var getErrorShape = require('../../unstable-core-do-not-import/error/getErrorShape.js');
|
|
4
|
-
var TRPCError = require('../../unstable-core-do-not-import/error/TRPCError.js');
|
|
5
|
-
var transformer = require('../../unstable-core-do-not-import/transformer.js');
|
|
6
|
-
var utils = require('../../unstable-core-do-not-import/utils.js');
|
|
7
|
-
require('../../unstable-core-do-not-import/rpc/codes.js');
|
|
8
|
-
var resolveResponse = require('../../unstable-core-do-not-import/http/resolveResponse.js');
|
|
9
|
-
require('../../unstable-core-do-not-import/rootConfig.js');
|
|
10
|
-
require('../../vendor/unpromise/unpromise.js');
|
|
11
|
-
require('../../unstable-core-do-not-import/stream/utils/disposable.js');
|
|
12
|
-
var incomingMessageToRequest = require('./incomingMessageToRequest.js');
|
|
13
|
-
var writeResponse = require('./writeResponse.js');
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* 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`
|
|
17
|
-
*
|
|
18
|
-
* @example
|
|
19
|
-
* ```ts
|
|
20
|
-
* import type { AnyTRPCRouter } from '@trpc/server'
|
|
21
|
-
* import type { HTTPBaseHandlerOptions } from '@trpc/server/http'
|
|
22
|
-
* ```
|
|
23
|
-
*/ // @trpc/server
|
|
24
|
-
/**
|
|
25
|
-
* @internal
|
|
26
|
-
*/ function internal_exceptionHandler(opts) {
|
|
27
|
-
return (cause)=>{
|
|
28
|
-
const { res, req } = opts;
|
|
29
|
-
const error = TRPCError.getTRPCErrorFromUnknown(cause);
|
|
30
|
-
const shape = getErrorShape.getErrorShape({
|
|
31
|
-
config: opts.router._def._config,
|
|
32
|
-
error,
|
|
33
|
-
type: 'unknown',
|
|
34
|
-
path: undefined,
|
|
35
|
-
input: undefined,
|
|
36
|
-
ctx: undefined
|
|
37
|
-
});
|
|
38
|
-
opts.onError?.({
|
|
39
|
-
req,
|
|
40
|
-
error,
|
|
41
|
-
type: 'unknown',
|
|
42
|
-
path: undefined,
|
|
43
|
-
input: undefined,
|
|
44
|
-
ctx: undefined
|
|
45
|
-
});
|
|
46
|
-
const transformed = transformer.transformTRPCResponse(opts.router._def._config, {
|
|
47
|
-
error: shape
|
|
48
|
-
});
|
|
49
|
-
res.statusCode = shape.data.httpStatus;
|
|
50
|
-
res.end(JSON.stringify(transformed));
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* @remark the promise never rejects
|
|
55
|
-
*/ async function nodeHTTPRequestHandler(opts) {
|
|
56
|
-
return new Promise((resolve)=>{
|
|
57
|
-
const handleViaMiddleware = opts.middleware ?? ((_req, _res, next)=>next());
|
|
58
|
-
opts.res.once('finish', ()=>{
|
|
59
|
-
resolve();
|
|
60
|
-
});
|
|
61
|
-
return handleViaMiddleware(opts.req, opts.res, (err)=>{
|
|
62
|
-
utils.run(async ()=>{
|
|
63
|
-
const request = incomingMessageToRequest.incomingMessageToRequest(opts.req, opts.res, {
|
|
64
|
-
maxBodySize: opts.maxBodySize ?? null
|
|
65
|
-
});
|
|
66
|
-
// Build tRPC dependencies
|
|
67
|
-
const createContext = async (innerOpts)=>{
|
|
68
|
-
return await opts.createContext?.({
|
|
69
|
-
...opts,
|
|
70
|
-
...innerOpts
|
|
71
|
-
});
|
|
72
|
-
};
|
|
73
|
-
const response = await resolveResponse.resolveResponse({
|
|
74
|
-
...opts,
|
|
75
|
-
req: request,
|
|
76
|
-
error: err ? TRPCError.getTRPCErrorFromUnknown(err) : null,
|
|
77
|
-
createContext,
|
|
78
|
-
onError (o) {
|
|
79
|
-
opts?.onError?.({
|
|
80
|
-
...o,
|
|
81
|
-
req: opts.req
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
});
|
|
85
|
-
await writeResponse.writeResponse({
|
|
86
|
-
request,
|
|
87
|
-
response,
|
|
88
|
-
rawResponse: opts.res
|
|
89
|
-
});
|
|
90
|
-
}).catch(internal_exceptionHandler(opts));
|
|
91
|
-
});
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
exports.internal_exceptionHandler = internal_exceptionHandler;
|
|
96
|
-
exports.nodeHTTPRequestHandler = nodeHTTPRequestHandler;
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import { getErrorShape } from '../../unstable-core-do-not-import/error/getErrorShape.mjs';
|
|
2
|
-
import { getTRPCErrorFromUnknown } from '../../unstable-core-do-not-import/error/TRPCError.mjs';
|
|
3
|
-
import { transformTRPCResponse } from '../../unstable-core-do-not-import/transformer.mjs';
|
|
4
|
-
import { run } from '../../unstable-core-do-not-import/utils.mjs';
|
|
5
|
-
import '../../unstable-core-do-not-import/rpc/codes.mjs';
|
|
6
|
-
import { resolveResponse } from '../../unstable-core-do-not-import/http/resolveResponse.mjs';
|
|
7
|
-
import '../../unstable-core-do-not-import/rootConfig.mjs';
|
|
8
|
-
import '../../vendor/unpromise/unpromise.mjs';
|
|
9
|
-
import '../../unstable-core-do-not-import/stream/utils/disposable.mjs';
|
|
10
|
-
import { incomingMessageToRequest } from './incomingMessageToRequest.mjs';
|
|
11
|
-
import { writeResponse } from './writeResponse.mjs';
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* 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`
|
|
15
|
-
*
|
|
16
|
-
* @example
|
|
17
|
-
* ```ts
|
|
18
|
-
* import type { AnyTRPCRouter } from '@trpc/server'
|
|
19
|
-
* import type { HTTPBaseHandlerOptions } from '@trpc/server/http'
|
|
20
|
-
* ```
|
|
21
|
-
*/ // @trpc/server
|
|
22
|
-
/**
|
|
23
|
-
* @internal
|
|
24
|
-
*/ function internal_exceptionHandler(opts) {
|
|
25
|
-
return (cause)=>{
|
|
26
|
-
const { res, req } = opts;
|
|
27
|
-
const error = getTRPCErrorFromUnknown(cause);
|
|
28
|
-
const shape = getErrorShape({
|
|
29
|
-
config: opts.router._def._config,
|
|
30
|
-
error,
|
|
31
|
-
type: 'unknown',
|
|
32
|
-
path: undefined,
|
|
33
|
-
input: undefined,
|
|
34
|
-
ctx: undefined
|
|
35
|
-
});
|
|
36
|
-
opts.onError?.({
|
|
37
|
-
req,
|
|
38
|
-
error,
|
|
39
|
-
type: 'unknown',
|
|
40
|
-
path: undefined,
|
|
41
|
-
input: undefined,
|
|
42
|
-
ctx: undefined
|
|
43
|
-
});
|
|
44
|
-
const transformed = transformTRPCResponse(opts.router._def._config, {
|
|
45
|
-
error: shape
|
|
46
|
-
});
|
|
47
|
-
res.statusCode = shape.data.httpStatus;
|
|
48
|
-
res.end(JSON.stringify(transformed));
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* @remark the promise never rejects
|
|
53
|
-
*/ async function nodeHTTPRequestHandler(opts) {
|
|
54
|
-
return new Promise((resolve)=>{
|
|
55
|
-
const handleViaMiddleware = opts.middleware ?? ((_req, _res, next)=>next());
|
|
56
|
-
opts.res.once('finish', ()=>{
|
|
57
|
-
resolve();
|
|
58
|
-
});
|
|
59
|
-
return handleViaMiddleware(opts.req, opts.res, (err)=>{
|
|
60
|
-
run(async ()=>{
|
|
61
|
-
const request = incomingMessageToRequest(opts.req, opts.res, {
|
|
62
|
-
maxBodySize: opts.maxBodySize ?? null
|
|
63
|
-
});
|
|
64
|
-
// Build tRPC dependencies
|
|
65
|
-
const createContext = async (innerOpts)=>{
|
|
66
|
-
return await opts.createContext?.({
|
|
67
|
-
...opts,
|
|
68
|
-
...innerOpts
|
|
69
|
-
});
|
|
70
|
-
};
|
|
71
|
-
const response = await resolveResponse({
|
|
72
|
-
...opts,
|
|
73
|
-
req: request,
|
|
74
|
-
error: err ? getTRPCErrorFromUnknown(err) : null,
|
|
75
|
-
createContext,
|
|
76
|
-
onError (o) {
|
|
77
|
-
opts?.onError?.({
|
|
78
|
-
...o,
|
|
79
|
-
req: opts.req
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
});
|
|
83
|
-
await writeResponse({
|
|
84
|
-
request,
|
|
85
|
-
response,
|
|
86
|
-
rawResponse: opts.res
|
|
87
|
-
});
|
|
88
|
-
}).catch(internal_exceptionHandler(opts));
|
|
89
|
-
});
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
export { internal_exceptionHandler, nodeHTTPRequestHandler };
|
|
@@ -1,81 +0,0 @@
|
|
|
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
|
-
*/
|
|
10
|
-
import type * as http from 'http';
|
|
11
|
-
import type * as http2 from 'http2';
|
|
12
|
-
import type { AnyRouter, CreateContextCallback, inferRouterContext } from '../../@trpc/server';
|
|
13
|
-
import type { HTTPBaseHandlerOptions, TRPCRequestInfo } from '../../@trpc/server/http';
|
|
14
|
-
import type { DistributiveOmit, MaybePromise } from '../../unstable-core-do-not-import';
|
|
15
|
-
export type NodeHTTPRequest = DistributiveOmit<http.IncomingMessage | http2.Http2ServerRequest, 'socket'> & {
|
|
16
|
-
/**
|
|
17
|
-
* Many adapters will add a `body` property to the incoming message and pre-parse the body
|
|
18
|
-
*/
|
|
19
|
-
body?: unknown;
|
|
20
|
-
/**
|
|
21
|
-
* Socket is not always available in all deployments, so we need to make it optional
|
|
22
|
-
* @see https://github.com/trpc/trpc/issues/6341
|
|
23
|
-
* The socket object provided in the request does not fully implement the expected Node.js Socket interface.
|
|
24
|
-
* @see https://github.com/trpc/trpc/pull/6358
|
|
25
|
-
*/
|
|
26
|
-
socket?: Partial<http.IncomingMessage['socket']> | Partial<http2.Http2ServerRequest['socket']>;
|
|
27
|
-
};
|
|
28
|
-
export type NodeHTTPResponse = DistributiveOmit<http.ServerResponse | http2.Http2ServerResponse, 'write'> & {
|
|
29
|
-
/**
|
|
30
|
-
* Force the partially-compressed response to be flushed to the client.
|
|
31
|
-
*
|
|
32
|
-
* Added by compression middleware
|
|
33
|
-
* (depending on the environment,
|
|
34
|
-
* e.g. Next <= 12,
|
|
35
|
-
* e.g. Express w/ `compression()`)
|
|
36
|
-
*/
|
|
37
|
-
flush?: () => void;
|
|
38
|
-
write: (chunk: string | Uint8Array) => boolean;
|
|
39
|
-
};
|
|
40
|
-
export type NodeHTTPCreateContextOption<TRouter extends AnyRouter, TRequest, TResponse> = CreateContextCallback<inferRouterContext<TRouter>, NodeHTTPCreateContextFn<TRouter, TRequest, TResponse>>;
|
|
41
|
-
/**
|
|
42
|
-
* @internal
|
|
43
|
-
*/
|
|
44
|
-
type ConnectMiddleware<TRequest extends NodeHTTPRequest = NodeHTTPRequest, TResponse extends NodeHTTPResponse = NodeHTTPResponse> = (req: TRequest, res: TResponse, next: (err?: any) => any) => void;
|
|
45
|
-
export type NodeHTTPHandlerOptions<TRouter extends AnyRouter, TRequest extends NodeHTTPRequest, TResponse extends NodeHTTPResponse> = HTTPBaseHandlerOptions<TRouter, TRequest> & NodeHTTPCreateContextOption<TRouter, TRequest, TResponse> & {
|
|
46
|
-
/**
|
|
47
|
-
* By default, http `OPTIONS` requests are not handled, and CORS headers are not returned.
|
|
48
|
-
*
|
|
49
|
-
* This can be used to handle them manually or via the `cors` npm package: https://www.npmjs.com/package/cors
|
|
50
|
-
*
|
|
51
|
-
* ```ts
|
|
52
|
-
* import cors from 'cors'
|
|
53
|
-
*
|
|
54
|
-
* nodeHTTPRequestHandler({
|
|
55
|
-
* cors: cors()
|
|
56
|
-
* })
|
|
57
|
-
* ```
|
|
58
|
-
*
|
|
59
|
-
* You can also use it for other needs which a connect/node.js compatible middleware can solve,
|
|
60
|
-
* though you might wish to consider an alternative solution like the Express adapter if your needs are complex.
|
|
61
|
-
*/
|
|
62
|
-
middleware?: ConnectMiddleware<TRequest, TResponse>;
|
|
63
|
-
maxBodySize?: number;
|
|
64
|
-
};
|
|
65
|
-
export type NodeHTTPRequestHandlerOptions<TRouter extends AnyRouter, TRequest extends NodeHTTPRequest, TResponse extends NodeHTTPResponse> = NodeHTTPHandlerOptions<TRouter, TRequest, TResponse> & {
|
|
66
|
-
req: TRequest;
|
|
67
|
-
res: TResponse;
|
|
68
|
-
/**
|
|
69
|
-
* The tRPC path to handle requests for
|
|
70
|
-
* @example 'post.all'
|
|
71
|
-
*/
|
|
72
|
-
path: string;
|
|
73
|
-
};
|
|
74
|
-
export type NodeHTTPCreateContextFnOptions<TRequest, TResponse> = {
|
|
75
|
-
req: TRequest;
|
|
76
|
-
res: TResponse;
|
|
77
|
-
info: TRPCRequestInfo;
|
|
78
|
-
};
|
|
79
|
-
export type NodeHTTPCreateContextFn<TRouter extends AnyRouter, TRequest, TResponse> = (opts: NodeHTTPCreateContextFnOptions<TRequest, TResponse>) => MaybePromise<inferRouterContext<TRouter>>;
|
|
80
|
-
export {};
|
|
81
|
-
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/adapters/node-http/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,KAAK,IAAI,MAAM,MAAM,CAAC;AAClC,OAAO,KAAK,KAAK,KAAK,MAAM,OAAO,CAAC;AAEpC,OAAO,KAAK,EACV,SAAS,EACT,qBAAqB,EACrB,kBAAkB,EACnB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,KAAK,EACV,sBAAsB,EACtB,eAAe,EAChB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,KAAK,EACV,gBAAgB,EAChB,YAAY,EACb,MAAM,mCAAmC,CAAC;AAE3C,MAAM,MAAM,eAAe,GAAG,gBAAgB,CAC5C,IAAI,CAAC,eAAe,GAAG,KAAK,CAAC,kBAAkB,EAC/C,QAAQ,CACT,GAAG;IACF;;OAEG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;IACf;;;;;OAKG;IACH,MAAM,CAAC,EACH,OAAO,CAAC,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC,GACvC,OAAO,CAAC,KAAK,CAAC,kBAAkB,CAAC,QAAQ,CAAC,CAAC,CAAC;CACjD,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG,gBAAgB,CAC7C,IAAI,CAAC,cAAc,GAAG,KAAK,CAAC,mBAAmB,EAC/C,OAAO,CACR,GAAG;IACF;;;;;;;OAOG;IACH,KAAK,CAAC,EAAE,MAAM,IAAI,CAAC;IAEnB,KAAK,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,UAAU,KAAK,OAAO,CAAC;CAChD,CAAC;AACF,MAAM,MAAM,2BAA2B,CACrC,OAAO,SAAS,SAAS,EACzB,QAAQ,EACR,SAAS,IACP,qBAAqB,CACvB,kBAAkB,CAAC,OAAO,CAAC,EAC3B,uBAAuB,CAAC,OAAO,EAAE,QAAQ,EAAE,SAAS,CAAC,CACtD,CAAC;AAEF;;GAEG;AACH,KAAK,iBAAiB,CACpB,QAAQ,SAAS,eAAe,GAAG,eAAe,EAClD,SAAS,SAAS,gBAAgB,GAAG,gBAAgB,IACnD,CAAC,GAAG,EAAE,QAAQ,EAAE,GAAG,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,GAAG,CAAC,EAAE,GAAG,KAAK,GAAG,KAAK,IAAI,CAAC;AAEtE,MAAM,MAAM,sBAAsB,CAChC,OAAO,SAAS,SAAS,EACzB,QAAQ,SAAS,eAAe,EAChC,SAAS,SAAS,gBAAgB,IAChC,sBAAsB,CAAC,OAAO,EAAE,QAAQ,CAAC,GAC3C,2BAA2B,CAAC,OAAO,EAAE,QAAQ,EAAE,SAAS,CAAC,GAAG;IAC1D;;;;;;;;;;;;;;;OAeG;IACH,UAAU,CAAC,EAAE,iBAAiB,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;IACpD,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAEJ,MAAM,MAAM,6BAA6B,CACvC,OAAO,SAAS,SAAS,EACzB,QAAQ,SAAS,eAAe,EAChC,SAAS,SAAS,gBAAgB,IAChC,sBAAsB,CAAC,OAAO,EAAE,QAAQ,EAAE,SAAS,CAAC,GAAG;IACzD,GAAG,EAAE,QAAQ,CAAC;IACd,GAAG,EAAE,SAAS,CAAC;IACf;;;OAGG;IACH,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,MAAM,MAAM,8BAA8B,CAAC,QAAQ,EAAE,SAAS,IAAI;IAChE,GAAG,EAAE,QAAQ,CAAC;IACd,GAAG,EAAE,SAAS,CAAC;IACf,IAAI,EAAE,eAAe,CAAC;CACvB,CAAC;AACF,MAAM,MAAM,uBAAuB,CACjC,OAAO,SAAS,SAAS,EACzB,QAAQ,EACR,SAAS,IACP,CACF,IAAI,EAAE,8BAA8B,CAAC,QAAQ,EAAE,SAAS,CAAC,KACtD,YAAY,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC,CAAC"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { NodeHTTPResponse } from './types';
|
|
2
|
-
/**
|
|
3
|
-
* @internal
|
|
4
|
-
*/
|
|
5
|
-
export declare function writeResponseBody(opts: {
|
|
6
|
-
res: NodeHTTPResponse;
|
|
7
|
-
signal: AbortSignal;
|
|
8
|
-
body: NonNullable<Response['body']>;
|
|
9
|
-
}): Promise<void>;
|
|
10
|
-
/**
|
|
11
|
-
* @internal
|
|
12
|
-
*/
|
|
13
|
-
export declare function writeResponse(opts: {
|
|
14
|
-
request: Request;
|
|
15
|
-
response: Response;
|
|
16
|
-
rawResponse: NodeHTTPResponse;
|
|
17
|
-
}): Promise<void>;
|
|
18
|
-
//# sourceMappingURL=writeResponse.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"writeResponse.d.ts","sourceRoot":"","sources":["../../../src/adapters/node-http/writeResponse.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AA4BhD;;GAEG;AAEH,wBAAsB,iBAAiB,CAAC,IAAI,EAAE;IAC5C,GAAG,EAAE,gBAAgB,CAAC;IACtB,MAAM,EAAE,WAAW,CAAC;IACpB,IAAI,EAAE,WAAW,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;CACrC,iBAoBA;AACD;;GAEG;AAEH,wBAAsB,aAAa,CAAC,IAAI,EAAE;IACxC,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,QAAQ,CAAC;IACnB,WAAW,EAAE,gBAAgB,CAAC;CAC/B,iBA0BA"}
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
require('../../unstable-core-do-not-import/rpc/codes.js');
|
|
4
|
-
var abortError = require('../../unstable-core-do-not-import/http/abortError.js');
|
|
5
|
-
require('../../vendor/unpromise/unpromise.js');
|
|
6
|
-
require('../../unstable-core-do-not-import/stream/utils/disposable.js');
|
|
7
|
-
require('../../unstable-core-do-not-import/rootConfig.js');
|
|
8
|
-
|
|
9
|
-
// eslint-disable-next-line no-restricted-imports
|
|
10
|
-
async function writeResponseBodyChunk(res, chunk) {
|
|
11
|
-
// useful for debugging 🙃
|
|
12
|
-
// console.debug('writing', new TextDecoder().decode(chunk));
|
|
13
|
-
if (res.write(chunk) === false) {
|
|
14
|
-
await new Promise((resolve, reject)=>{
|
|
15
|
-
const onError = (err)=>{
|
|
16
|
-
reject(err);
|
|
17
|
-
cleanup();
|
|
18
|
-
};
|
|
19
|
-
const onDrain = ()=>{
|
|
20
|
-
resolve();
|
|
21
|
-
cleanup();
|
|
22
|
-
};
|
|
23
|
-
const cleanup = ()=>{
|
|
24
|
-
res.off('error', onError);
|
|
25
|
-
res.off('drain', onDrain);
|
|
26
|
-
};
|
|
27
|
-
res.once('error', onError);
|
|
28
|
-
res.once('drain', onDrain);
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* @internal
|
|
34
|
-
*/ async function writeResponseBody(opts) {
|
|
35
|
-
const { res } = opts;
|
|
36
|
-
try {
|
|
37
|
-
const writableStream = new WritableStream({
|
|
38
|
-
async write (chunk) {
|
|
39
|
-
await writeResponseBodyChunk(res, chunk);
|
|
40
|
-
res.flush?.();
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
|
-
await opts.body.pipeTo(writableStream, {
|
|
44
|
-
signal: opts.signal
|
|
45
|
-
});
|
|
46
|
-
} catch (err) {
|
|
47
|
-
if (abortError.isAbortError(err)) {
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
throw err;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* @internal
|
|
55
|
-
*/ async function writeResponse(opts) {
|
|
56
|
-
const { response, rawResponse } = opts;
|
|
57
|
-
// Only override status code if it hasn't been explicitly set in a procedure etc
|
|
58
|
-
if (rawResponse.statusCode === 200) {
|
|
59
|
-
rawResponse.statusCode = response.status;
|
|
60
|
-
}
|
|
61
|
-
for (const [key, value] of response.headers){
|
|
62
|
-
rawResponse.setHeader(key, value);
|
|
63
|
-
}
|
|
64
|
-
try {
|
|
65
|
-
if (response.body) {
|
|
66
|
-
await writeResponseBody({
|
|
67
|
-
res: rawResponse,
|
|
68
|
-
signal: opts.request.signal,
|
|
69
|
-
body: response.body
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
} catch (err) {
|
|
73
|
-
if (!rawResponse.headersSent) {
|
|
74
|
-
rawResponse.statusCode = 500;
|
|
75
|
-
}
|
|
76
|
-
throw err;
|
|
77
|
-
} finally{
|
|
78
|
-
rawResponse.end();
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
exports.writeResponse = writeResponse;
|
|
83
|
-
exports.writeResponseBody = writeResponseBody;
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import '../../unstable-core-do-not-import/rpc/codes.mjs';
|
|
2
|
-
import { isAbortError } from '../../unstable-core-do-not-import/http/abortError.mjs';
|
|
3
|
-
import '../../vendor/unpromise/unpromise.mjs';
|
|
4
|
-
import '../../unstable-core-do-not-import/stream/utils/disposable.mjs';
|
|
5
|
-
import '../../unstable-core-do-not-import/rootConfig.mjs';
|
|
6
|
-
|
|
7
|
-
// eslint-disable-next-line no-restricted-imports
|
|
8
|
-
async function writeResponseBodyChunk(res, chunk) {
|
|
9
|
-
// useful for debugging 🙃
|
|
10
|
-
// console.debug('writing', new TextDecoder().decode(chunk));
|
|
11
|
-
if (res.write(chunk) === false) {
|
|
12
|
-
await new Promise((resolve, reject)=>{
|
|
13
|
-
const onError = (err)=>{
|
|
14
|
-
reject(err);
|
|
15
|
-
cleanup();
|
|
16
|
-
};
|
|
17
|
-
const onDrain = ()=>{
|
|
18
|
-
resolve();
|
|
19
|
-
cleanup();
|
|
20
|
-
};
|
|
21
|
-
const cleanup = ()=>{
|
|
22
|
-
res.off('error', onError);
|
|
23
|
-
res.off('drain', onDrain);
|
|
24
|
-
};
|
|
25
|
-
res.once('error', onError);
|
|
26
|
-
res.once('drain', onDrain);
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* @internal
|
|
32
|
-
*/ async function writeResponseBody(opts) {
|
|
33
|
-
const { res } = opts;
|
|
34
|
-
try {
|
|
35
|
-
const writableStream = new WritableStream({
|
|
36
|
-
async write (chunk) {
|
|
37
|
-
await writeResponseBodyChunk(res, chunk);
|
|
38
|
-
res.flush?.();
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
await opts.body.pipeTo(writableStream, {
|
|
42
|
-
signal: opts.signal
|
|
43
|
-
});
|
|
44
|
-
} catch (err) {
|
|
45
|
-
if (isAbortError(err)) {
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
throw err;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* @internal
|
|
53
|
-
*/ async function writeResponse(opts) {
|
|
54
|
-
const { response, rawResponse } = opts;
|
|
55
|
-
// Only override status code if it hasn't been explicitly set in a procedure etc
|
|
56
|
-
if (rawResponse.statusCode === 200) {
|
|
57
|
-
rawResponse.statusCode = response.status;
|
|
58
|
-
}
|
|
59
|
-
for (const [key, value] of response.headers){
|
|
60
|
-
rawResponse.setHeader(key, value);
|
|
61
|
-
}
|
|
62
|
-
try {
|
|
63
|
-
if (response.body) {
|
|
64
|
-
await writeResponseBody({
|
|
65
|
-
res: rawResponse,
|
|
66
|
-
signal: opts.request.signal,
|
|
67
|
-
body: response.body
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
} catch (err) {
|
|
71
|
-
if (!rawResponse.headersSent) {
|
|
72
|
-
rawResponse.statusCode = 500;
|
|
73
|
-
}
|
|
74
|
-
throw err;
|
|
75
|
-
} finally{
|
|
76
|
-
rawResponse.end();
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
export { writeResponse, writeResponseBody };
|
|
@@ -1,36 +0,0 @@
|
|
|
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
|
-
*/
|
|
10
|
-
import http from 'http';
|
|
11
|
-
import type * as http2 from 'http2';
|
|
12
|
-
import { type AnyRouter } from '../@trpc/server';
|
|
13
|
-
import type { NodeHTTPCreateContextFnOptions, NodeHTTPHandlerOptions, NodeHTTPRequest, NodeHTTPResponse } from './node-http';
|
|
14
|
-
type StandaloneHandlerOptions<TRouter extends AnyRouter, TRequest extends NodeHTTPRequest, TResponse extends NodeHTTPResponse> = NodeHTTPHandlerOptions<TRouter, TRequest, TResponse> & {
|
|
15
|
-
/**
|
|
16
|
-
* The base path to handle requests for.
|
|
17
|
-
* This will be sliced from the beginning of the request path
|
|
18
|
-
* (Do not miss including the trailing slash)
|
|
19
|
-
* @default '/'
|
|
20
|
-
* @example '/trpc/'
|
|
21
|
-
* @example '/trpc/api/'
|
|
22
|
-
*/
|
|
23
|
-
basePath?: string;
|
|
24
|
-
};
|
|
25
|
-
export type CreateHTTPHandlerOptions<TRouter extends AnyRouter> = StandaloneHandlerOptions<TRouter, http.IncomingMessage, http.ServerResponse>;
|
|
26
|
-
export type CreateHTTPContextOptions = NodeHTTPCreateContextFnOptions<http.IncomingMessage, http.ServerResponse>;
|
|
27
|
-
/**
|
|
28
|
-
* @internal
|
|
29
|
-
*/
|
|
30
|
-
export declare function createHTTPHandler<TRouter extends AnyRouter>(opts: CreateHTTPHandlerOptions<TRouter>): http.RequestListener;
|
|
31
|
-
export declare function createHTTPServer<TRouter extends AnyRouter>(opts: CreateHTTPHandlerOptions<TRouter>): http.Server<typeof http.IncomingMessage, typeof http.ServerResponse>;
|
|
32
|
-
export type CreateHTTP2HandlerOptions<TRouter extends AnyRouter> = StandaloneHandlerOptions<TRouter, http2.Http2ServerRequest, http2.Http2ServerResponse>;
|
|
33
|
-
export type CreateHTTP2ContextOptions = NodeHTTPCreateContextFnOptions<http2.Http2ServerRequest, http2.Http2ServerResponse>;
|
|
34
|
-
export declare function createHTTP2Handler(opts: CreateHTTP2HandlerOptions<AnyRouter>): (req: http2.Http2ServerRequest, res: http2.Http2ServerResponse<http2.Http2ServerRequest>) => void;
|
|
35
|
-
export {};
|
|
36
|
-
//# sourceMappingURL=standalone.d.ts.map
|