@temporary-name/server 1.9.3-alpha.4275e976ddda4d8be107c2cfde9899bdea9a337d → 1.9.3-alpha.4c6c68e5af7355d5a6dff1179055586e1093ac2d
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/adapters/aws-lambda/index.d.mts +12 -8
- package/dist/adapters/aws-lambda/index.d.ts +12 -8
- package/dist/adapters/aws-lambda/index.mjs +12 -4
- package/dist/adapters/fetch/index.d.mts +15 -87
- package/dist/adapters/fetch/index.d.ts +15 -87
- package/dist/adapters/fetch/index.mjs +23 -161
- package/dist/adapters/node/index.d.mts +15 -64
- package/dist/adapters/node/index.d.ts +15 -64
- package/dist/adapters/node/index.mjs +21 -126
- package/dist/adapters/standard/index.d.mts +27 -14
- package/dist/adapters/standard/index.d.ts +27 -14
- package/dist/adapters/standard/index.mjs +9 -101
- package/dist/helpers/index.mjs +3 -29
- package/dist/index.d.mts +120 -583
- package/dist/index.d.ts +120 -583
- package/dist/index.mjs +213 -449
- package/dist/openapi/index.d.mts +204 -0
- package/dist/openapi/index.d.ts +204 -0
- package/dist/openapi/index.mjs +692 -0
- package/dist/shared/server.BbUmcWIW.d.mts +41 -0
- package/dist/shared/server.BfraJHay.d.mts +373 -0
- package/dist/shared/server.BfraJHay.d.ts +373 -0
- package/dist/shared/server.C1RJffw4.mjs +30 -0
- package/dist/shared/server.CHugaZ_Y.d.ts +41 -0
- package/dist/shared/server.CQIFwyhc.mjs +40 -0
- package/dist/shared/server.CYa9puL2.mjs +403 -0
- package/dist/shared/server.ChOv1yG3.mjs +319 -0
- package/dist/shared/server.Cza0RB3u.mjs +160 -0
- package/dist/shared/server.YUvuxHty.mjs +48 -0
- package/package.json +18 -30
- package/dist/plugins/index.d.mts +0 -160
- package/dist/plugins/index.d.ts +0 -160
- package/dist/plugins/index.mjs +0 -288
- package/dist/shared/server.BEQrAa3A.mjs +0 -207
- package/dist/shared/server.Bo94xDTv.d.mts +0 -73
- package/dist/shared/server.Btxrgkj5.d.ts +0 -73
- package/dist/shared/server.C1YnHvvf.d.mts +0 -192
- package/dist/shared/server.C1YnHvvf.d.ts +0 -192
- package/dist/shared/server.D6K9uoPI.mjs +0 -35
- package/dist/shared/server.DZ5BIITo.mjs +0 -9
- package/dist/shared/server.X0YaZxSJ.mjs +0 -13
|
@@ -1,22 +1,26 @@
|
|
|
1
1
|
import { MaybeOptionalOptions } from '@temporary-name/shared';
|
|
2
2
|
import { SendStandardResponseOptions, APIGatewayProxyEventV2, ResponseStream } from '@temporary-name/standard-server-aws-lambda';
|
|
3
|
-
import { C as Context } from '../../shared/server.
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import '@temporary-name/contract';
|
|
7
|
-
import '@temporary-name/standard-server';
|
|
3
|
+
import { C as Context, m as Router } from '../../shared/server.BfraJHay.mjs';
|
|
4
|
+
import { b as StandardHandlerOptions, F as FriendlyStandardHandleOptions } from '../../shared/server.BbUmcWIW.mjs';
|
|
5
|
+
import '@temporary-name/zod';
|
|
8
6
|
|
|
9
|
-
interface AwsLambdaHandlerOptions extends SendStandardResponseOptions {
|
|
7
|
+
interface AwsLambdaHandlerOptions<T extends Context> extends StandardHandlerOptions<T>, SendStandardResponseOptions {
|
|
10
8
|
}
|
|
11
9
|
type AwsLambdaHandleResult = {
|
|
12
10
|
matched: true;
|
|
13
11
|
} | {
|
|
14
12
|
matched: false;
|
|
15
13
|
};
|
|
14
|
+
/**
|
|
15
|
+
* OpenAPI Handler for AWS Lambda.
|
|
16
|
+
*
|
|
17
|
+
* @see {@link https://orpc.unnoq.com/docs/openapi/openapi-handler OpenAPI Handler Docs}
|
|
18
|
+
* @see {@link https://orpc.unnoq.com/docs/adapters/http HTTP Adapter Docs}
|
|
19
|
+
*/
|
|
16
20
|
declare class AwsLambdaHandler<T extends Context> {
|
|
17
|
-
private readonly standardHandler;
|
|
18
21
|
private readonly sendStandardResponseOptions;
|
|
19
|
-
|
|
22
|
+
private readonly standardHandler;
|
|
23
|
+
constructor(router: Router<T>, options?: AwsLambdaHandlerOptions<T>);
|
|
20
24
|
handle(event: APIGatewayProxyEventV2, responseStream: ResponseStream, ...rest: MaybeOptionalOptions<FriendlyStandardHandleOptions<T>>): Promise<AwsLambdaHandleResult>;
|
|
21
25
|
}
|
|
22
26
|
|
|
@@ -1,22 +1,26 @@
|
|
|
1
1
|
import { MaybeOptionalOptions } from '@temporary-name/shared';
|
|
2
2
|
import { SendStandardResponseOptions, APIGatewayProxyEventV2, ResponseStream } from '@temporary-name/standard-server-aws-lambda';
|
|
3
|
-
import { C as Context } from '../../shared/server.
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import '@temporary-name/contract';
|
|
7
|
-
import '@temporary-name/standard-server';
|
|
3
|
+
import { C as Context, m as Router } from '../../shared/server.BfraJHay.js';
|
|
4
|
+
import { b as StandardHandlerOptions, F as FriendlyStandardHandleOptions } from '../../shared/server.CHugaZ_Y.js';
|
|
5
|
+
import '@temporary-name/zod';
|
|
8
6
|
|
|
9
|
-
interface AwsLambdaHandlerOptions extends SendStandardResponseOptions {
|
|
7
|
+
interface AwsLambdaHandlerOptions<T extends Context> extends StandardHandlerOptions<T>, SendStandardResponseOptions {
|
|
10
8
|
}
|
|
11
9
|
type AwsLambdaHandleResult = {
|
|
12
10
|
matched: true;
|
|
13
11
|
} | {
|
|
14
12
|
matched: false;
|
|
15
13
|
};
|
|
14
|
+
/**
|
|
15
|
+
* OpenAPI Handler for AWS Lambda.
|
|
16
|
+
*
|
|
17
|
+
* @see {@link https://orpc.unnoq.com/docs/openapi/openapi-handler OpenAPI Handler Docs}
|
|
18
|
+
* @see {@link https://orpc.unnoq.com/docs/adapters/http HTTP Adapter Docs}
|
|
19
|
+
*/
|
|
16
20
|
declare class AwsLambdaHandler<T extends Context> {
|
|
17
|
-
private readonly standardHandler;
|
|
18
21
|
private readonly sendStandardResponseOptions;
|
|
19
|
-
|
|
22
|
+
private readonly standardHandler;
|
|
23
|
+
constructor(router: Router<T>, options?: AwsLambdaHandlerOptions<T>);
|
|
20
24
|
handle(event: APIGatewayProxyEventV2, responseStream: ResponseStream, ...rest: MaybeOptionalOptions<FriendlyStandardHandleOptions<T>>): Promise<AwsLambdaHandleResult>;
|
|
21
25
|
}
|
|
22
26
|
|
|
@@ -1,13 +1,21 @@
|
|
|
1
1
|
import { resolveMaybeOptionalOptions } from '@temporary-name/shared';
|
|
2
2
|
import { toStandardLazyRequest, sendStandardResponse } from '@temporary-name/standard-server-aws-lambda';
|
|
3
|
-
import { r as resolveFriendlyStandardHandleOptions } from '../../shared/server.
|
|
3
|
+
import { S as StandardHandler, r as resolveFriendlyStandardHandleOptions } from '../../shared/server.CYa9puL2.mjs';
|
|
4
|
+
import '@temporary-name/standard-server';
|
|
5
|
+
import '@temporary-name/server';
|
|
6
|
+
import 'rou3';
|
|
7
|
+
import '../../shared/server.Cza0RB3u.mjs';
|
|
8
|
+
import '@temporary-name/zod';
|
|
9
|
+
import '../../shared/server.ChOv1yG3.mjs';
|
|
10
|
+
import '../../shared/server.CQIFwyhc.mjs';
|
|
4
11
|
|
|
5
12
|
class AwsLambdaHandler {
|
|
6
|
-
|
|
7
|
-
|
|
13
|
+
sendStandardResponseOptions;
|
|
14
|
+
standardHandler;
|
|
15
|
+
constructor(router, options = {}) {
|
|
16
|
+
this.standardHandler = new StandardHandler(router, options);
|
|
8
17
|
this.sendStandardResponseOptions = options;
|
|
9
18
|
}
|
|
10
|
-
sendStandardResponseOptions;
|
|
11
19
|
async handle(event, responseStream, ...rest) {
|
|
12
20
|
const standardRequest = toStandardLazyRequest(event, responseStream);
|
|
13
21
|
const options = resolveFriendlyStandardHandleOptions(resolveMaybeOptionalOptions(rest));
|
|
@@ -1,17 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Interceptor, MaybeOptionalOptions } from '@temporary-name/shared';
|
|
1
|
+
import { MaybeOptionalOptions } from '@temporary-name/shared';
|
|
3
2
|
import { ToFetchResponseOptions } from '@temporary-name/standard-server-fetch';
|
|
4
|
-
import {
|
|
5
|
-
import { FriendlyStandardHandleOptions } from '
|
|
6
|
-
import '@temporary-name/
|
|
7
|
-
import '@temporary-name/standard-server';
|
|
8
|
-
|
|
9
|
-
interface FetchHandlerPlugin<T extends Context> extends StandardHandlerPlugin<T> {
|
|
10
|
-
initRuntimeAdapter?(options: FetchHandlerOptions<T>): void;
|
|
11
|
-
}
|
|
12
|
-
declare class CompositeFetchHandlerPlugin<T extends Context, TPlugin extends FetchHandlerPlugin<T>> extends CompositeStandardHandlerPlugin<T, TPlugin> implements FetchHandlerPlugin<T> {
|
|
13
|
-
initRuntimeAdapter(options: FetchHandlerOptions<T>): void;
|
|
14
|
-
}
|
|
3
|
+
import { C as Context, m as Router } from '../../shared/server.BfraJHay.mjs';
|
|
4
|
+
import { b as StandardHandlerOptions, F as FriendlyStandardHandleOptions } from '../../shared/server.BbUmcWIW.mjs';
|
|
5
|
+
import '@temporary-name/zod';
|
|
15
6
|
|
|
16
7
|
type FetchHandleResult = {
|
|
17
8
|
matched: true;
|
|
@@ -20,83 +11,20 @@ type FetchHandleResult = {
|
|
|
20
11
|
matched: false;
|
|
21
12
|
response: undefined;
|
|
22
13
|
};
|
|
23
|
-
interface
|
|
24
|
-
request: Request;
|
|
25
|
-
toFetchResponseOptions: ToFetchResponseOptions;
|
|
26
|
-
}
|
|
27
|
-
interface FetchHandlerOptions<T extends Context> extends ToFetchResponseOptions {
|
|
28
|
-
adapterInterceptors?: Interceptor<FetchHandlerInterceptorOptions<T>, Promise<FetchHandleResult>>[];
|
|
29
|
-
plugins?: FetchHandlerPlugin<T>[];
|
|
30
|
-
}
|
|
31
|
-
declare class FetchHandler<T extends Context> {
|
|
32
|
-
private readonly standardHandler;
|
|
33
|
-
private readonly toFetchResponseOptions;
|
|
34
|
-
private readonly adapterInterceptors;
|
|
35
|
-
constructor(standardHandler: StandardHandler<T>, options?: NoInfer<FetchHandlerOptions<T>>);
|
|
36
|
-
handle(request: Request, ...rest: MaybeOptionalOptions<FriendlyStandardHandleOptions<T>>): Promise<FetchHandleResult>;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
interface BodyLimitPluginOptions {
|
|
40
|
-
/**
|
|
41
|
-
* The maximum size of the body in bytes.
|
|
42
|
-
*/
|
|
43
|
-
maxBodySize: number;
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* The Body Limit Plugin restricts the size of the request body for the Fetch Server.
|
|
47
|
-
*
|
|
48
|
-
* @see {@link https://orpc.unnoq.com/docs/plugins/body-limit Body Limit Plugin Docs}
|
|
49
|
-
*/
|
|
50
|
-
declare class BodyLimitPlugin<T extends Context> implements FetchHandlerPlugin<T> {
|
|
51
|
-
private readonly maxBodySize;
|
|
52
|
-
constructor(options: BodyLimitPluginOptions);
|
|
53
|
-
initRuntimeAdapter(options: FetchHandlerOptions<T>): void;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* This plugin is heavily inspired by the [Hono Compression Plugin](https://github.com/honojs/hono/blob/main/src/middleware/compress/index.ts)
|
|
58
|
-
*/
|
|
59
|
-
|
|
60
|
-
declare const ORDERED_SUPPORTED_ENCODINGS: readonly ["gzip", "deflate"];
|
|
61
|
-
interface CompressionPluginOptions {
|
|
62
|
-
/**
|
|
63
|
-
* The compression schemes to use for response compression.
|
|
64
|
-
* Schemes are prioritized by their order in this array and
|
|
65
|
-
* only applied if the client supports them.
|
|
66
|
-
*
|
|
67
|
-
* @default ['gzip', 'deflate']
|
|
68
|
-
*/
|
|
69
|
-
encodings?: readonly (typeof ORDERED_SUPPORTED_ENCODINGS)[number][];
|
|
70
|
-
/**
|
|
71
|
-
* The minimum response size in bytes required to trigger compression.
|
|
72
|
-
* Responses smaller than this threshold will not be compressed to avoid overhead.
|
|
73
|
-
* If the response size cannot be determined, compression will still be applied.
|
|
74
|
-
*
|
|
75
|
-
* @default 1024 (1KB)
|
|
76
|
-
*/
|
|
77
|
-
threshold?: number;
|
|
78
|
-
/**
|
|
79
|
-
* Override the default content-type filter used to determine which responses should be compressed.
|
|
80
|
-
*
|
|
81
|
-
* @warning [Event Iterator](https://orpc.unnoq.com/docs/event-iterator) responses are never compressed, regardless of this filter's return value.
|
|
82
|
-
* @default only responses with compressible content types are compressed.
|
|
83
|
-
*/
|
|
84
|
-
filter?: (request: Request, response: Response) => boolean;
|
|
14
|
+
interface FetchHandlerOptions<T extends Context> extends ToFetchResponseOptions, StandardHandlerOptions<T> {
|
|
85
15
|
}
|
|
86
16
|
/**
|
|
87
|
-
*
|
|
88
|
-
* Build on top of [CompressionStream](https://developer.mozilla.org/en-US/docs/Web/API/CompressionStream)
|
|
89
|
-
* You might need to polyfill it if your environment does not support it.
|
|
17
|
+
* OpenAPI Handler for Fetch Server
|
|
90
18
|
*
|
|
91
|
-
* @see {@link https://orpc.unnoq.com/docs/
|
|
19
|
+
* @see {@link https://orpc.unnoq.com/docs/openapi/openapi-handler OpenAPI Handler Docs}
|
|
20
|
+
* @see {@link https://orpc.unnoq.com/docs/adapters/http HTTP Adapter Docs}
|
|
92
21
|
*/
|
|
93
|
-
declare class
|
|
94
|
-
private readonly
|
|
95
|
-
private readonly
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
initRuntimeAdapter(options: FetchHandlerOptions<T>): void;
|
|
22
|
+
declare class FetchHandler<T extends Context> {
|
|
23
|
+
private readonly toFetchResponseOptions;
|
|
24
|
+
private readonly standardHandler;
|
|
25
|
+
constructor(router: Router<T>, options?: NoInfer<FetchHandlerOptions<T>>);
|
|
26
|
+
handle(request: Request, ...rest: MaybeOptionalOptions<FriendlyStandardHandleOptions<T>>): Promise<FetchHandleResult>;
|
|
99
27
|
}
|
|
100
28
|
|
|
101
|
-
export {
|
|
102
|
-
export type {
|
|
29
|
+
export { FetchHandler };
|
|
30
|
+
export type { FetchHandleResult, FetchHandlerOptions };
|
|
@@ -1,17 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Interceptor, MaybeOptionalOptions } from '@temporary-name/shared';
|
|
1
|
+
import { MaybeOptionalOptions } from '@temporary-name/shared';
|
|
3
2
|
import { ToFetchResponseOptions } from '@temporary-name/standard-server-fetch';
|
|
4
|
-
import {
|
|
5
|
-
import { FriendlyStandardHandleOptions } from '
|
|
6
|
-
import '@temporary-name/
|
|
7
|
-
import '@temporary-name/standard-server';
|
|
8
|
-
|
|
9
|
-
interface FetchHandlerPlugin<T extends Context> extends StandardHandlerPlugin<T> {
|
|
10
|
-
initRuntimeAdapter?(options: FetchHandlerOptions<T>): void;
|
|
11
|
-
}
|
|
12
|
-
declare class CompositeFetchHandlerPlugin<T extends Context, TPlugin extends FetchHandlerPlugin<T>> extends CompositeStandardHandlerPlugin<T, TPlugin> implements FetchHandlerPlugin<T> {
|
|
13
|
-
initRuntimeAdapter(options: FetchHandlerOptions<T>): void;
|
|
14
|
-
}
|
|
3
|
+
import { C as Context, m as Router } from '../../shared/server.BfraJHay.js';
|
|
4
|
+
import { b as StandardHandlerOptions, F as FriendlyStandardHandleOptions } from '../../shared/server.CHugaZ_Y.js';
|
|
5
|
+
import '@temporary-name/zod';
|
|
15
6
|
|
|
16
7
|
type FetchHandleResult = {
|
|
17
8
|
matched: true;
|
|
@@ -20,83 +11,20 @@ type FetchHandleResult = {
|
|
|
20
11
|
matched: false;
|
|
21
12
|
response: undefined;
|
|
22
13
|
};
|
|
23
|
-
interface
|
|
24
|
-
request: Request;
|
|
25
|
-
toFetchResponseOptions: ToFetchResponseOptions;
|
|
26
|
-
}
|
|
27
|
-
interface FetchHandlerOptions<T extends Context> extends ToFetchResponseOptions {
|
|
28
|
-
adapterInterceptors?: Interceptor<FetchHandlerInterceptorOptions<T>, Promise<FetchHandleResult>>[];
|
|
29
|
-
plugins?: FetchHandlerPlugin<T>[];
|
|
30
|
-
}
|
|
31
|
-
declare class FetchHandler<T extends Context> {
|
|
32
|
-
private readonly standardHandler;
|
|
33
|
-
private readonly toFetchResponseOptions;
|
|
34
|
-
private readonly adapterInterceptors;
|
|
35
|
-
constructor(standardHandler: StandardHandler<T>, options?: NoInfer<FetchHandlerOptions<T>>);
|
|
36
|
-
handle(request: Request, ...rest: MaybeOptionalOptions<FriendlyStandardHandleOptions<T>>): Promise<FetchHandleResult>;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
interface BodyLimitPluginOptions {
|
|
40
|
-
/**
|
|
41
|
-
* The maximum size of the body in bytes.
|
|
42
|
-
*/
|
|
43
|
-
maxBodySize: number;
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* The Body Limit Plugin restricts the size of the request body for the Fetch Server.
|
|
47
|
-
*
|
|
48
|
-
* @see {@link https://orpc.unnoq.com/docs/plugins/body-limit Body Limit Plugin Docs}
|
|
49
|
-
*/
|
|
50
|
-
declare class BodyLimitPlugin<T extends Context> implements FetchHandlerPlugin<T> {
|
|
51
|
-
private readonly maxBodySize;
|
|
52
|
-
constructor(options: BodyLimitPluginOptions);
|
|
53
|
-
initRuntimeAdapter(options: FetchHandlerOptions<T>): void;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* This plugin is heavily inspired by the [Hono Compression Plugin](https://github.com/honojs/hono/blob/main/src/middleware/compress/index.ts)
|
|
58
|
-
*/
|
|
59
|
-
|
|
60
|
-
declare const ORDERED_SUPPORTED_ENCODINGS: readonly ["gzip", "deflate"];
|
|
61
|
-
interface CompressionPluginOptions {
|
|
62
|
-
/**
|
|
63
|
-
* The compression schemes to use for response compression.
|
|
64
|
-
* Schemes are prioritized by their order in this array and
|
|
65
|
-
* only applied if the client supports them.
|
|
66
|
-
*
|
|
67
|
-
* @default ['gzip', 'deflate']
|
|
68
|
-
*/
|
|
69
|
-
encodings?: readonly (typeof ORDERED_SUPPORTED_ENCODINGS)[number][];
|
|
70
|
-
/**
|
|
71
|
-
* The minimum response size in bytes required to trigger compression.
|
|
72
|
-
* Responses smaller than this threshold will not be compressed to avoid overhead.
|
|
73
|
-
* If the response size cannot be determined, compression will still be applied.
|
|
74
|
-
*
|
|
75
|
-
* @default 1024 (1KB)
|
|
76
|
-
*/
|
|
77
|
-
threshold?: number;
|
|
78
|
-
/**
|
|
79
|
-
* Override the default content-type filter used to determine which responses should be compressed.
|
|
80
|
-
*
|
|
81
|
-
* @warning [Event Iterator](https://orpc.unnoq.com/docs/event-iterator) responses are never compressed, regardless of this filter's return value.
|
|
82
|
-
* @default only responses with compressible content types are compressed.
|
|
83
|
-
*/
|
|
84
|
-
filter?: (request: Request, response: Response) => boolean;
|
|
14
|
+
interface FetchHandlerOptions<T extends Context> extends ToFetchResponseOptions, StandardHandlerOptions<T> {
|
|
85
15
|
}
|
|
86
16
|
/**
|
|
87
|
-
*
|
|
88
|
-
* Build on top of [CompressionStream](https://developer.mozilla.org/en-US/docs/Web/API/CompressionStream)
|
|
89
|
-
* You might need to polyfill it if your environment does not support it.
|
|
17
|
+
* OpenAPI Handler for Fetch Server
|
|
90
18
|
*
|
|
91
|
-
* @see {@link https://orpc.unnoq.com/docs/
|
|
19
|
+
* @see {@link https://orpc.unnoq.com/docs/openapi/openapi-handler OpenAPI Handler Docs}
|
|
20
|
+
* @see {@link https://orpc.unnoq.com/docs/adapters/http HTTP Adapter Docs}
|
|
92
21
|
*/
|
|
93
|
-
declare class
|
|
94
|
-
private readonly
|
|
95
|
-
private readonly
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
initRuntimeAdapter(options: FetchHandlerOptions<T>): void;
|
|
22
|
+
declare class FetchHandler<T extends Context> {
|
|
23
|
+
private readonly toFetchResponseOptions;
|
|
24
|
+
private readonly standardHandler;
|
|
25
|
+
constructor(router: Router<T>, options?: NoInfer<FetchHandlerOptions<T>>);
|
|
26
|
+
handle(request: Request, ...rest: MaybeOptionalOptions<FriendlyStandardHandleOptions<T>>): Promise<FetchHandleResult>;
|
|
99
27
|
}
|
|
100
28
|
|
|
101
|
-
export {
|
|
102
|
-
export type {
|
|
29
|
+
export { FetchHandler };
|
|
30
|
+
export type { FetchHandleResult, FetchHandlerOptions };
|
|
@@ -1,171 +1,33 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { resolveMaybeOptionalOptions } from '@temporary-name/shared';
|
|
2
2
|
import { toStandardLazyRequest, toFetchResponse } from '@temporary-name/standard-server-fetch';
|
|
3
|
-
import { r as resolveFriendlyStandardHandleOptions } from '../../shared/server.
|
|
3
|
+
import { S as StandardHandler, r as resolveFriendlyStandardHandleOptions } from '../../shared/server.CYa9puL2.mjs';
|
|
4
4
|
import '@temporary-name/standard-server';
|
|
5
|
-
import '@temporary-name/
|
|
6
|
-
import '
|
|
7
|
-
import
|
|
8
|
-
import '
|
|
9
|
-
import '
|
|
10
|
-
import '
|
|
11
|
-
|
|
12
|
-
class BodyLimitPlugin {
|
|
13
|
-
maxBodySize;
|
|
14
|
-
constructor(options) {
|
|
15
|
-
this.maxBodySize = options.maxBodySize;
|
|
16
|
-
}
|
|
17
|
-
initRuntimeAdapter(options) {
|
|
18
|
-
options.adapterInterceptors ??= [];
|
|
19
|
-
options.adapterInterceptors.push(async (options2) => {
|
|
20
|
-
if (!options2.request.body) {
|
|
21
|
-
return options2.next();
|
|
22
|
-
}
|
|
23
|
-
let currentBodySize = 0;
|
|
24
|
-
const rawReader = options2.request.body.getReader();
|
|
25
|
-
const reader = new ReadableStream({
|
|
26
|
-
start: async (controller) => {
|
|
27
|
-
try {
|
|
28
|
-
if (Number(options2.request.headers.get("content-length")) > this.maxBodySize) {
|
|
29
|
-
controller.error(new ORPCError("PAYLOAD_TOO_LARGE"));
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
while (true) {
|
|
33
|
-
const { done, value } = await rawReader.read();
|
|
34
|
-
if (done) {
|
|
35
|
-
break;
|
|
36
|
-
}
|
|
37
|
-
currentBodySize += value.length;
|
|
38
|
-
if (currentBodySize > this.maxBodySize) {
|
|
39
|
-
controller.error(new ORPCError("PAYLOAD_TOO_LARGE"));
|
|
40
|
-
break;
|
|
41
|
-
}
|
|
42
|
-
controller.enqueue(value);
|
|
43
|
-
}
|
|
44
|
-
} finally {
|
|
45
|
-
controller.close();
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
const requestInit = { body: reader, duplex: "half" };
|
|
50
|
-
return options2.next({
|
|
51
|
-
...options2,
|
|
52
|
-
request: new Request(options2.request, requestInit)
|
|
53
|
-
});
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
const ORDERED_SUPPORTED_ENCODINGS = ["gzip", "deflate"];
|
|
59
|
-
class CompressionPlugin {
|
|
60
|
-
encodings;
|
|
61
|
-
threshold;
|
|
62
|
-
filter;
|
|
63
|
-
constructor(options = {}) {
|
|
64
|
-
this.encodings = options.encodings ?? ORDERED_SUPPORTED_ENCODINGS;
|
|
65
|
-
this.threshold = options.threshold ?? 1024;
|
|
66
|
-
this.filter = (request, response) => {
|
|
67
|
-
const hasContentDisposition = response.headers.has("content-disposition");
|
|
68
|
-
const contentType = response.headers.get("content-type");
|
|
69
|
-
if (!hasContentDisposition && contentType?.startsWith("text/event-stream")) {
|
|
70
|
-
return false;
|
|
71
|
-
}
|
|
72
|
-
return options.filter ? options.filter(request, response) : isCompressibleContentType(contentType);
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
initRuntimeAdapter(options) {
|
|
76
|
-
options.adapterInterceptors ??= [];
|
|
77
|
-
options.adapterInterceptors.unshift(async (options2) => {
|
|
78
|
-
const result = await options2.next();
|
|
79
|
-
if (!result.matched) {
|
|
80
|
-
return result;
|
|
81
|
-
}
|
|
82
|
-
const response = result.response;
|
|
83
|
-
if (response.headers.has("content-encoding") || // already encoded
|
|
84
|
-
response.headers.has("transfer-encoding") || // already encoded or chunked
|
|
85
|
-
isNoTransformCacheControl(response.headers.get("cache-control"))) {
|
|
86
|
-
return result;
|
|
87
|
-
}
|
|
88
|
-
const contentLength = response.headers.get("content-length");
|
|
89
|
-
if (contentLength && Number(contentLength) < this.threshold) {
|
|
90
|
-
return result;
|
|
91
|
-
}
|
|
92
|
-
const acceptEncoding = options2.request.headers.get("accept-encoding")?.split(",").map((enc) => enc.trim().split(";")[0]);
|
|
93
|
-
const encoding = this.encodings.find((enc) => acceptEncoding?.includes(enc));
|
|
94
|
-
if (!response.body || encoding === void 0) {
|
|
95
|
-
return result;
|
|
96
|
-
}
|
|
97
|
-
if (!this.filter(options2.request, response)) {
|
|
98
|
-
return result;
|
|
99
|
-
}
|
|
100
|
-
const compressedBody = response.body.pipeThrough(new CompressionStream(encoding));
|
|
101
|
-
const compressedHeaders = new Headers(response.headers);
|
|
102
|
-
compressedHeaders.delete("content-length");
|
|
103
|
-
compressedHeaders.set("content-encoding", encoding);
|
|
104
|
-
return {
|
|
105
|
-
...result,
|
|
106
|
-
response: new Response(compressedBody, {
|
|
107
|
-
status: response.status,
|
|
108
|
-
statusText: response.statusText,
|
|
109
|
-
headers: compressedHeaders
|
|
110
|
-
})
|
|
111
|
-
};
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
const COMPRESSIBLE_CONTENT_TYPE_REGEX = /^\s*(?:text\/(?!event-stream(?:[;\s]|$))[^;\s]+|application\/(?:javascript|json|xml|xml-dtd|ecmascript|dart|postscript|rtf|tar|toml|vnd\.dart|vnd\.ms-fontobject|vnd\.ms-opentype|wasm|x-httpd-php|x-javascript|x-ns-proxy-autoconfig|x-sh|x-tar|x-virtualbox-hdd|x-virtualbox-ova|x-virtualbox-ovf|x-virtualbox-vbox|x-virtualbox-vdi|x-virtualbox-vhd|x-virtualbox-vmdk|x-www-form-urlencoded)|font\/(?:otf|ttf)|image\/(?:bmp|vnd\.adobe\.photoshop|vnd\.microsoft\.icon|vnd\.ms-dds|x-icon|x-ms-bmp)|message\/rfc822|model\/gltf-binary|x-shader\/x-fragment|x-shader\/x-vertex|[^;\s]+?\+(?:json|text|xml|yaml))(?:[;\s]|$)/i;
|
|
116
|
-
function isCompressibleContentType(contentType) {
|
|
117
|
-
if (contentType === null) {
|
|
118
|
-
return false;
|
|
119
|
-
}
|
|
120
|
-
return COMPRESSIBLE_CONTENT_TYPE_REGEX.test(contentType);
|
|
121
|
-
}
|
|
122
|
-
const CACHE_CONTROL_NO_TRANSFORM_REGEX = /(?:^|,)\s*no-transform\s*(?:,|$)/i;
|
|
123
|
-
function isNoTransformCacheControl(cacheControl) {
|
|
124
|
-
if (cacheControl === null) {
|
|
125
|
-
return false;
|
|
126
|
-
}
|
|
127
|
-
return CACHE_CONTROL_NO_TRANSFORM_REGEX.test(cacheControl);
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
class CompositeFetchHandlerPlugin extends CompositeStandardHandlerPlugin {
|
|
131
|
-
initRuntimeAdapter(options) {
|
|
132
|
-
for (const plugin of this.plugins) {
|
|
133
|
-
plugin.initRuntimeAdapter?.(options);
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
}
|
|
5
|
+
import '@temporary-name/server';
|
|
6
|
+
import 'rou3';
|
|
7
|
+
import '../../shared/server.Cza0RB3u.mjs';
|
|
8
|
+
import '@temporary-name/zod';
|
|
9
|
+
import '../../shared/server.ChOv1yG3.mjs';
|
|
10
|
+
import '../../shared/server.CQIFwyhc.mjs';
|
|
137
11
|
|
|
138
12
|
class FetchHandler {
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
this.adapterInterceptors = toArray(options.adapterInterceptors);
|
|
13
|
+
toFetchResponseOptions;
|
|
14
|
+
standardHandler;
|
|
15
|
+
constructor(router, options = {}) {
|
|
16
|
+
this.standardHandler = new StandardHandler(router, options);
|
|
144
17
|
this.toFetchResponseOptions = options;
|
|
145
18
|
}
|
|
146
|
-
toFetchResponseOptions;
|
|
147
|
-
adapterInterceptors;
|
|
148
19
|
async handle(request, ...rest) {
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
if (!result.matched) {
|
|
160
|
-
return result;
|
|
161
|
-
}
|
|
162
|
-
return {
|
|
163
|
-
matched: true,
|
|
164
|
-
response: toFetchResponse(result.response, toFetchResponseOptions)
|
|
165
|
-
};
|
|
166
|
-
}
|
|
167
|
-
);
|
|
20
|
+
const options = resolveFriendlyStandardHandleOptions(resolveMaybeOptionalOptions(rest));
|
|
21
|
+
const standardRequest = toStandardLazyRequest(request);
|
|
22
|
+
const result = await this.standardHandler.handle(standardRequest, options);
|
|
23
|
+
if (!result.matched) {
|
|
24
|
+
return result;
|
|
25
|
+
}
|
|
26
|
+
return {
|
|
27
|
+
matched: true,
|
|
28
|
+
response: toFetchResponse(result.response, this.toFetchResponseOptions)
|
|
29
|
+
};
|
|
168
30
|
}
|
|
169
31
|
}
|
|
170
32
|
|
|
171
|
-
export {
|
|
33
|
+
export { FetchHandler };
|
|
@@ -1,77 +1,28 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Interceptor, MaybeOptionalOptions } from '@temporary-name/shared';
|
|
1
|
+
import { MaybeOptionalOptions } from '@temporary-name/shared';
|
|
3
2
|
import { SendStandardResponseOptions, NodeHttpRequest, NodeHttpResponse } from '@temporary-name/standard-server-node';
|
|
4
|
-
import {
|
|
5
|
-
import { FriendlyStandardHandleOptions } from '
|
|
6
|
-
import
|
|
7
|
-
import '@temporary-name/contract';
|
|
8
|
-
import '@temporary-name/standard-server';
|
|
9
|
-
|
|
10
|
-
interface NodeHttpHandlerPlugin<T extends Context> extends StandardHandlerPlugin<T> {
|
|
11
|
-
initRuntimeAdapter?(options: NodeHttpHandlerOptions<T>): void;
|
|
12
|
-
}
|
|
13
|
-
declare class CompositeNodeHttpHandlerPlugin<T extends Context, TPlugin extends NodeHttpHandlerPlugin<T>> extends CompositeStandardHandlerPlugin<T, TPlugin> implements NodeHttpHandlerPlugin<T> {
|
|
14
|
-
initRuntimeAdapter(options: NodeHttpHandlerOptions<T>): void;
|
|
15
|
-
}
|
|
3
|
+
import { C as Context, m as Router } from '../../shared/server.BfraJHay.mjs';
|
|
4
|
+
import { b as StandardHandlerOptions, F as FriendlyStandardHandleOptions } from '../../shared/server.BbUmcWIW.mjs';
|
|
5
|
+
import '@temporary-name/zod';
|
|
16
6
|
|
|
17
7
|
type NodeHttpHandleResult = {
|
|
18
8
|
matched: true;
|
|
19
9
|
} | {
|
|
20
10
|
matched: false;
|
|
21
11
|
};
|
|
22
|
-
interface
|
|
23
|
-
request: NodeHttpRequest;
|
|
24
|
-
response: NodeHttpResponse;
|
|
25
|
-
sendStandardResponseOptions: SendStandardResponseOptions;
|
|
26
|
-
}
|
|
27
|
-
interface NodeHttpHandlerOptions<T extends Context> extends SendStandardResponseOptions {
|
|
28
|
-
adapterInterceptors?: Interceptor<NodeHttpHandlerInterceptorOptions<T>, Promise<NodeHttpHandleResult>>[];
|
|
29
|
-
plugins?: NodeHttpHandlerPlugin<T>[];
|
|
30
|
-
}
|
|
31
|
-
declare class NodeHttpHandler<T extends Context> implements NodeHttpHandler<T> {
|
|
32
|
-
private readonly standardHandler;
|
|
33
|
-
private readonly sendStandardResponseOptions;
|
|
34
|
-
private readonly adapterInterceptors;
|
|
35
|
-
constructor(standardHandler: StandardHandler<T>, options?: NoInfer<NodeHttpHandlerOptions<T>>);
|
|
36
|
-
handle(request: NodeHttpRequest, response: NodeHttpResponse, ...rest: MaybeOptionalOptions<FriendlyStandardHandleOptions<T>>): Promise<NodeHttpHandleResult>;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
interface BodyLimitPluginOptions {
|
|
40
|
-
/**
|
|
41
|
-
* The maximum size of the body in bytes.
|
|
42
|
-
*/
|
|
43
|
-
maxBodySize: number;
|
|
12
|
+
interface NodeHttpHandlerOptions<T extends Context> extends SendStandardResponseOptions, StandardHandlerOptions<T> {
|
|
44
13
|
}
|
|
45
14
|
/**
|
|
46
|
-
*
|
|
15
|
+
* OpenAPI Handler for Node Server
|
|
47
16
|
*
|
|
48
|
-
* @see {@link https://orpc.unnoq.com/docs/
|
|
17
|
+
* @see {@link https://orpc.unnoq.com/docs/openapi/openapi-handler OpenAPI Handler Docs}
|
|
18
|
+
* @see {@link https://orpc.unnoq.com/docs/adapters/http HTTP Adapter Docs}
|
|
49
19
|
*/
|
|
50
|
-
declare class
|
|
51
|
-
private readonly
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
interface CompressionPluginOptions extends compression.CompressionOptions {
|
|
57
|
-
/**
|
|
58
|
-
* Override the default content-type filter used to determine which responses should be compressed.
|
|
59
|
-
*
|
|
60
|
-
* @warning [Event Iterator](https://orpc.unnoq.com/docs/event-iterator) responses are never compressed, regardless of this filter's return value.
|
|
61
|
-
* @default only responses with compressible content types are compressed.
|
|
62
|
-
*/
|
|
63
|
-
filter?: (req: NodeHttpRequest, res: NodeHttpResponse) => boolean;
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* The Compression Plugin adds response compression to the Node.js HTTP Server.
|
|
67
|
-
*
|
|
68
|
-
* @see {@link https://orpc.unnoq.com/docs/plugins/compression Compression Plugin Docs}
|
|
69
|
-
*/
|
|
70
|
-
declare class CompressionPlugin<T extends Context> implements NodeHttpHandlerPlugin<T> {
|
|
71
|
-
private readonly compressionHandler;
|
|
72
|
-
constructor(options?: CompressionPluginOptions);
|
|
73
|
-
initRuntimeAdapter(options: NodeHttpHandlerOptions<T>): void;
|
|
20
|
+
declare class NodeHttpHandler<T extends Context> implements NodeHttpHandler<T> {
|
|
21
|
+
private readonly sendStandardResponseOptions;
|
|
22
|
+
private readonly standardHandler;
|
|
23
|
+
constructor(router: Router<T>, options?: NoInfer<NodeHttpHandlerOptions<T>>);
|
|
24
|
+
handle(request: NodeHttpRequest, response: NodeHttpResponse, ...rest: MaybeOptionalOptions<FriendlyStandardHandleOptions<T>>): Promise<NodeHttpHandleResult>;
|
|
74
25
|
}
|
|
75
26
|
|
|
76
|
-
export {
|
|
77
|
-
export type {
|
|
27
|
+
export { NodeHttpHandler };
|
|
28
|
+
export type { NodeHttpHandleResult, NodeHttpHandlerOptions };
|