@trpc/server 11.0.0-next-alpha.172 → 11.0.0-next-beta.178
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/{unstableDoNotImportThis.d.ts → @trpc-core-unstable-do-not-import-this-please.d.ts} +1 -1
- package/dist/@trpc-core-unstable-do-not-import-this-please.d.ts.map +1 -0
- package/dist/@trpc-server/http.d.ts +2 -0
- package/dist/@trpc-server/http.d.ts.map +1 -0
- package/dist/@trpc-server.d.ts +37 -0
- package/dist/@trpc-server.d.ts.map +1 -0
- package/dist/adapters/aws-lambda/index.d.ts +11 -1
- package/dist/adapters/aws-lambda/index.d.ts.map +1 -1
- package/dist/adapters/aws-lambda/index.js +20 -0
- package/dist/adapters/aws-lambda/index.mjs +20 -0
- package/dist/adapters/aws-lambda/utils.d.ts +13 -3
- package/dist/adapters/aws-lambda/utils.d.ts.map +1 -1
- package/dist/adapters/express.d.ts +11 -1
- package/dist/adapters/express.d.ts.map +1 -1
- package/dist/adapters/express.js +2 -2
- package/dist/adapters/express.mjs +2 -2
- package/dist/adapters/fastify/fastifyRequestHandler.d.ts +1 -1
- package/dist/adapters/fastify/fastifyRequestHandler.d.ts.map +1 -1
- package/dist/adapters/fastify/fastifyTRPCPlugin.d.ts +11 -1
- package/dist/adapters/fastify/fastifyTRPCPlugin.d.ts.map +1 -1
- package/dist/adapters/fastify/index.js +11 -2
- package/dist/adapters/fastify/index.mjs +11 -2
- package/dist/adapters/fetch/fetchRequestHandler.d.ts +11 -1
- package/dist/adapters/fetch/fetchRequestHandler.d.ts.map +1 -1
- package/dist/adapters/fetch/index.js +10 -0
- package/dist/adapters/fetch/index.mjs +10 -0
- package/dist/adapters/fetch/types.d.ts +14 -4
- package/dist/adapters/fetch/types.d.ts.map +1 -1
- package/dist/adapters/next.d.ts +11 -1
- package/dist/adapters/next.d.ts.map +1 -1
- package/dist/adapters/next.js +12 -2
- package/dist/adapters/next.mjs +12 -2
- package/dist/adapters/node-http/content-type/form-data/index.d.ts +1 -1
- package/dist/adapters/node-http/content-type/form-data/index.d.ts.map +1 -1
- package/dist/adapters/node-http/content-type/form-data/index.js +2 -2
- package/dist/adapters/node-http/content-type/form-data/index.mjs +2 -2
- package/dist/adapters/node-http/content-type/form-data/memoryUploadHandler.d.ts +1 -1
- package/dist/adapters/node-http/content-type/form-data/uploadHandler.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/index.js +2 -1
- package/dist/adapters/node-http/content-type/json/index.mjs +2 -1
- package/dist/adapters/node-http/index.js +2 -2
- package/dist/adapters/node-http/index.mjs +2 -2
- 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/adapters/node-http/nodeHTTPRequestHandler.d.ts +11 -1
- package/dist/adapters/node-http/nodeHTTPRequestHandler.d.ts.map +1 -1
- package/dist/adapters/node-http/types.d.ts +15 -4
- package/dist/adapters/node-http/types.d.ts.map +1 -1
- package/dist/adapters/standalone.d.ts +11 -1
- package/dist/adapters/standalone.d.ts.map +1 -1
- package/dist/adapters/standalone.js +2 -2
- package/dist/adapters/standalone.mjs +2 -2
- package/dist/adapters/ws.d.ts +4 -3
- package/dist/adapters/ws.d.ts.map +1 -1
- package/dist/adapters/ws.js +2 -2
- package/dist/adapters/ws.mjs +2 -2
- package/dist/bundle-analysis.json +80 -80
- package/dist/{contentType-3194ed5f.mjs → contentType-72ed9df5.mjs} +1 -0
- package/dist/{contentType-8c16408e.js → contentType-d9d22104.js} +1 -0
- package/dist/http.d.ts +1 -1
- package/dist/http.d.ts.map +1 -1
- package/dist/index.d.ts +1 -23
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +28 -8
- package/dist/index.mjs +1 -1
- package/dist/{nodeHTTPRequestHandler-36974696.mjs → nodeHTTPRequestHandler-0223fac5.mjs} +10 -0
- package/dist/{nodeHTTPRequestHandler-30028c9a.js → nodeHTTPRequestHandler-83441c73.js} +10 -0
- package/package.json +4 -20
- package/src/@trpc-server/http.ts +2 -0
- package/src/@trpc-server.ts +60 -0
- package/src/adapters/aws-lambda/index.ts +14 -2
- package/src/adapters/aws-lambda/utils.ts +16 -4
- package/src/adapters/express.ts +12 -1
- package/src/adapters/fastify/fastifyRequestHandler.ts +12 -1
- package/src/adapters/fastify/fastifyTRPCPlugin.ts +12 -1
- package/src/adapters/fetch/fetchRequestHandler.ts +12 -1
- package/src/adapters/fetch/types.ts +19 -4
- package/src/adapters/next.ts +14 -2
- package/src/adapters/node-http/content-type/form-data/fileUploadHandler.ts +1 -1
- package/src/adapters/node-http/content-type/form-data/index.ts +4 -3
- package/src/adapters/node-http/content-type/form-data/memoryUploadHandler.ts +1 -1
- package/src/adapters/node-http/content-type/form-data/uploadHandler.ts +1 -1
- package/src/adapters/node-http/content-type/json/getPostBody.ts +2 -1
- package/src/adapters/node-http/internals/contentType.ts +4 -2
- package/src/adapters/node-http/nodeHTTPRequestHandler.ts +12 -1
- package/src/adapters/node-http/types.ts +21 -4
- package/src/adapters/standalone.ts +12 -1
- package/src/adapters/ws.ts +13 -11
- package/src/http.ts +1 -2
- package/src/index.ts +1 -39
- package/dist/unstableDoNotImportThis.d.ts.map +0 -1
- /package/dist/{nodeHTTPRequestHandler-640c1f60.js → nodeHTTPRequestHandler-aa0dce4e.js} +0 -0
- /package/src/{unstableDoNotImportThis.ts → @trpc-core-unstable-do-not-import-this-please.ts} +0 -0
package/dist/index.d.ts
CHANGED
|
@@ -1,24 +1,2 @@
|
|
|
1
|
-
export
|
|
2
|
-
/**
|
|
3
|
-
* @deprecated use `experimental_trpcMiddleware` instead
|
|
4
|
-
*/
|
|
5
|
-
experimental_standaloneMiddleware, experimental_standaloneMiddleware as experimental_trpcMiddleware, initTRPC, type inferProcedureInput, type inferProcedureOutput, type inferRouterError, type inferRouterInputs, type inferRouterOutputs, type AnyProcedure as AnyTRPCProcedure, type AnyRouter as AnyTRPCRouter, type AnyMiddlewareFunction as AnyTRPCMiddlewareFunction, } from './unstableDoNotImportThis';
|
|
6
|
-
export type {
|
|
7
|
-
/**
|
|
8
|
-
* @deprecated use `AnyTRPCProcedure` instead
|
|
9
|
-
*/
|
|
10
|
-
AnyProcedure,
|
|
11
|
-
/**
|
|
12
|
-
* @deprecated use `AnyTRPCRouter` instead
|
|
13
|
-
*/
|
|
14
|
-
AnyRouter,
|
|
15
|
-
/**
|
|
16
|
-
* @deprecated use `AnyTRPCMiddlewareFunction` instead
|
|
17
|
-
*/
|
|
18
|
-
AnyMiddlewareFunction, } from '@trpc/core';
|
|
19
|
-
/**
|
|
20
|
-
* @deprecated
|
|
21
|
-
* Use `Awaited<ReturnType<typeof myFunction>>` instead
|
|
22
|
-
*/
|
|
23
|
-
export type inferAsyncReturnType<TFunction extends (...args: any[]) => any> = Awaited<ReturnType<TFunction>>;
|
|
1
|
+
export * from './@trpc-server';
|
|
24
2
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -7,18 +7,38 @@ var core = require('@trpc/core');
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
Object.defineProperty(exports, 'TRPCError', {
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
enumerable: true,
|
|
11
|
+
get: function () { return core.TRPCError; }
|
|
12
|
+
});
|
|
13
|
+
Object.defineProperty(exports, 'callProcedure', {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
get: function () { return core.callProcedure; }
|
|
16
|
+
});
|
|
17
|
+
Object.defineProperty(exports, 'callTRPCProcedure', {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: function () { return core.callProcedure; }
|
|
12
20
|
});
|
|
13
21
|
Object.defineProperty(exports, 'experimental_standaloneMiddleware', {
|
|
14
|
-
|
|
15
|
-
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function () { return core.experimental_standaloneMiddleware; }
|
|
16
24
|
});
|
|
17
25
|
Object.defineProperty(exports, 'experimental_trpcMiddleware', {
|
|
18
|
-
|
|
19
|
-
|
|
26
|
+
enumerable: true,
|
|
27
|
+
get: function () { return core.experimental_standaloneMiddleware; }
|
|
28
|
+
});
|
|
29
|
+
Object.defineProperty(exports, 'getErrorShape', {
|
|
30
|
+
enumerable: true,
|
|
31
|
+
get: function () { return core.getErrorShape; }
|
|
32
|
+
});
|
|
33
|
+
Object.defineProperty(exports, 'getTRPCErrorFromUnknown', {
|
|
34
|
+
enumerable: true,
|
|
35
|
+
get: function () { return core.getTRPCErrorFromUnknown; }
|
|
20
36
|
});
|
|
21
37
|
Object.defineProperty(exports, 'initTRPC', {
|
|
22
|
-
|
|
23
|
-
|
|
38
|
+
enumerable: true,
|
|
39
|
+
get: function () { return core.initTRPC; }
|
|
40
|
+
});
|
|
41
|
+
Object.defineProperty(exports, 'transformTRPCResponse', {
|
|
42
|
+
enumerable: true,
|
|
43
|
+
get: function () { return core.transformTRPCResponse; }
|
|
24
44
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { TRPCError, experimental_standaloneMiddleware, experimental_standaloneMiddleware as experimental_trpcMiddleware, initTRPC } from '@trpc/core';
|
|
1
|
+
export { TRPCError, callProcedure, callProcedure as callTRPCProcedure, experimental_standaloneMiddleware, experimental_standaloneMiddleware as experimental_trpcMiddleware, getErrorShape, getTRPCErrorFromUnknown, initTRPC, transformTRPCResponse } from '@trpc/core';
|
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
import { resolveHTTPResponse, getBatchStreamFormatter } from '@trpc/core/http';
|
|
2
2
|
import { nodeHTTPJSONContentTypeHandler } from './adapters/node-http/content-type/json/index.mjs';
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* 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`
|
|
6
|
+
*
|
|
7
|
+
* Do **not** import from `@trpc/core`
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* import type { AnyTRPCRouter } from '@trpc/server'
|
|
11
|
+
* import type { HTTPBaseHandlerOptions } from '@trpc/server/http'
|
|
12
|
+
* ```
|
|
13
|
+
*/ /* eslint-disable @typescript-eslint/no-non-null-assertion */ // @trpc/server
|
|
4
14
|
const defaultJSONContentTypeHandler = nodeHTTPJSONContentTypeHandler();
|
|
5
15
|
async function nodeHTTPRequestHandler(opts) {
|
|
6
16
|
const handleViaMiddleware = opts.middleware ?? ((_req, _res, next)=>next());
|
|
@@ -3,6 +3,16 @@
|
|
|
3
3
|
var http = require('@trpc/core/http');
|
|
4
4
|
var adapters_nodeHttp_contentType_json_index = require('./adapters/node-http/content-type/json/index.js');
|
|
5
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
|
+
* Do **not** import from `@trpc/core`
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* import type { AnyTRPCRouter } from '@trpc/server'
|
|
13
|
+
* import type { HTTPBaseHandlerOptions } from '@trpc/server/http'
|
|
14
|
+
* ```
|
|
15
|
+
*/ /* eslint-disable @typescript-eslint/no-non-null-assertion */ // @trpc/server
|
|
6
16
|
const defaultJSONContentTypeHandler = adapters_nodeHttp_contentType_json_index.nodeHTTPJSONContentTypeHandler();
|
|
7
17
|
async function nodeHTTPRequestHandler(opts) {
|
|
8
18
|
const handleViaMiddleware = opts.middleware ?? ((_req, _res, next)=>next());
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trpc/server",
|
|
3
|
-
"version": "11.0.0-next-
|
|
3
|
+
"version": "11.0.0-next-beta.178+f6674ef59",
|
|
4
4
|
"description": "The tRPC server library",
|
|
5
5
|
"author": "KATT",
|
|
6
6
|
"license": "MIT",
|
|
@@ -13,28 +13,12 @@
|
|
|
13
13
|
"url": "git+https://github.com/trpc/trpc.git",
|
|
14
14
|
"directory": "packages/server"
|
|
15
15
|
},
|
|
16
|
-
"eslintConfig": {
|
|
17
|
-
"overrides": [
|
|
18
|
-
{
|
|
19
|
-
"files": [
|
|
20
|
-
"src"
|
|
21
|
-
],
|
|
22
|
-
"rules": {
|
|
23
|
-
"explicit-module-boundary-types": "off",
|
|
24
|
-
"no-restricted-imports": [
|
|
25
|
-
"error",
|
|
26
|
-
"@trpc/server"
|
|
27
|
-
]
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
]
|
|
31
|
-
},
|
|
32
16
|
"scripts": {
|
|
33
17
|
"build": "rollup --config rollup.config.ts --configPlugin rollup-plugin-swc3",
|
|
34
18
|
"dev": "pnpm build --watch",
|
|
35
19
|
"codegen-entrypoints": "tsx entrypoints.script.ts",
|
|
36
20
|
"benchmark": "tsc --project tsconfig.benchmark.json",
|
|
37
|
-
"lint": "eslint --cache --ext \".js,.ts,.tsx\" --ignore-path ../../.gitignore
|
|
21
|
+
"lint": "eslint --cache --ext \".js,.ts,.tsx\" --ignore-path ../../.gitignore src",
|
|
38
22
|
"ts-watch": "tsc --watch"
|
|
39
23
|
},
|
|
40
24
|
"exports": {
|
|
@@ -131,7 +115,7 @@
|
|
|
131
115
|
"access": "public"
|
|
132
116
|
},
|
|
133
117
|
"dependencies": {
|
|
134
|
-
"@trpc/core": "11.0.0-next-
|
|
118
|
+
"@trpc/core": "11.0.0-next-beta.178+f6674ef59"
|
|
135
119
|
},
|
|
136
120
|
"devDependencies": {
|
|
137
121
|
"@fastify/websocket": "^7.1.2",
|
|
@@ -170,5 +154,5 @@
|
|
|
170
154
|
"funding": [
|
|
171
155
|
"https://trpc.io/sponsor"
|
|
172
156
|
],
|
|
173
|
-
"gitHead": "
|
|
157
|
+
"gitHead": "f6674ef5901fe558e9f482918fe2b7b2218185cc"
|
|
174
158
|
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
export {
|
|
2
|
+
TRPCError,
|
|
3
|
+
/**
|
|
4
|
+
* @deprecated use `experimental_trpcMiddleware` instead
|
|
5
|
+
*/
|
|
6
|
+
experimental_standaloneMiddleware,
|
|
7
|
+
experimental_standaloneMiddleware as experimental_trpcMiddleware,
|
|
8
|
+
initTRPC,
|
|
9
|
+
callProcedure as callTRPCProcedure,
|
|
10
|
+
getTRPCErrorFromUnknown,
|
|
11
|
+
transformTRPCResponse,
|
|
12
|
+
type inferProcedureInput,
|
|
13
|
+
type inferProcedureOutput,
|
|
14
|
+
type inferRouterError,
|
|
15
|
+
type inferRouterInputs,
|
|
16
|
+
type inferRouterOutputs,
|
|
17
|
+
type inferRouterContext,
|
|
18
|
+
type AnyProcedure as AnyTRPCProcedure,
|
|
19
|
+
type AnyRouter as AnyTRPCRouter,
|
|
20
|
+
type AnyMiddlewareFunction as AnyTRPCMiddlewareFunction,
|
|
21
|
+
type CombinedDataTransformer as TRPCCombinedDataTransformer,
|
|
22
|
+
} from './@trpc-core-unstable-do-not-import-this-please';
|
|
23
|
+
|
|
24
|
+
export type {
|
|
25
|
+
/**
|
|
26
|
+
* @deprecated use `AnyTRPCProcedure` instead
|
|
27
|
+
*/
|
|
28
|
+
AnyProcedure,
|
|
29
|
+
/**
|
|
30
|
+
* @deprecated use `AnyTRPCRouter` instead
|
|
31
|
+
*/
|
|
32
|
+
AnyRouter,
|
|
33
|
+
/**
|
|
34
|
+
* @deprecated use `AnyTRPCMiddlewareFunction` instead
|
|
35
|
+
*/
|
|
36
|
+
AnyMiddlewareFunction,
|
|
37
|
+
/**
|
|
38
|
+
* @deprecated use `TRPCCombinedDataTransformer` instead
|
|
39
|
+
*/
|
|
40
|
+
CombinedDataTransformer,
|
|
41
|
+
} from '@trpc/core';
|
|
42
|
+
|
|
43
|
+
export {
|
|
44
|
+
/**
|
|
45
|
+
* @deprecated use `getTRPCErrorShape` instead
|
|
46
|
+
*/
|
|
47
|
+
getErrorShape,
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* @deprecated use `callTRPCProcedure` instead
|
|
51
|
+
*/
|
|
52
|
+
callProcedure,
|
|
53
|
+
} from '@trpc/core';
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* @deprecated
|
|
57
|
+
* Use `Awaited<ReturnType<typeof myFunction>>` instead
|
|
58
|
+
*/
|
|
59
|
+
export type inferAsyncReturnType<TFunction extends (...args: any[]) => any> =
|
|
60
|
+
Awaited<ReturnType<TFunction>>;
|
|
@@ -1,5 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
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
|
+
* Do **not** import from `@trpc/core`
|
|
5
|
+
* @example
|
|
6
|
+
* ```ts
|
|
7
|
+
* import type { AnyTRPCRouter } from '@trpc/server'
|
|
8
|
+
* import type { HTTPBaseHandlerOptions } from '@trpc/server/http'
|
|
9
|
+
* ```
|
|
10
|
+
*/
|
|
3
11
|
import type {
|
|
4
12
|
APIGatewayProxyEvent,
|
|
5
13
|
APIGatewayProxyEventV2,
|
|
@@ -7,6 +15,10 @@ import type {
|
|
|
7
15
|
APIGatewayProxyStructuredResultV2,
|
|
8
16
|
Context as APIGWContext,
|
|
9
17
|
} from 'aws-lambda';
|
|
18
|
+
// @trpc/server
|
|
19
|
+
import type { AnyRouter } from '../../@trpc-server';
|
|
20
|
+
// @trpc/server
|
|
21
|
+
import { TRPCError } from '../../@trpc-server';
|
|
10
22
|
import type {
|
|
11
23
|
HTTPRequest,
|
|
12
24
|
HTTPResponse,
|
|
@@ -1,5 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
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
|
+
* Do **not** import from `@trpc/core`
|
|
5
|
+
* @example
|
|
6
|
+
* ```ts
|
|
7
|
+
* import type { AnyTRPCRouter } from '@trpc/server'
|
|
8
|
+
* import type { HTTPBaseHandlerOptions } from '@trpc/server/http'
|
|
9
|
+
* ```
|
|
10
|
+
*/
|
|
3
11
|
import type {
|
|
4
12
|
APIGatewayProxyEvent,
|
|
5
13
|
APIGatewayProxyEventV2,
|
|
@@ -7,6 +15,10 @@ import type {
|
|
|
7
15
|
APIGatewayProxyStructuredResultV2,
|
|
8
16
|
Context as APIGWContext,
|
|
9
17
|
} from 'aws-lambda';
|
|
18
|
+
import type { AnyRouter, inferRouterContext } from '../../@trpc-server'; // import @trpc/server
|
|
19
|
+
|
|
20
|
+
// @trpc/server
|
|
21
|
+
import { TRPCError } from '../../@trpc-server';
|
|
10
22
|
import type {
|
|
11
23
|
HTTPHeaders,
|
|
12
24
|
OnErrorFunction,
|
|
@@ -49,13 +61,13 @@ export type AWSLambdaOptions<
|
|
|
49
61
|
} & (
|
|
50
62
|
| {
|
|
51
63
|
/**
|
|
52
|
-
* @link https://trpc.io/docs/context
|
|
64
|
+
* @link https://trpc.io/docs/v11/context
|
|
53
65
|
**/
|
|
54
66
|
createContext: AWSLambdaCreateContextFn<TRouter, TEvent>;
|
|
55
67
|
}
|
|
56
68
|
| {
|
|
57
69
|
/**
|
|
58
|
-
* @link https://trpc.io/docs/context
|
|
70
|
+
* @link https://trpc.io/docs/v11/context
|
|
59
71
|
**/
|
|
60
72
|
createContext?: AWSLambdaCreateContextFn<TRouter, TEvent>;
|
|
61
73
|
}
|
package/src/adapters/express.ts
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
|
-
|
|
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
|
+
* Do **not** import from `@trpc/core`
|
|
5
|
+
* @example
|
|
6
|
+
* ```ts
|
|
7
|
+
* import type { AnyTRPCRouter } from '@trpc/server'
|
|
8
|
+
* import type { HTTPBaseHandlerOptions } from '@trpc/server/http'
|
|
9
|
+
* ```
|
|
10
|
+
*/
|
|
2
11
|
import type * as express from 'express';
|
|
12
|
+
// @trpc/server
|
|
13
|
+
import type { AnyRouter } from '../@trpc-server';
|
|
3
14
|
import type {
|
|
4
15
|
NodeHTTPCreateContextFnOptions,
|
|
5
16
|
NodeHTTPHandlerOptions,
|
|
@@ -1,6 +1,17 @@
|
|
|
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
|
+
* Do **not** import from `@trpc/core`
|
|
5
|
+
* @example
|
|
6
|
+
* ```ts
|
|
7
|
+
* import type { AnyTRPCRouter } from '@trpc/server'
|
|
8
|
+
* import type { HTTPBaseHandlerOptions } from '@trpc/server/http'
|
|
9
|
+
* ```
|
|
10
|
+
*/
|
|
1
11
|
import { Readable } from 'node:stream';
|
|
2
|
-
import type { AnyRouter } from '@trpc/core';
|
|
3
12
|
import type { FastifyReply, FastifyRequest } from 'fastify';
|
|
13
|
+
// @trpc/server
|
|
14
|
+
import type { AnyRouter } from '../../@trpc-server';
|
|
4
15
|
import type {
|
|
5
16
|
HTTPBaseHandlerOptions,
|
|
6
17
|
HTTPRequest,
|
|
@@ -1,7 +1,18 @@
|
|
|
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
|
+
* Do **not** import from `@trpc/core`
|
|
5
|
+
* @example
|
|
6
|
+
* ```ts
|
|
7
|
+
* import type { AnyTRPCRouter } from '@trpc/server'
|
|
8
|
+
* import type { HTTPBaseHandlerOptions } from '@trpc/server/http'
|
|
9
|
+
* ```
|
|
10
|
+
*/
|
|
1
11
|
/// <reference types="@fastify/websocket" />
|
|
2
|
-
import type { AnyRouter } from '@trpc/core';
|
|
3
12
|
import type { FastifyInstance, FastifyReply, FastifyRequest } from 'fastify';
|
|
4
13
|
import type { FastifyHandlerOptions } from '.';
|
|
14
|
+
// @trpc/server
|
|
15
|
+
import type { AnyRouter } from '../../@trpc-server';
|
|
5
16
|
import type { NodeHTTPCreateContextFnOptions } from '../node-http';
|
|
6
17
|
import type { WSSHandlerOptions } from '../ws';
|
|
7
18
|
import { applyWSSHandler } from '../ws';
|
|
@@ -1,4 +1,15 @@
|
|
|
1
|
-
|
|
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
|
+
* Do **not** import from `@trpc/core`
|
|
5
|
+
* @example
|
|
6
|
+
* ```ts
|
|
7
|
+
* import type { AnyTRPCRouter } from '@trpc/server'
|
|
8
|
+
* import type { HTTPBaseHandlerOptions } from '@trpc/server/http'
|
|
9
|
+
* ```
|
|
10
|
+
*/
|
|
11
|
+
// @trpc/server
|
|
12
|
+
import type { AnyRouter } from '../../@trpc-server';
|
|
2
13
|
import type {
|
|
3
14
|
HTTPRequest,
|
|
4
15
|
HTTPResponse,
|
|
@@ -1,5 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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
|
+
* Do **not** import from `@trpc/core`
|
|
5
|
+
* @example
|
|
6
|
+
* ```ts
|
|
7
|
+
* import type { AnyTRPCRouter } from '@trpc/server'
|
|
8
|
+
* import type { HTTPBaseHandlerOptions } from '@trpc/server/http'
|
|
9
|
+
* ```
|
|
10
|
+
*/
|
|
11
|
+
// @trpc/server
|
|
12
|
+
import type { AnyRouter, inferRouterContext } from '../../@trpc-server';
|
|
13
|
+
// @trpc/server/http
|
|
14
|
+
import type {
|
|
15
|
+
HTTPBaseHandlerOptions,
|
|
16
|
+
TRPCRequestInfo,
|
|
17
|
+
} from '../../@trpc-server/http';
|
|
3
18
|
|
|
4
19
|
export type FetchCreateContextFnOptions = {
|
|
5
20
|
req: Request;
|
|
@@ -15,13 +30,13 @@ export type FetchCreateContextOption<TRouter extends AnyRouter> =
|
|
|
15
30
|
unknown extends inferRouterContext<TRouter>
|
|
16
31
|
? {
|
|
17
32
|
/**
|
|
18
|
-
* @link https://trpc.io/docs/context
|
|
33
|
+
* @link https://trpc.io/docs/v11/context
|
|
19
34
|
**/
|
|
20
35
|
createContext?: FetchCreateContextFn<TRouter>;
|
|
21
36
|
}
|
|
22
37
|
: {
|
|
23
38
|
/**
|
|
24
|
-
* @link https://trpc.io/docs/context
|
|
39
|
+
* @link https://trpc.io/docs/v11/context
|
|
25
40
|
**/
|
|
26
41
|
createContext: FetchCreateContextFn<TRouter>;
|
|
27
42
|
};
|
package/src/adapters/next.ts
CHANGED
|
@@ -1,6 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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
|
+
* Do **not** import from `@trpc/core`
|
|
5
|
+
* @example
|
|
6
|
+
* ```ts
|
|
7
|
+
* import type { AnyTRPCRouter } from '@trpc/server'
|
|
8
|
+
* import type { HTTPBaseHandlerOptions } from '@trpc/server/http'
|
|
9
|
+
* ```
|
|
10
|
+
*/
|
|
3
11
|
import type { NextApiHandler, NextApiRequest, NextApiResponse } from 'next';
|
|
12
|
+
// @trpc/server
|
|
13
|
+
import type { AnyRouter } from '../@trpc-server';
|
|
14
|
+
// @trpc/server
|
|
15
|
+
import { getErrorShape, TRPCError } from '../@trpc-server';
|
|
4
16
|
import type {
|
|
5
17
|
NodeHTTPCreateContextFnOptions,
|
|
6
18
|
NodeHTTPHandlerOptions,
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
|
-
* @
|
|
11
|
+
* @link https://github.com/remix-run/remix/blob/0bcb4a304dd2f08f6032c3bf0c3aa7eb5b976901/packages/remix-node/upload/fileUploadHandler.ts
|
|
12
12
|
*/
|
|
13
13
|
import { randomBytes } from 'node:crypto';
|
|
14
14
|
import { createReadStream, createWriteStream, statSync } from 'node:fs';
|
|
@@ -6,14 +6,15 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
|
-
* @
|
|
9
|
+
* @link https://github.com/remix-run/remix/blob/0bcb4a304dd2f08f6032c3bf0c3aa7eb5b976901/packages/remix-server-runtime/formData.ts
|
|
10
10
|
*/
|
|
11
11
|
import * as fs from 'fs/promises';
|
|
12
12
|
import { Readable } from 'node:stream';
|
|
13
|
-
import type { CombinedDataTransformer } from '@trpc/core';
|
|
14
13
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
15
14
|
// @ts-ignore the type definitions for this package are borked
|
|
16
15
|
import { streamMultipart } from '@web3-storage/multipart-parser';
|
|
16
|
+
// @trpc/server
|
|
17
|
+
import type { CombinedDataTransformer } from '../../../../@trpc-server';
|
|
17
18
|
import { createNodeHTTPContentTypeHandler } from '../../internals/contentType';
|
|
18
19
|
import type { NodeHTTPRequest } from '../../types';
|
|
19
20
|
import { NodeOnDiskFile } from './fileUploadHandler';
|
|
@@ -30,7 +31,7 @@ const utfTextDecoder = new TextDecoder('utf-8');
|
|
|
30
31
|
* @param uploadHandler A function that handles file uploads and returns a value to be used in the request body. If uploaded to disk, the returned value is a NodeOnDiskFile. If uploaded to memory, the returned value is a File.
|
|
31
32
|
* @param maxBodySize The maximum size of the request body in bytes. Defaults to Infinity.
|
|
32
33
|
*
|
|
33
|
-
* @
|
|
34
|
+
* @link https://remix.run/utils/parse-multipart-form-data
|
|
34
35
|
*/
|
|
35
36
|
async function parseMultipartFormData(
|
|
36
37
|
request: NodeHTTPRequest,
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
|
-
* @
|
|
9
|
+
* @link https://github.com/remix-run/remix/blob/0bcb4a304dd2f08f6032c3bf0c3aa7eb5b976901/packages/remix-server-runtime/upload/memoryUploadHandler.ts
|
|
10
10
|
*/
|
|
11
11
|
import type { UploadHandler } from './uploadHandler';
|
|
12
12
|
import { MaxPartSizeExceededError } from './uploadHandler';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { NodeOnDiskFile } from './fileUploadHandler';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* @
|
|
4
|
+
* @link https://github.com/remix-run/remix/blob/0bcb4a304dd2f08f6032c3bf0c3aa7eb5b976901/packages/remix-server-runtime/formData.ts
|
|
5
5
|
*/
|
|
6
6
|
export type UploadHandlerPart = {
|
|
7
7
|
name: string;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
import type {
|
|
1
|
+
// @trpc/server
|
|
2
|
+
import type { AnyRouter } from '../../../@trpc-server';
|
|
3
|
+
// @trpc/server/http
|
|
4
|
+
import type { BaseContentTypeHandler } from '../../../@trpc-server/http';
|
|
3
5
|
import type {
|
|
4
6
|
NodeHTTPRequest,
|
|
5
7
|
NodeHTTPRequestHandlerOptions,
|
|
@@ -1,5 +1,16 @@
|
|
|
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
|
+
* Do **not** import from `@trpc/core`
|
|
5
|
+
* @example
|
|
6
|
+
* ```ts
|
|
7
|
+
* import type { AnyTRPCRouter } from '@trpc/server'
|
|
8
|
+
* import type { HTTPBaseHandlerOptions } from '@trpc/server/http'
|
|
9
|
+
* ```
|
|
10
|
+
*/
|
|
1
11
|
/* eslint-disable @typescript-eslint/no-non-null-assertion */
|
|
2
|
-
|
|
12
|
+
// @trpc/server
|
|
13
|
+
import type { AnyRouter } from '../../@trpc-server';
|
|
3
14
|
import type {
|
|
4
15
|
HTTPRequest,
|
|
5
16
|
HTTPResponse,
|
|
@@ -1,6 +1,23 @@
|
|
|
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
|
+
* Do **not** import from `@trpc/core`
|
|
5
|
+
* @example
|
|
6
|
+
* ```ts
|
|
7
|
+
* import type { AnyTRPCRouter } from '@trpc/server'
|
|
8
|
+
* import type { HTTPBaseHandlerOptions } from '@trpc/server/http'
|
|
9
|
+
* ```
|
|
10
|
+
*/
|
|
1
11
|
import type { IncomingMessage, ServerResponse } from 'http';
|
|
2
|
-
|
|
3
|
-
import type {
|
|
12
|
+
// eslint-disable-next-line no-restricted-imports
|
|
13
|
+
import type { MaybePromise } from '@trpc/core';
|
|
14
|
+
// @trpc/server
|
|
15
|
+
import type { AnyRouter, inferRouterContext } from '../../@trpc-server';
|
|
16
|
+
// @trpc/server/http
|
|
17
|
+
import type {
|
|
18
|
+
HTTPBaseHandlerOptions,
|
|
19
|
+
TRPCRequestInfo,
|
|
20
|
+
} from '../../@trpc-server/http';
|
|
4
21
|
import type { NodeHTTPContentTypeHandler } from './internals/contentType';
|
|
5
22
|
|
|
6
23
|
interface ParsedQs {
|
|
@@ -30,13 +47,13 @@ export type NodeHTTPCreateContextOption<
|
|
|
30
47
|
> = object extends inferRouterContext<TRouter>
|
|
31
48
|
? {
|
|
32
49
|
/**
|
|
33
|
-
* @link https://trpc.io/docs/context
|
|
50
|
+
* @link https://trpc.io/docs/v11/context
|
|
34
51
|
**/
|
|
35
52
|
createContext?: NodeHTTPCreateContextFn<TRouter, TRequest, TResponse>;
|
|
36
53
|
}
|
|
37
54
|
: {
|
|
38
55
|
/**
|
|
39
|
-
* @link https://trpc.io/docs/context
|
|
56
|
+
* @link https://trpc.io/docs/v11/context
|
|
40
57
|
**/
|
|
41
58
|
createContext: NodeHTTPCreateContextFn<TRouter, TRequest, TResponse>;
|
|
42
59
|
};
|
|
@@ -1,6 +1,17 @@
|
|
|
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
|
+
* Do **not** import from `@trpc/core`
|
|
5
|
+
* @example
|
|
6
|
+
* ```ts
|
|
7
|
+
* import type { AnyTRPCRouter } from '@trpc/server'
|
|
8
|
+
* import type { HTTPBaseHandlerOptions } from '@trpc/server/http'
|
|
9
|
+
* ```
|
|
10
|
+
*/
|
|
1
11
|
/* eslint-disable @typescript-eslint/no-non-null-assertion */
|
|
2
12
|
import http from 'http';
|
|
3
|
-
|
|
13
|
+
// @trpc/server
|
|
14
|
+
import type { AnyRouter } from '../@trpc-server';
|
|
4
15
|
import type {
|
|
5
16
|
NodeHTTPCreateContextFnOptions,
|
|
6
17
|
NodeHTTPHandlerOptions,
|
package/src/adapters/ws.ts
CHANGED
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
import type { IncomingMessage } from 'http';
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
callProcedure,
|
|
5
|
-
getErrorShape,
|
|
6
|
-
getTRPCErrorFromUnknown,
|
|
7
|
-
transformTRPCResponse,
|
|
8
|
-
TRPCError,
|
|
9
|
-
} from '@trpc/core';
|
|
2
|
+
// eslint-disable-next-line no-restricted-imports
|
|
3
|
+
import type { MaybePromise } from '@trpc/core';
|
|
10
4
|
import type { BaseHandlerOptions } from '@trpc/core/http';
|
|
11
5
|
import type { Unsubscribable } from '@trpc/core/observable';
|
|
12
6
|
import { isObservable } from '@trpc/core/observable';
|
|
@@ -18,11 +12,19 @@ import type {
|
|
|
18
12
|
} from '@trpc/core/rpc';
|
|
19
13
|
import { parseTRPCMessage } from '@trpc/core/rpc';
|
|
20
14
|
import type ws from 'ws';
|
|
15
|
+
import type { AnyRouter, inferRouterContext } from '../@trpc-server';
|
|
16
|
+
import {
|
|
17
|
+
callProcedure,
|
|
18
|
+
getErrorShape,
|
|
19
|
+
getTRPCErrorFromUnknown,
|
|
20
|
+
transformTRPCResponse,
|
|
21
|
+
TRPCError,
|
|
22
|
+
} from '../@trpc-server';
|
|
21
23
|
import type { NodeHTTPCreateContextFnOptions } from './node-http';
|
|
22
24
|
|
|
23
25
|
/**
|
|
24
26
|
* Importing ws causes a build error
|
|
25
|
-
* @
|
|
27
|
+
* @link https://github.com/trpc/trpc/pull/5279
|
|
26
28
|
*/
|
|
27
29
|
const WEBSOCKET_OPEN = 1; /* ws.WebSocket.OPEN */
|
|
28
30
|
|
|
@@ -51,13 +53,13 @@ export type WSSHandlerOptions<TRouter extends AnyRouter> = BaseHandlerOptions<
|
|
|
51
53
|
(object extends inferRouterContext<TRouter>
|
|
52
54
|
? {
|
|
53
55
|
/**
|
|
54
|
-
* @link https://trpc.io/docs/context
|
|
56
|
+
* @link https://trpc.io/docs/v11/context
|
|
55
57
|
**/
|
|
56
58
|
createContext?: CreateWSSContextFn<TRouter>;
|
|
57
59
|
}
|
|
58
60
|
: {
|
|
59
61
|
/**
|
|
60
|
-
* @link https://trpc.io/docs/context
|
|
62
|
+
* @link https://trpc.io/docs/v11/context
|
|
61
63
|
**/
|
|
62
64
|
createContext: CreateWSSContextFn<TRouter>;
|
|
63
65
|
}) & {
|