@trpc/server 11.0.0-alpha-tmp-export-from-main.213 → 11.0.0-alpha-tmp-export-from-main-nuke-core.236
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 -0
- package/dist/@trpc/server/http.d.ts.map +1 -0
- package/dist/@trpc/server/index.d.ts +69 -0
- package/dist/@trpc/server/index.d.ts.map +1 -0
- package/dist/@trpc/server/rpc.d.ts +3 -0
- package/dist/@trpc/server/rpc.d.ts.map +1 -0
- package/dist/adapters/aws-lambda/index.d.ts +1 -2
- package/dist/adapters/aws-lambda/index.d.ts.map +1 -1
- package/dist/adapters/aws-lambda/index.js +20 -109
- package/dist/adapters/aws-lambda/index.mjs +5 -92
- package/dist/adapters/aws-lambda/utils.d.ts +2 -3
- package/dist/adapters/aws-lambda/utils.d.ts.map +1 -1
- package/dist/adapters/aws-lambda/utils.js +101 -0
- package/dist/adapters/aws-lambda/utils.mjs +94 -0
- package/dist/adapters/express.d.ts +1 -2
- package/dist/adapters/express.d.ts.map +1 -1
- package/dist/adapters/express.js +1 -6
- package/dist/adapters/express.mjs +1 -4
- package/dist/adapters/fastify/fastifyRequestHandler.d.ts +2 -2
- package/dist/adapters/fastify/fastifyRequestHandler.d.ts.map +1 -1
- package/dist/adapters/fastify/fastifyRequestHandler.js +84 -0
- package/dist/adapters/fastify/fastifyRequestHandler.mjs +82 -0
- package/dist/adapters/fastify/fastifyTRPCPlugin.d.ts +1 -2
- package/dist/adapters/fastify/fastifyTRPCPlugin.d.ts.map +1 -1
- package/dist/adapters/fastify/fastifyTRPCPlugin.js +50 -0
- package/dist/adapters/fastify/fastifyTRPCPlugin.mjs +48 -0
- package/dist/adapters/fastify/index.js +4 -125
- package/dist/adapters/fastify/index.mjs +2 -125
- package/dist/adapters/fetch/fetchRequestHandler.d.ts +1 -2
- package/dist/adapters/fetch/fetchRequestHandler.d.ts.map +1 -1
- package/dist/adapters/fetch/fetchRequestHandler.js +120 -0
- package/dist/adapters/fetch/fetchRequestHandler.mjs +118 -0
- package/dist/adapters/fetch/index.js +2 -115
- package/dist/adapters/fetch/index.mjs +1 -116
- package/dist/adapters/fetch/types.d.ts +2 -3
- package/dist/adapters/fetch/types.d.ts.map +1 -1
- package/dist/adapters/next.d.ts +1 -2
- package/dist/adapters/next.d.ts.map +1 -1
- package/dist/adapters/next.js +7 -9
- package/dist/adapters/next.mjs +5 -5
- package/dist/adapters/node-http/content-type/form-data/fileUploadHandler.js +161 -0
- package/dist/adapters/node-http/content-type/form-data/fileUploadHandler.mjs +157 -0
- package/dist/adapters/node-http/content-type/form-data/index.js +20 -646
- package/dist/adapters/node-http/content-type/form-data/index.mjs +9 -631
- package/dist/adapters/node-http/content-type/form-data/memoryUploadHandler.js +29 -0
- package/dist/adapters/node-http/content-type/form-data/memoryUploadHandler.mjs +27 -0
- package/dist/adapters/node-http/content-type/form-data/streamSlice.js +46 -0
- package/dist/adapters/node-http/content-type/form-data/streamSlice.mjs +44 -0
- package/dist/adapters/node-http/content-type/form-data/uploadHandler.js +30 -0
- package/dist/adapters/node-http/content-type/form-data/uploadHandler.mjs +26 -0
- package/dist/adapters/node-http/content-type/json/getPostBody.d.ts +1 -1
- package/dist/adapters/node-http/content-type/json/getPostBody.d.ts.map +1 -1
- package/dist/adapters/node-http/content-type/json/getPostBody.js +44 -0
- package/dist/adapters/node-http/content-type/json/getPostBody.mjs +42 -0
- package/dist/adapters/node-http/content-type/json/index.js +7 -43
- package/dist/adapters/node-http/content-type/json/index.mjs +5 -39
- package/dist/adapters/node-http/index.js +1 -6
- package/dist/adapters/node-http/index.mjs +1 -4
- package/dist/adapters/node-http/internals/contentType.d.ts +2 -2
- package/dist/adapters/node-http/internals/contentType.d.ts.map +1 -1
- package/dist/{contentType-72ed9df5.mjs → adapters/node-http/internals/contentType.mjs} +1 -1
- package/dist/adapters/node-http/nodeHTTPRequestHandler.d.ts +1 -2
- package/dist/adapters/node-http/nodeHTTPRequestHandler.d.ts.map +1 -1
- package/dist/{nodeHTTPRequestHandler-55f05150.js → adapters/node-http/nodeHTTPRequestHandler.js} +8 -6
- package/dist/{nodeHTTPRequestHandler-2d5c8791.mjs → adapters/node-http/nodeHTTPRequestHandler.mjs} +6 -4
- package/dist/adapters/node-http/types.d.ts +3 -4
- package/dist/adapters/node-http/types.d.ts.map +1 -1
- package/dist/adapters/standalone.d.ts +1 -2
- package/dist/adapters/standalone.d.ts.map +1 -1
- package/dist/adapters/standalone.js +3 -11
- package/dist/adapters/standalone.mjs +3 -5
- package/dist/adapters/ws.d.ts +3 -2
- package/dist/adapters/ws.d.ts.map +1 -1
- package/dist/adapters/ws.js +33 -28
- package/dist/adapters/ws.mjs +8 -1
- package/dist/bundle-analysis.json +757 -0
- package/dist/http.d.ts +1 -6
- package/dist/http.d.ts.map +1 -1
- package/dist/http.js +11 -23
- package/dist/http.mjs +6 -1
- package/dist/index.d.ts +1 -68
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +18 -43
- package/dist/index.mjs +8 -1
- package/dist/node_modules/.pnpm/@web3-storage_multipart-parser@1.0.0/node_modules/@web3-storage/multipart-parser/esm/src/index.js +203 -0
- package/dist/node_modules/.pnpm/@web3-storage_multipart-parser@1.0.0/node_modules/@web3-storage/multipart-parser/esm/src/index.mjs +201 -0
- package/dist/node_modules/.pnpm/@web3-storage_multipart-parser@1.0.0/node_modules/@web3-storage/multipart-parser/esm/src/search.js +167 -0
- package/dist/node_modules/.pnpm/@web3-storage_multipart-parser@1.0.0/node_modules/@web3-storage/multipart-parser/esm/src/search.mjs +163 -0
- package/dist/node_modules/.pnpm/@web3-storage_multipart-parser@1.0.0/node_modules/@web3-storage/multipart-parser/esm/src/utils.js +35 -0
- package/dist/node_modules/.pnpm/@web3-storage_multipart-parser@1.0.0/node_modules/@web3-storage/multipart-parser/esm/src/utils.mjs +30 -0
- package/dist/observable/index.d.ts +5 -0
- package/dist/observable/index.d.ts.map +1 -0
- package/dist/observable/index.js +13 -0
- package/dist/observable/index.mjs +2 -0
- package/dist/observable/observable.d.ts +13 -0
- package/dist/observable/observable.d.ts.map +1 -0
- package/dist/observable/observable.js +126 -0
- package/dist/observable/observable.mjs +122 -0
- package/dist/observable/operators.d.ts +8 -0
- package/dist/observable/operators.d.ts.map +1 -0
- package/dist/observable/operators.js +103 -0
- package/dist/observable/operators.mjs +99 -0
- package/dist/observable/types.d.ts +26 -0
- package/dist/observable/types.d.ts.map +1 -0
- package/dist/rpc.d.ts +1 -2
- package/dist/rpc.d.ts.map +1 -1
- package/dist/rpc.js +6 -15
- package/dist/rpc.mjs +3 -1
- package/dist/shared.d.ts +1 -1
- package/dist/shared.d.ts.map +1 -1
- package/dist/shared.js +6 -11
- package/dist/shared.mjs +4 -1
- package/dist/unstable-core-do-not-import/TRPCInferrable.d.ts +6 -0
- package/dist/unstable-core-do-not-import/TRPCInferrable.d.ts.map +1 -0
- package/dist/unstable-core-do-not-import/createProxy.d.ts +19 -0
- package/dist/unstable-core-do-not-import/createProxy.d.ts.map +1 -0
- package/dist/unstable-core-do-not-import/createProxy.js +52 -0
- package/dist/unstable-core-do-not-import/createProxy.mjs +49 -0
- package/dist/unstable-core-do-not-import/error/TRPCError.d.ts +13 -0
- package/dist/unstable-core-do-not-import/error/TRPCError.d.ts.map +1 -0
- package/dist/unstable-core-do-not-import/error/TRPCError.js +67 -0
- package/dist/unstable-core-do-not-import/error/TRPCError.mjs +63 -0
- package/dist/unstable-core-do-not-import/error/formatter.d.ts +33 -0
- package/dist/unstable-core-do-not-import/error/formatter.d.ts.map +1 -0
- package/dist/unstable-core-do-not-import/error/formatter.js +7 -0
- package/dist/unstable-core-do-not-import/error/formatter.mjs +5 -0
- package/dist/unstable-core-do-not-import/error/getErrorShape.d.ts +15 -0
- package/dist/unstable-core-do-not-import/error/getErrorShape.d.ts.map +1 -0
- package/dist/unstable-core-do-not-import/error/getErrorShape.js +31 -0
- package/dist/unstable-core-do-not-import/error/getErrorShape.mjs +29 -0
- package/dist/unstable-core-do-not-import/http/batchStreamFormatter.d.ts +24 -0
- package/dist/unstable-core-do-not-import/http/batchStreamFormatter.d.ts.map +1 -0
- package/dist/unstable-core-do-not-import/http/batchStreamFormatter.js +32 -0
- package/dist/unstable-core-do-not-import/http/batchStreamFormatter.mjs +30 -0
- package/dist/unstable-core-do-not-import/http/contentType.d.ts +29 -0
- package/dist/unstable-core-do-not-import/http/contentType.d.ts.map +1 -0
- package/dist/unstable-core-do-not-import/http/contentType.js +54 -0
- package/dist/unstable-core-do-not-import/http/contentType.mjs +52 -0
- package/dist/unstable-core-do-not-import/http/getHTTPStatusCode.d.ts +5 -0
- package/dist/unstable-core-do-not-import/http/getHTTPStatusCode.d.ts.map +1 -0
- package/dist/unstable-core-do-not-import/http/getHTTPStatusCode.js +51 -0
- package/dist/unstable-core-do-not-import/http/getHTTPStatusCode.mjs +48 -0
- package/dist/unstable-core-do-not-import/http/index.d.ts +7 -0
- package/dist/unstable-core-do-not-import/http/index.d.ts.map +1 -0
- package/dist/unstable-core-do-not-import/http/resolveHTTPResponse.d.ts +51 -0
- package/dist/unstable-core-do-not-import/http/resolveHTTPResponse.d.ts.map +1 -0
- package/dist/unstable-core-do-not-import/http/resolveHTTPResponse.js +295 -0
- package/dist/unstable-core-do-not-import/http/resolveHTTPResponse.mjs +293 -0
- package/dist/unstable-core-do-not-import/http/types.d.ts +96 -0
- package/dist/unstable-core-do-not-import/http/types.d.ts.map +1 -0
- package/dist/unstable-core-do-not-import/index.d.ts +37 -0
- package/dist/unstable-core-do-not-import/index.d.ts.map +1 -0
- package/dist/unstable-core-do-not-import/index.js +48 -0
- package/dist/unstable-core-do-not-import/index.mjs +16 -0
- package/dist/unstable-core-do-not-import/initTRPC.d.ts +96 -0
- package/dist/unstable-core-do-not-import/initTRPC.d.ts.map +1 -0
- package/dist/unstable-core-do-not-import/initTRPC.js +95 -0
- package/dist/unstable-core-do-not-import/initTRPC.mjs +93 -0
- package/dist/unstable-core-do-not-import/middleware.d.ts +105 -0
- package/dist/unstable-core-do-not-import/middleware.d.ts.map +1 -0
- package/dist/unstable-core-do-not-import/middleware.js +95 -0
- package/dist/unstable-core-do-not-import/middleware.mjs +89 -0
- package/dist/unstable-core-do-not-import/parser.d.ts +30 -0
- package/dist/unstable-core-do-not-import/parser.d.ts.map +1 -0
- package/dist/unstable-core-do-not-import/parser.js +37 -0
- package/dist/unstable-core-do-not-import/parser.mjs +35 -0
- package/dist/unstable-core-do-not-import/procedure.d.ts +72 -0
- package/dist/unstable-core-do-not-import/procedure.d.ts.map +1 -0
- package/dist/unstable-core-do-not-import/procedure.js +9 -0
- package/dist/unstable-core-do-not-import/procedure.mjs +7 -0
- package/dist/unstable-core-do-not-import/procedureBuilder.d.ts +101 -0
- package/dist/unstable-core-do-not-import/procedureBuilder.d.ts.map +1 -0
- package/dist/unstable-core-do-not-import/procedureBuilder.js +176 -0
- package/dist/unstable-core-do-not-import/procedureBuilder.mjs +173 -0
- package/dist/unstable-core-do-not-import/rootConfig.d.ts +75 -0
- package/dist/unstable-core-do-not-import/rootConfig.d.ts.map +1 -0
- package/dist/unstable-core-do-not-import/rootConfig.js +8 -0
- package/dist/unstable-core-do-not-import/rootConfig.mjs +6 -0
- package/dist/unstable-core-do-not-import/router.d.ts +85 -0
- package/dist/unstable-core-do-not-import/router.d.ts.map +1 -0
- package/dist/unstable-core-do-not-import/router.js +156 -0
- package/dist/unstable-core-do-not-import/router.mjs +151 -0
- package/dist/unstable-core-do-not-import/rpc/codes.d.ts +51 -0
- package/dist/unstable-core-do-not-import/rpc/codes.d.ts.map +1 -0
- package/dist/unstable-core-do-not-import/rpc/codes.js +38 -0
- package/dist/unstable-core-do-not-import/rpc/codes.mjs +35 -0
- package/dist/unstable-core-do-not-import/rpc/envelopes.d.ts +97 -0
- package/dist/unstable-core-do-not-import/rpc/envelopes.d.ts.map +1 -0
- package/dist/unstable-core-do-not-import/rpc/index.d.ts +5 -0
- package/dist/unstable-core-do-not-import/rpc/index.d.ts.map +1 -0
- package/dist/unstable-core-do-not-import/rpc/parseTRPCMessage.d.ts +5 -0
- package/dist/unstable-core-do-not-import/rpc/parseTRPCMessage.d.ts.map +1 -0
- package/dist/unstable-core-do-not-import/rpc/parseTRPCMessage.js +59 -0
- package/dist/unstable-core-do-not-import/rpc/parseTRPCMessage.mjs +57 -0
- package/dist/unstable-core-do-not-import/serialize.d.ts +62 -0
- package/dist/unstable-core-do-not-import/serialize.d.ts.map +1 -0
- package/dist/unstable-core-do-not-import/transformer.d.ts +107 -0
- package/dist/unstable-core-do-not-import/transformer.d.ts.map +1 -0
- package/dist/unstable-core-do-not-import/transformer.js +107 -0
- package/dist/unstable-core-do-not-import/transformer.mjs +102 -0
- package/dist/unstable-core-do-not-import/types.d.ts +98 -0
- package/dist/unstable-core-do-not-import/types.d.ts.map +1 -0
- package/dist/unstable-core-do-not-import/utils.d.ts +27 -0
- package/dist/unstable-core-do-not-import/utils.d.ts.map +1 -0
- package/dist/unstable-core-do-not-import/utils.js +44 -0
- package/dist/unstable-core-do-not-import/utils.mjs +39 -0
- package/package.json +54 -126
- package/src/@trpc/server/http.ts +26 -0
- package/src/@trpc/server/index.ts +105 -0
- package/src/@trpc/server/rpc.ts +26 -0
- package/src/adapters/aws-lambda/index.ts +4 -5
- package/src/adapters/aws-lambda/utils.ts +3 -4
- package/src/adapters/express.ts +1 -3
- package/src/adapters/fastify/fastifyRequestHandler.ts +6 -4
- package/src/adapters/fastify/fastifyTRPCPlugin.ts +1 -2
- package/src/adapters/fetch/fetchRequestHandler.ts +6 -4
- package/src/adapters/fetch/types.ts +2 -3
- package/src/adapters/next.ts +2 -3
- package/src/adapters/node-http/content-type/form-data/index.ts +1 -1
- package/src/adapters/node-http/content-type/json/getPostBody.ts +2 -2
- package/src/adapters/node-http/content-type/json/index.ts +1 -1
- package/src/adapters/node-http/internals/contentType.ts +2 -2
- package/src/adapters/node-http/nodeHTTPRequestHandler.ts +6 -4
- package/src/adapters/node-http/types.ts +4 -5
- package/src/adapters/standalone.ts +3 -3
- package/src/adapters/ws.ts +14 -13
- package/src/http.ts +1 -26
- package/src/index.ts +1 -105
- package/src/observable/index.ts +10 -0
- package/src/observable/observable.ts +158 -0
- package/src/observable/operators.ts +119 -0
- package/src/observable/types.ts +76 -0
- package/src/rpc.ts +1 -26
- package/src/shared.ts +1 -1
- package/src/unstable-core-do-not-import/TRPCInferrable.ts +9 -0
- package/src/unstable-core-do-not-import/createProxy.ts +59 -0
- package/src/unstable-core-do-not-import/error/TRPCError.ts +82 -0
- package/src/unstable-core-do-not-import/error/formatter.ts +51 -0
- package/src/unstable-core-do-not-import/error/getErrorShape.ts +36 -0
- package/src/unstable-core-do-not-import/http/batchStreamFormatter.ts +29 -0
- package/src/unstable-core-do-not-import/http/contentType.ts +99 -0
- package/src/unstable-core-do-not-import/http/getHTTPStatusCode.ts +57 -0
- package/src/unstable-core-do-not-import/http/index.ts +23 -0
- package/src/unstable-core-do-not-import/http/resolveHTTPResponse.ts +458 -0
- package/src/unstable-core-do-not-import/http/types.ts +111 -0
- package/src/unstable-core-do-not-import/index.ts +110 -0
- package/src/unstable-core-do-not-import/initTRPC.ts +206 -0
- package/src/unstable-core-do-not-import/middleware.ts +233 -0
- package/src/unstable-core-do-not-import/parser.ts +94 -0
- package/src/unstable-core-do-not-import/procedure.ts +108 -0
- package/src/unstable-core-do-not-import/procedureBuilder.ts +458 -0
- package/src/unstable-core-do-not-import/rootConfig.ts +90 -0
- package/src/unstable-core-do-not-import/router.ts +370 -0
- package/src/unstable-core-do-not-import/rpc/codes.ts +44 -0
- package/src/unstable-core-do-not-import/rpc/envelopes.ts +136 -0
- package/src/unstable-core-do-not-import/rpc/index.ts +21 -0
- package/src/unstable-core-do-not-import/rpc/parseTRPCMessage.ts +85 -0
- package/src/unstable-core-do-not-import/serialize.ts +122 -0
- package/src/unstable-core-do-not-import/transformer.ts +202 -0
- package/src/unstable-core-do-not-import/types.ts +151 -0
- package/src/unstable-core-do-not-import/utils.ts +59 -0
- package/unstable-core-do-not-import/index.d.ts +1 -0
- package/unstable-core-do-not-import/index.js +1 -0
- package/dist/@trpc-core-unstable-do-not-import-this-please.d.ts +0 -10
- package/dist/@trpc-core-unstable-do-not-import-this-please.d.ts.map +0 -1
- package/dist/@trpc-server/http.d.ts +0 -2
- package/dist/@trpc-server/http.d.ts.map +0 -1
- package/dist/contentType-24c44bba.js +0 -5
- package/dist/nodeHTTPRequestHandler-7691fc79.js +0 -105
- package/dist/observable.d.ts +0 -3
- package/dist/observable.d.ts.map +0 -1
- package/dist/observable.js +0 -32
- package/dist/observable.mjs +0 -1
- package/src/@trpc-core-unstable-do-not-import-this-please.ts +0 -146
- package/src/@trpc-server/http.ts +0 -2
- package/src/observable.ts +0 -16
- /package/dist/{contentType-d9d22104.js → adapters/node-http/internals/contentType.js} +0 -0
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
require('../../unstable-core-do-not-import/rpc/codes.js');
|
|
4
|
+
require('../../unstable-core-do-not-import/rootConfig.js');
|
|
5
|
+
var resolveHTTPResponse = require('../../unstable-core-do-not-import/http/resolveHTTPResponse.js');
|
|
6
|
+
var batchStreamFormatter = require('../../unstable-core-do-not-import/http/batchStreamFormatter.js');
|
|
7
|
+
|
|
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
|
+
const trimSlashes = (path)=>{
|
|
18
|
+
path = path.startsWith('/') ? path.slice(1) : path;
|
|
19
|
+
path = path.endsWith('/') ? path.slice(0, -1) : path;
|
|
20
|
+
return path;
|
|
21
|
+
};
|
|
22
|
+
async function fetchRequestHandler(opts) {
|
|
23
|
+
const resHeaders = new Headers();
|
|
24
|
+
const createContext = async (innerOpts)=>{
|
|
25
|
+
return opts.createContext?.({
|
|
26
|
+
req: opts.req,
|
|
27
|
+
resHeaders,
|
|
28
|
+
...innerOpts
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
const url = new URL(opts.req.url);
|
|
32
|
+
const pathname = trimSlashes(url.pathname);
|
|
33
|
+
const endpoint = trimSlashes(opts.endpoint);
|
|
34
|
+
const path = trimSlashes(pathname.slice(endpoint.length));
|
|
35
|
+
const req = {
|
|
36
|
+
query: url.searchParams,
|
|
37
|
+
method: opts.req.method,
|
|
38
|
+
headers: Object.fromEntries(opts.req.headers),
|
|
39
|
+
body: opts.req.headers.get('content-type')?.startsWith('application/json') ? await opts.req.text() : ''
|
|
40
|
+
};
|
|
41
|
+
let resolve;
|
|
42
|
+
const promise = new Promise((r)=>resolve = r);
|
|
43
|
+
let status = 200;
|
|
44
|
+
let isStream = false;
|
|
45
|
+
let controller;
|
|
46
|
+
let encoder;
|
|
47
|
+
let formatter;
|
|
48
|
+
const unstable_onHead = (head, isStreaming)=>{
|
|
49
|
+
for (const [key, value] of Object.entries(head.headers ?? {})){
|
|
50
|
+
/* istanbul ignore if -- @preserve */ if (typeof value === 'undefined') {
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
if (typeof value === 'string') {
|
|
54
|
+
resHeaders.set(key, value);
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
57
|
+
for (const v of value){
|
|
58
|
+
resHeaders.append(key, v);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
status = head.status;
|
|
62
|
+
if (isStreaming) {
|
|
63
|
+
resHeaders.set('Transfer-Encoding', 'chunked');
|
|
64
|
+
resHeaders.append('Vary', 'trpc-batch-mode');
|
|
65
|
+
const stream = new ReadableStream({
|
|
66
|
+
start (c) {
|
|
67
|
+
controller = c;
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
const response = new Response(stream, {
|
|
71
|
+
status,
|
|
72
|
+
headers: resHeaders
|
|
73
|
+
});
|
|
74
|
+
resolve(response);
|
|
75
|
+
encoder = new TextEncoder();
|
|
76
|
+
formatter = batchStreamFormatter.getBatchStreamFormatter();
|
|
77
|
+
isStream = true;
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
const unstable_onChunk = ([index, string])=>{
|
|
81
|
+
if (index === -1) {
|
|
82
|
+
// full response, no streaming
|
|
83
|
+
const response = new Response(string || null, {
|
|
84
|
+
status,
|
|
85
|
+
headers: resHeaders
|
|
86
|
+
});
|
|
87
|
+
resolve(response);
|
|
88
|
+
} else {
|
|
89
|
+
controller.enqueue(encoder.encode(formatter(index, string)));
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
resolveHTTPResponse.resolveHTTPResponse({
|
|
93
|
+
req,
|
|
94
|
+
createContext,
|
|
95
|
+
path,
|
|
96
|
+
router: opts.router,
|
|
97
|
+
batching: opts.batching,
|
|
98
|
+
responseMeta: opts.responseMeta,
|
|
99
|
+
onError (o) {
|
|
100
|
+
opts?.onError?.({
|
|
101
|
+
...o,
|
|
102
|
+
req: opts.req
|
|
103
|
+
});
|
|
104
|
+
},
|
|
105
|
+
unstable_onHead,
|
|
106
|
+
unstable_onChunk
|
|
107
|
+
}).then(()=>{
|
|
108
|
+
if (isStream) {
|
|
109
|
+
controller.enqueue(encoder.encode(formatter.end()));
|
|
110
|
+
controller.close();
|
|
111
|
+
}
|
|
112
|
+
}).catch(()=>{
|
|
113
|
+
if (isStream) {
|
|
114
|
+
controller.close();
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
return promise;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
exports.fetchRequestHandler = fetchRequestHandler;
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import '../../unstable-core-do-not-import/rpc/codes.mjs';
|
|
2
|
+
import '../../unstable-core-do-not-import/rootConfig.mjs';
|
|
3
|
+
import { resolveHTTPResponse } from '../../unstable-core-do-not-import/http/resolveHTTPResponse.mjs';
|
|
4
|
+
import { getBatchStreamFormatter } from '../../unstable-core-do-not-import/http/batchStreamFormatter.mjs';
|
|
5
|
+
|
|
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
|
+
const trimSlashes = (path)=>{
|
|
16
|
+
path = path.startsWith('/') ? path.slice(1) : path;
|
|
17
|
+
path = path.endsWith('/') ? path.slice(0, -1) : path;
|
|
18
|
+
return path;
|
|
19
|
+
};
|
|
20
|
+
async function fetchRequestHandler(opts) {
|
|
21
|
+
const resHeaders = new Headers();
|
|
22
|
+
const createContext = async (innerOpts)=>{
|
|
23
|
+
return opts.createContext?.({
|
|
24
|
+
req: opts.req,
|
|
25
|
+
resHeaders,
|
|
26
|
+
...innerOpts
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
const url = new URL(opts.req.url);
|
|
30
|
+
const pathname = trimSlashes(url.pathname);
|
|
31
|
+
const endpoint = trimSlashes(opts.endpoint);
|
|
32
|
+
const path = trimSlashes(pathname.slice(endpoint.length));
|
|
33
|
+
const req = {
|
|
34
|
+
query: url.searchParams,
|
|
35
|
+
method: opts.req.method,
|
|
36
|
+
headers: Object.fromEntries(opts.req.headers),
|
|
37
|
+
body: opts.req.headers.get('content-type')?.startsWith('application/json') ? await opts.req.text() : ''
|
|
38
|
+
};
|
|
39
|
+
let resolve;
|
|
40
|
+
const promise = new Promise((r)=>resolve = r);
|
|
41
|
+
let status = 200;
|
|
42
|
+
let isStream = false;
|
|
43
|
+
let controller;
|
|
44
|
+
let encoder;
|
|
45
|
+
let formatter;
|
|
46
|
+
const unstable_onHead = (head, isStreaming)=>{
|
|
47
|
+
for (const [key, value] of Object.entries(head.headers ?? {})){
|
|
48
|
+
/* istanbul ignore if -- @preserve */ if (typeof value === 'undefined') {
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
if (typeof value === 'string') {
|
|
52
|
+
resHeaders.set(key, value);
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
for (const v of value){
|
|
56
|
+
resHeaders.append(key, v);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
status = head.status;
|
|
60
|
+
if (isStreaming) {
|
|
61
|
+
resHeaders.set('Transfer-Encoding', 'chunked');
|
|
62
|
+
resHeaders.append('Vary', 'trpc-batch-mode');
|
|
63
|
+
const stream = new ReadableStream({
|
|
64
|
+
start (c) {
|
|
65
|
+
controller = c;
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
const response = new Response(stream, {
|
|
69
|
+
status,
|
|
70
|
+
headers: resHeaders
|
|
71
|
+
});
|
|
72
|
+
resolve(response);
|
|
73
|
+
encoder = new TextEncoder();
|
|
74
|
+
formatter = getBatchStreamFormatter();
|
|
75
|
+
isStream = true;
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
const unstable_onChunk = ([index, string])=>{
|
|
79
|
+
if (index === -1) {
|
|
80
|
+
// full response, no streaming
|
|
81
|
+
const response = new Response(string || null, {
|
|
82
|
+
status,
|
|
83
|
+
headers: resHeaders
|
|
84
|
+
});
|
|
85
|
+
resolve(response);
|
|
86
|
+
} else {
|
|
87
|
+
controller.enqueue(encoder.encode(formatter(index, string)));
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
resolveHTTPResponse({
|
|
91
|
+
req,
|
|
92
|
+
createContext,
|
|
93
|
+
path,
|
|
94
|
+
router: opts.router,
|
|
95
|
+
batching: opts.batching,
|
|
96
|
+
responseMeta: opts.responseMeta,
|
|
97
|
+
onError (o) {
|
|
98
|
+
opts?.onError?.({
|
|
99
|
+
...o,
|
|
100
|
+
req: opts.req
|
|
101
|
+
});
|
|
102
|
+
},
|
|
103
|
+
unstable_onHead,
|
|
104
|
+
unstable_onChunk
|
|
105
|
+
}).then(()=>{
|
|
106
|
+
if (isStream) {
|
|
107
|
+
controller.enqueue(encoder.encode(formatter.end()));
|
|
108
|
+
controller.close();
|
|
109
|
+
}
|
|
110
|
+
}).catch(()=>{
|
|
111
|
+
if (isStream) {
|
|
112
|
+
controller.close();
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
return promise;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export { fetchRequestHandler };
|
|
@@ -1,120 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
var fetchRequestHandler = require('./fetchRequestHandler.js');
|
|
4
4
|
|
|
5
|
-
var core = require('@trpc/core');
|
|
6
5
|
|
|
7
|
-
/**
|
|
8
|
-
* 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`
|
|
9
|
-
*
|
|
10
|
-
* Do **not** import from `@trpc/core`
|
|
11
|
-
* @example
|
|
12
|
-
* ```ts
|
|
13
|
-
* import type { AnyTRPCRouter } from '@trpc/server'
|
|
14
|
-
* import type { HTTPBaseHandlerOptions } from '@trpc/server/http'
|
|
15
|
-
* ```
|
|
16
|
-
*/ // @trpc/server
|
|
17
|
-
const trimSlashes = (path)=>{
|
|
18
|
-
path = path.startsWith('/') ? path.slice(1) : path;
|
|
19
|
-
path = path.endsWith('/') ? path.slice(0, -1) : path;
|
|
20
|
-
return path;
|
|
21
|
-
};
|
|
22
|
-
async function fetchRequestHandler(opts) {
|
|
23
|
-
const resHeaders = new Headers();
|
|
24
|
-
const createContext = async (innerOpts)=>{
|
|
25
|
-
return opts.createContext?.({
|
|
26
|
-
req: opts.req,
|
|
27
|
-
resHeaders,
|
|
28
|
-
...innerOpts
|
|
29
|
-
});
|
|
30
|
-
};
|
|
31
|
-
const url = new URL(opts.req.url);
|
|
32
|
-
const pathname = trimSlashes(url.pathname);
|
|
33
|
-
const endpoint = trimSlashes(opts.endpoint);
|
|
34
|
-
const path = trimSlashes(pathname.slice(endpoint.length));
|
|
35
|
-
const req = {
|
|
36
|
-
query: url.searchParams,
|
|
37
|
-
method: opts.req.method,
|
|
38
|
-
headers: Object.fromEntries(opts.req.headers),
|
|
39
|
-
body: opts.req.headers.get('content-type')?.startsWith('application/json') ? await opts.req.text() : ''
|
|
40
|
-
};
|
|
41
|
-
let resolve;
|
|
42
|
-
const promise = new Promise((r)=>resolve = r);
|
|
43
|
-
let status = 200;
|
|
44
|
-
let isStream = false;
|
|
45
|
-
let controller;
|
|
46
|
-
let encoder;
|
|
47
|
-
let formatter;
|
|
48
|
-
const unstable_onHead = (head, isStreaming)=>{
|
|
49
|
-
for (const [key, value] of Object.entries(head.headers ?? {})){
|
|
50
|
-
/* istanbul ignore if -- @preserve */ if (typeof value === 'undefined') {
|
|
51
|
-
continue;
|
|
52
|
-
}
|
|
53
|
-
if (typeof value === 'string') {
|
|
54
|
-
resHeaders.set(key, value);
|
|
55
|
-
continue;
|
|
56
|
-
}
|
|
57
|
-
for (const v of value){
|
|
58
|
-
resHeaders.append(key, v);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
status = head.status;
|
|
62
|
-
if (isStreaming) {
|
|
63
|
-
resHeaders.set('Transfer-Encoding', 'chunked');
|
|
64
|
-
resHeaders.append('Vary', 'trpc-batch-mode');
|
|
65
|
-
const stream = new ReadableStream({
|
|
66
|
-
start (c) {
|
|
67
|
-
controller = c;
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
|
-
const response = new Response(stream, {
|
|
71
|
-
status,
|
|
72
|
-
headers: resHeaders
|
|
73
|
-
});
|
|
74
|
-
resolve(response);
|
|
75
|
-
encoder = new TextEncoder();
|
|
76
|
-
formatter = core.getBatchStreamFormatter();
|
|
77
|
-
isStream = true;
|
|
78
|
-
}
|
|
79
|
-
};
|
|
80
|
-
const unstable_onChunk = ([index, string])=>{
|
|
81
|
-
if (index === -1) {
|
|
82
|
-
// full response, no streaming
|
|
83
|
-
const response = new Response(string || null, {
|
|
84
|
-
status,
|
|
85
|
-
headers: resHeaders
|
|
86
|
-
});
|
|
87
|
-
resolve(response);
|
|
88
|
-
} else {
|
|
89
|
-
controller.enqueue(encoder.encode(formatter(index, string)));
|
|
90
|
-
}
|
|
91
|
-
};
|
|
92
|
-
core.resolveHTTPResponse({
|
|
93
|
-
req,
|
|
94
|
-
createContext,
|
|
95
|
-
path,
|
|
96
|
-
router: opts.router,
|
|
97
|
-
batching: opts.batching,
|
|
98
|
-
responseMeta: opts.responseMeta,
|
|
99
|
-
onError (o) {
|
|
100
|
-
opts?.onError?.({
|
|
101
|
-
...o,
|
|
102
|
-
req: opts.req
|
|
103
|
-
});
|
|
104
|
-
},
|
|
105
|
-
unstable_onHead,
|
|
106
|
-
unstable_onChunk
|
|
107
|
-
}).then(()=>{
|
|
108
|
-
if (isStream) {
|
|
109
|
-
controller.enqueue(encoder.encode(formatter.end()));
|
|
110
|
-
controller.close();
|
|
111
|
-
}
|
|
112
|
-
}).catch(()=>{
|
|
113
|
-
if (isStream) {
|
|
114
|
-
controller.close();
|
|
115
|
-
}
|
|
116
|
-
});
|
|
117
|
-
return promise;
|
|
118
|
-
}
|
|
119
6
|
|
|
120
|
-
exports.fetchRequestHandler = fetchRequestHandler;
|
|
7
|
+
exports.fetchRequestHandler = fetchRequestHandler.fetchRequestHandler;
|
|
@@ -1,116 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* 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`
|
|
5
|
-
*
|
|
6
|
-
* Do **not** import from `@trpc/core`
|
|
7
|
-
* @example
|
|
8
|
-
* ```ts
|
|
9
|
-
* import type { AnyTRPCRouter } from '@trpc/server'
|
|
10
|
-
* import type { HTTPBaseHandlerOptions } from '@trpc/server/http'
|
|
11
|
-
* ```
|
|
12
|
-
*/ // @trpc/server
|
|
13
|
-
const trimSlashes = (path)=>{
|
|
14
|
-
path = path.startsWith('/') ? path.slice(1) : path;
|
|
15
|
-
path = path.endsWith('/') ? path.slice(0, -1) : path;
|
|
16
|
-
return path;
|
|
17
|
-
};
|
|
18
|
-
async function fetchRequestHandler(opts) {
|
|
19
|
-
const resHeaders = new Headers();
|
|
20
|
-
const createContext = async (innerOpts)=>{
|
|
21
|
-
return opts.createContext?.({
|
|
22
|
-
req: opts.req,
|
|
23
|
-
resHeaders,
|
|
24
|
-
...innerOpts
|
|
25
|
-
});
|
|
26
|
-
};
|
|
27
|
-
const url = new URL(opts.req.url);
|
|
28
|
-
const pathname = trimSlashes(url.pathname);
|
|
29
|
-
const endpoint = trimSlashes(opts.endpoint);
|
|
30
|
-
const path = trimSlashes(pathname.slice(endpoint.length));
|
|
31
|
-
const req = {
|
|
32
|
-
query: url.searchParams,
|
|
33
|
-
method: opts.req.method,
|
|
34
|
-
headers: Object.fromEntries(opts.req.headers),
|
|
35
|
-
body: opts.req.headers.get('content-type')?.startsWith('application/json') ? await opts.req.text() : ''
|
|
36
|
-
};
|
|
37
|
-
let resolve;
|
|
38
|
-
const promise = new Promise((r)=>resolve = r);
|
|
39
|
-
let status = 200;
|
|
40
|
-
let isStream = false;
|
|
41
|
-
let controller;
|
|
42
|
-
let encoder;
|
|
43
|
-
let formatter;
|
|
44
|
-
const unstable_onHead = (head, isStreaming)=>{
|
|
45
|
-
for (const [key, value] of Object.entries(head.headers ?? {})){
|
|
46
|
-
/* istanbul ignore if -- @preserve */ if (typeof value === 'undefined') {
|
|
47
|
-
continue;
|
|
48
|
-
}
|
|
49
|
-
if (typeof value === 'string') {
|
|
50
|
-
resHeaders.set(key, value);
|
|
51
|
-
continue;
|
|
52
|
-
}
|
|
53
|
-
for (const v of value){
|
|
54
|
-
resHeaders.append(key, v);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
status = head.status;
|
|
58
|
-
if (isStreaming) {
|
|
59
|
-
resHeaders.set('Transfer-Encoding', 'chunked');
|
|
60
|
-
resHeaders.append('Vary', 'trpc-batch-mode');
|
|
61
|
-
const stream = new ReadableStream({
|
|
62
|
-
start (c) {
|
|
63
|
-
controller = c;
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
const response = new Response(stream, {
|
|
67
|
-
status,
|
|
68
|
-
headers: resHeaders
|
|
69
|
-
});
|
|
70
|
-
resolve(response);
|
|
71
|
-
encoder = new TextEncoder();
|
|
72
|
-
formatter = getBatchStreamFormatter();
|
|
73
|
-
isStream = true;
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
|
-
const unstable_onChunk = ([index, string])=>{
|
|
77
|
-
if (index === -1) {
|
|
78
|
-
// full response, no streaming
|
|
79
|
-
const response = new Response(string || null, {
|
|
80
|
-
status,
|
|
81
|
-
headers: resHeaders
|
|
82
|
-
});
|
|
83
|
-
resolve(response);
|
|
84
|
-
} else {
|
|
85
|
-
controller.enqueue(encoder.encode(formatter(index, string)));
|
|
86
|
-
}
|
|
87
|
-
};
|
|
88
|
-
resolveHTTPResponse({
|
|
89
|
-
req,
|
|
90
|
-
createContext,
|
|
91
|
-
path,
|
|
92
|
-
router: opts.router,
|
|
93
|
-
batching: opts.batching,
|
|
94
|
-
responseMeta: opts.responseMeta,
|
|
95
|
-
onError (o) {
|
|
96
|
-
opts?.onError?.({
|
|
97
|
-
...o,
|
|
98
|
-
req: opts.req
|
|
99
|
-
});
|
|
100
|
-
},
|
|
101
|
-
unstable_onHead,
|
|
102
|
-
unstable_onChunk
|
|
103
|
-
}).then(()=>{
|
|
104
|
-
if (isStream) {
|
|
105
|
-
controller.enqueue(encoder.encode(formatter.end()));
|
|
106
|
-
controller.close();
|
|
107
|
-
}
|
|
108
|
-
}).catch(()=>{
|
|
109
|
-
if (isStream) {
|
|
110
|
-
controller.close();
|
|
111
|
-
}
|
|
112
|
-
});
|
|
113
|
-
return promise;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
export { fetchRequestHandler };
|
|
1
|
+
export { fetchRequestHandler } from './fetchRequestHandler.mjs';
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
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
3
|
*
|
|
4
|
-
* Do **not** import from `@trpc/core`
|
|
5
4
|
* @example
|
|
6
5
|
* ```ts
|
|
7
6
|
* import type { AnyTRPCRouter } from '@trpc/server'
|
|
8
7
|
* import type { HTTPBaseHandlerOptions } from '@trpc/server/http'
|
|
9
8
|
* ```
|
|
10
9
|
*/
|
|
11
|
-
import type { AnyRouter, inferRouterContext } from '
|
|
12
|
-
import type { HTTPBaseHandlerOptions, TRPCRequestInfo } from '../../@trpc
|
|
10
|
+
import type { AnyRouter, inferRouterContext } from '../../@trpc/server';
|
|
11
|
+
import type { HTTPBaseHandlerOptions, TRPCRequestInfo } from '../../@trpc/server/http';
|
|
13
12
|
export type FetchCreateContextFnOptions = {
|
|
14
13
|
req: Request;
|
|
15
14
|
resHeaders: Headers;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/adapters/fetch/types.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/adapters/fetch/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAExE,OAAO,KAAK,EACV,sBAAsB,EACtB,eAAe,EAChB,MAAM,yBAAyB,CAAC;AAEjC,MAAM,MAAM,2BAA2B,GAAG;IACxC,GAAG,EAAE,OAAO,CAAC;IACb,UAAU,EAAE,OAAO,CAAC;IACpB,IAAI,EAAE,eAAe,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,oBAAoB,CAAC,OAAO,SAAS,SAAS,IAAI,CAC5D,IAAI,EAAE,2BAA2B,KAC9B,kBAAkB,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC,CAAC;AAExE,MAAM,MAAM,wBAAwB,CAAC,OAAO,SAAS,SAAS,IAC5D,OAAO,SAAS,kBAAkB,CAAC,OAAO,CAAC,GACvC;IACE;;QAEI;IACJ,aAAa,CAAC,EAAE,oBAAoB,CAAC,OAAO,CAAC,CAAC;CAC/C,GACD;IACE;;QAEI;IACJ,aAAa,EAAE,oBAAoB,CAAC,OAAO,CAAC,CAAC;CAC9C,CAAC;AAER,MAAM,MAAM,mBAAmB,CAAC,OAAO,SAAS,SAAS,IACvD,wBAAwB,CAAC,OAAO,CAAC,GAAG,sBAAsB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC"}
|
package/dist/adapters/next.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
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
3
|
*
|
|
4
|
-
* Do **not** import from `@trpc/core`
|
|
5
4
|
* @example
|
|
6
5
|
* ```ts
|
|
7
6
|
* import type { AnyTRPCRouter } from '@trpc/server'
|
|
@@ -9,7 +8,7 @@
|
|
|
9
8
|
* ```
|
|
10
9
|
*/
|
|
11
10
|
import type { NextApiHandler, NextApiRequest, NextApiResponse } from 'next';
|
|
12
|
-
import type { AnyRouter } from '
|
|
11
|
+
import type { AnyRouter } from '../@trpc/server';
|
|
13
12
|
import type { NodeHTTPCreateContextFnOptions, NodeHTTPHandlerOptions } from './node-http';
|
|
14
13
|
export type CreateNextContextOptions = NodeHTTPCreateContextFnOptions<NextApiRequest, NextApiResponse>;
|
|
15
14
|
export type { NextApiHandler, NextApiRequest, NextApiResponse } from 'next';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"next.d.ts","sourceRoot":"","sources":["../../src/adapters/next.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"next.d.ts","sourceRoot":"","sources":["../../src/adapters/next.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,MAAM,CAAC;AAE5E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAGjD,OAAO,KAAK,EACV,8BAA8B,EAC9B,sBAAsB,EACvB,MAAM,aAAa,CAAC;AAGrB,MAAM,MAAM,wBAAwB,GAAG,8BAA8B,CACnE,cAAc,EACd,eAAe,CAChB,CAAC;AACF,YAAY,EAAE,cAAc,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,MAAM,CAAC;AAE5E,wBAAgB,oBAAoB,CAAC,OAAO,SAAS,SAAS,EAC5D,IAAI,EAAE,sBAAsB,CAAC,OAAO,EAAE,cAAc,EAAE,eAAe,CAAC,GACrE,cAAc,CA8ChB"}
|
package/dist/adapters/next.js
CHANGED
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
require('./node-http/
|
|
8
|
-
require('../contentType-d9d22104.js');
|
|
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
|
+
require('../unstable-core-do-not-import/rootConfig.js');
|
|
6
|
+
require('../unstable-core-do-not-import/rpc/codes.js');
|
|
7
|
+
var nodeHTTPRequestHandler = require('./node-http/nodeHTTPRequestHandler.js');
|
|
9
8
|
|
|
10
9
|
/**
|
|
11
10
|
* 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`
|
|
12
11
|
*
|
|
13
|
-
* Do **not** import from `@trpc/core`
|
|
14
12
|
* @example
|
|
15
13
|
* ```ts
|
|
16
14
|
* import type { AnyTRPCRouter } from '@trpc/server'
|
|
@@ -30,9 +28,9 @@ function createNextApiHandler(opts) {
|
|
|
30
28
|
}
|
|
31
29
|
const path = getPath();
|
|
32
30
|
if (path === null) {
|
|
33
|
-
const error =
|
|
31
|
+
const error = getErrorShape.getErrorShape({
|
|
34
32
|
config: opts.router._def._config,
|
|
35
|
-
error: new
|
|
33
|
+
error: new TRPCError.TRPCError({
|
|
36
34
|
message: 'Query "trpc" not found - is the file named `[trpc]`.ts or `[...trpc].ts`?',
|
|
37
35
|
code: 'INTERNAL_SERVER_ERROR'
|
|
38
36
|
}),
|
package/dist/adapters/next.mjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { getErrorShape
|
|
2
|
-
import {
|
|
3
|
-
import '
|
|
4
|
-
import '../
|
|
1
|
+
import { getErrorShape } from '../unstable-core-do-not-import/error/getErrorShape.mjs';
|
|
2
|
+
import { TRPCError } from '../unstable-core-do-not-import/error/TRPCError.mjs';
|
|
3
|
+
import '../unstable-core-do-not-import/rootConfig.mjs';
|
|
4
|
+
import '../unstable-core-do-not-import/rpc/codes.mjs';
|
|
5
|
+
import { nodeHTTPRequestHandler } from './node-http/nodeHTTPRequestHandler.mjs';
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* 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
|
*
|
|
9
|
-
* Do **not** import from `@trpc/core`
|
|
10
10
|
* @example
|
|
11
11
|
* ```ts
|
|
12
12
|
* import type { AnyTRPCRouter } from '@trpc/server'
|