@orpc/server 2.0.0-beta.35 → 2.0.0-beta.37
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/README.md +29 -20
- package/dist/adapters/aws-lambda/index.d.mts +6 -49
- package/dist/adapters/aws-lambda/index.d.ts +6 -49
- package/dist/adapters/aws-lambda/index.mjs +13 -40
- package/dist/adapters/crossws/index.d.mts +2 -2
- package/dist/adapters/crossws/index.d.ts +2 -2
- package/dist/adapters/crossws/index.mjs +4 -3
- package/dist/adapters/fastify/index.d.mts +6 -49
- package/dist/adapters/fastify/index.d.ts +6 -49
- package/dist/adapters/fastify/index.mjs +13 -40
- package/dist/adapters/fetch/index.d.mts +7 -49
- package/dist/adapters/fetch/index.d.ts +7 -49
- package/dist/adapters/fetch/index.mjs +15 -41
- package/dist/adapters/message-port/index.d.mts +3 -3
- package/dist/adapters/message-port/index.d.ts +3 -3
- package/dist/adapters/message-port/index.mjs +4 -3
- package/dist/adapters/node/index.d.mts +7 -50
- package/dist/adapters/node/index.d.ts +7 -50
- package/dist/adapters/node/index.mjs +13 -40
- package/dist/adapters/standard/index.d.mts +91 -17
- package/dist/adapters/standard/index.d.ts +91 -17
- package/dist/adapters/standard/index.mjs +2 -2
- package/dist/adapters/standard-peer/index.d.mts +4 -9
- package/dist/adapters/standard-peer/index.d.ts +4 -9
- package/dist/adapters/standard-peer/index.mjs +10 -2
- package/dist/adapters/websocket/index.d.mts +3 -3
- package/dist/adapters/websocket/index.d.ts +3 -3
- package/dist/adapters/websocket/index.mjs +4 -3
- package/dist/index.mjs +4 -6
- package/dist/plugins/index.d.mts +1 -1
- package/dist/plugins/index.d.ts +1 -1
- package/dist/shared/{server.R0uHWfBo.d.mts → server.B5K1CViq.d.mts} +20 -9
- package/dist/shared/{server.BYnwk7Xz.mjs → server.BynNaBBA.mjs} +7 -9
- package/dist/shared/{server.sNWd6DAG.mjs → server.C0lFtoHU.mjs} +72 -11
- package/dist/shared/{server.CAiLRqPf.d.mts → server.C7xllBNN.d.mts} +1 -1
- package/dist/shared/server.CFqSIFnT.d.mts +14 -0
- package/dist/shared/{server.DEeCcNd6.d.ts → server.Cxranw-8.d.ts} +20 -9
- package/dist/shared/{server.b2-J4t6T.d.ts → server.D0dr-F8u.d.ts} +1 -1
- package/dist/shared/server.RRVK1xTV.d.ts +14 -0
- package/package.json +10 -10
- package/dist/shared/server.BGMO5dst.d.ts +0 -91
- package/dist/shared/server.CX4vUnDk.mjs +0 -11
- package/dist/shared/server.DcHlvZFK.d.mts +0 -91
package/README.md
CHANGED
|
@@ -46,29 +46,30 @@ You can read the documentation [here](https://orpc.dev).
|
|
|
46
46
|
|
|
47
47
|
**Built-in features**
|
|
48
48
|
|
|
49
|
-
| Package
|
|
50
|
-
|
|
|
51
|
-
| [@orpc/publisher](https://www.npmjs.com/package/@orpc/publisher)
|
|
52
|
-
| [@orpc/ratelimit](https://www.npmjs.com/package/@orpc/ratelimit)
|
|
53
|
-
| [@orpc/
|
|
54
|
-
| [@orpc/
|
|
49
|
+
| Package | Purpose | Docs |
|
|
50
|
+
| -------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------- |
|
|
51
|
+
| [@orpc/publisher](https://www.npmjs.com/package/@orpc/publisher) | Pub/Sub with memory, Redis, and Upstash adapters. | [Publisher](https://orpc.dev/docs/helpers/publisher) |
|
|
52
|
+
| [@orpc/ratelimit](https://www.npmjs.com/package/@orpc/ratelimit) | Rate limiting with memory, Redis, and Upstash adapters. | [Rate Limit](https://orpc.dev/docs/helpers/ratelimit) |
|
|
53
|
+
| [@orpc/experimental-lock](https://www.npmjs.com/package/@orpc/experimental-lock) | Locking with memory, Redis, and Upstash adapters. | [Lock](https://orpc.dev/docs/helpers/lock) |
|
|
54
|
+
| [@orpc/hibernation](https://www.npmjs.com/package/@orpc/hibernation) | Leverage Hibernation APIs like [Cloudflare's Hibernation WebSocket](https://developers.cloudflare.com/durable-objects/best-practices/websockets/#durable-objects-hibernation-websocket-api). | [Hibernation](https://orpc.dev/docs/integrations/hibernation) |
|
|
55
|
+
| [@orpc/json-schema](https://www.npmjs.com/package/@orpc/json-schema) | Smart coercion for OpenAPI requests. | [Smart Coercion](https://orpc.dev/docs/plugins/smart-coercion) |
|
|
55
56
|
|
|
56
57
|
**Framework & ecosystem integrations**
|
|
57
58
|
|
|
58
|
-
| Package | Purpose | Docs
|
|
59
|
-
| ------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------- |
|
|
60
|
-
| [@orpc/next](https://www.npmjs.com/package/@orpc/next) | Integrate with [Next.js Server Functions](https://nextjs.org/docs/app/getting-started/mutating-data). | [Next.js](https://orpc.dev/docs/integrations/next)
|
|
61
|
-
| [@orpc/ai-sdk](https://www.npmjs.com/package/@orpc/ai-sdk) | Turn contracts and procedures into [AI SDK](https://ai-sdk.dev/) tools. | [AI SDK](https://orpc.dev/docs/integrations/ai-sdk)
|
|
62
|
-
| [@orpc/tanstack-query](https://www.npmjs.com/package/@orpc/tanstack-query) | Integrate with [TanStack Query](https://tanstack.com/query/latest). | [TanStack Query](https://orpc.dev/docs/integrations/tanstack-query)
|
|
63
|
-
| [@orpc/pinia-colada](https://www.npmjs.com/package/@orpc/pinia-colada) | Integrate with [Pinia Colada](https://pinia-colada.esm.dev/). | [Pinia Colada](https://orpc.dev/docs/integrations/pinia-colada)
|
|
64
|
-
| [@orpc/swr](https://www.npmjs.com/package/@orpc/swr) | Integrate with [SWR](https://swr.vercel.app/). | [SWR](https://orpc.dev/docs/integrations/swr)
|
|
65
|
-
| [@orpc/experimental-msw](https://www.npmjs.com/package/@orpc/experimental-msw) | Mock procedures with [Mock Service Worker](https://mswjs.io/). | [MSW](https://orpc.dev/docs/integrations/msw)
|
|
66
|
-
| [@orpc/experimental-effect](https://www.npmjs.com/package/@orpc/experimental-effect) | Integrate with [Effect](https://effect.website/). | [Effect](https://orpc.dev/docs/integrations/effect)
|
|
67
|
-
| [@orpc/nest](https://www.npmjs.com/package/@orpc/nest) | Implement your contract with [NestJS](https://nestjs.com/). | [NestJS](https://orpc.dev/docs/integrations/nest)
|
|
68
|
-
| [@orpc/node](https://www.npmjs.com/package/@orpc/node) | [Node.js](https://nodejs.org/) plugins for static file serving and large uploads. | [Static File](https://orpc.dev/docs/plugins/static-file), [Tmp File Upload](https://orpc.dev/docs/plugins/tmp-file-upload), [Batch Response Compression](https://orpc.dev/docs/plugins/batch-response-compression)
|
|
69
|
-
| [@orpc/bun](https://www.npmjs.com/package/@orpc/bun) | Adapters for [Bun's Redis](https://bun.sh/). | [Publisher](https://orpc.dev/docs/helpers/publisher), [Rate Limit](https://orpc.dev/docs/helpers/ratelimit)
|
|
70
|
-
| [@orpc/cloudflare](https://www.npmjs.com/package/@orpc/cloudflare) | Adapters for [Cloudflare Workers](https://developers.cloudflare.com/workers/). | [Publisher](https://orpc.dev/docs/helpers/publisher), [Rate Limit](https://orpc.dev/docs/helpers/ratelimit), [Traces](https://orpc.dev/docs/integrations/cloudflare-traces)
|
|
71
|
-
| [@orpc/trpc](https://www.npmjs.com/package/@orpc/trpc) | Reuse existing [tRPC](https://trpc.io/) routers within oRPC. | [tRPC](https://orpc.dev/docs/integrations/trpc)
|
|
59
|
+
| Package | Purpose | Docs |
|
|
60
|
+
| ------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
61
|
+
| [@orpc/next](https://www.npmjs.com/package/@orpc/next) | Integrate with [Next.js Server Functions](https://nextjs.org/docs/app/getting-started/mutating-data). | [Next.js](https://orpc.dev/docs/integrations/next) |
|
|
62
|
+
| [@orpc/ai-sdk](https://www.npmjs.com/package/@orpc/ai-sdk) | Turn contracts and procedures into [AI SDK](https://ai-sdk.dev/) tools. | [AI SDK](https://orpc.dev/docs/integrations/ai-sdk) |
|
|
63
|
+
| [@orpc/tanstack-query](https://www.npmjs.com/package/@orpc/tanstack-query) | Integrate with [TanStack Query](https://tanstack.com/query/latest). | [TanStack Query](https://orpc.dev/docs/integrations/tanstack-query) |
|
|
64
|
+
| [@orpc/pinia-colada](https://www.npmjs.com/package/@orpc/pinia-colada) | Integrate with [Pinia Colada](https://pinia-colada.esm.dev/). | [Pinia Colada](https://orpc.dev/docs/integrations/pinia-colada) |
|
|
65
|
+
| [@orpc/swr](https://www.npmjs.com/package/@orpc/swr) | Integrate with [SWR](https://swr.vercel.app/). | [SWR](https://orpc.dev/docs/integrations/swr) |
|
|
66
|
+
| [@orpc/experimental-msw](https://www.npmjs.com/package/@orpc/experimental-msw) | Mock procedures with [Mock Service Worker](https://mswjs.io/). | [MSW](https://orpc.dev/docs/integrations/msw) |
|
|
67
|
+
| [@orpc/experimental-effect](https://www.npmjs.com/package/@orpc/experimental-effect) | Integrate with [Effect](https://effect.website/). | [Effect](https://orpc.dev/docs/integrations/effect) |
|
|
68
|
+
| [@orpc/nest](https://www.npmjs.com/package/@orpc/nest) | Implement your contract with [NestJS](https://nestjs.com/). | [NestJS](https://orpc.dev/docs/integrations/nest) |
|
|
69
|
+
| [@orpc/node](https://www.npmjs.com/package/@orpc/node) | [Node.js](https://nodejs.org/) plugins for static file serving and large uploads. | [Static File](https://orpc.dev/docs/plugins/static-file), [Tmp File Upload](https://orpc.dev/docs/plugins/tmp-file-upload), [Batch Response Compression](https://orpc.dev/docs/plugins/batch-response-compression) |
|
|
70
|
+
| [@orpc/bun](https://www.npmjs.com/package/@orpc/bun) | Adapters for [Bun's Redis](https://bun.sh/). | [Publisher](https://orpc.dev/docs/helpers/publisher), [Rate Limit](https://orpc.dev/docs/helpers/ratelimit), [Lock](https://orpc.dev/docs/helpers/lock) |
|
|
71
|
+
| [@orpc/cloudflare](https://www.npmjs.com/package/@orpc/cloudflare) | Adapters for [Cloudflare Workers](https://developers.cloudflare.com/workers/). | [Publisher](https://orpc.dev/docs/helpers/publisher), [Rate Limit](https://orpc.dev/docs/helpers/ratelimit), [Lock](https://orpc.dev/docs/helpers/lock), [Traces](https://orpc.dev/docs/integrations/cloudflare-traces) |
|
|
72
|
+
| [@orpc/trpc](https://www.npmjs.com/package/@orpc/trpc) | Reuse existing [tRPC](https://trpc.io/) routers within oRPC. | [tRPC](https://orpc.dev/docs/integrations/trpc) |
|
|
72
73
|
|
|
73
74
|
**Observability**
|
|
74
75
|
|
|
@@ -94,6 +95,14 @@ Like what we build over at [middleapi](https://github.com/middleapi)? You can he
|
|
|
94
95
|
</tr>
|
|
95
96
|
</table>
|
|
96
97
|
|
|
98
|
+
### Special Sponsors
|
|
99
|
+
|
|
100
|
+
<table>
|
|
101
|
+
<tr>
|
|
102
|
+
<td align="center"><a href="http://twitter.com/rauchg?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Guillermo Rauch"><img src="https://avatars.githubusercontent.com/u/13041?u=1ee8d111657cdd02ff6d253df00978d17ee6d722&v=4" width="279" alt="Guillermo Rauch"/><br />Guillermo Rauch</a></td>
|
|
103
|
+
</tr>
|
|
104
|
+
</table>
|
|
105
|
+
|
|
97
106
|
### Organization Sponsors
|
|
98
107
|
|
|
99
108
|
<table>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { MaybeOptionalOptions } from '@orpc/shared';
|
|
2
2
|
import { SendStandardResponseOptions, AnyAPIGatewayProxyEvent, HttpResponseStream } from '@standard-server/aws-lambda';
|
|
3
3
|
import { Context } from '../../index.mjs';
|
|
4
|
-
import {
|
|
4
|
+
import { StandardHandler, StandardHandlerOptions } from '../standard/index.mjs';
|
|
5
5
|
import { FriendlyStandardHandlerHandleOptions } from '../standard/index.mjs';
|
|
6
6
|
import { Router } from '../../index.mjs';
|
|
7
7
|
import { RPCHandlerCodecOptions } from '../standard/index.mjs';
|
|
@@ -9,58 +9,16 @@ import '@orpc/client';
|
|
|
9
9
|
import '@orpc/contract';
|
|
10
10
|
import '@standard-server/core';
|
|
11
11
|
|
|
12
|
-
interface AwsLambdaHandlerPlugin<T extends Context> extends StandardHandlerPlugin<T> {
|
|
13
|
-
/**
|
|
14
|
-
* Initializes the plugin and returns new AWS Lambda handler options.
|
|
15
|
-
* Called once per plugin instance during composition.
|
|
16
|
-
*
|
|
17
|
-
* This method allows plugins to wrap, extend, or transform AWS Lambda handler options
|
|
18
|
-
* such as interceptors, or other configuration.
|
|
19
|
-
*
|
|
20
|
-
* @param options - The current handler options from previous plugins or base configuration
|
|
21
|
-
* @returns Transformed handler options with plugin's modifications applied
|
|
22
|
-
*
|
|
23
|
-
* @example
|
|
24
|
-
* ```ts
|
|
25
|
-
* initAwsLambdaHandlerOptions(options) {
|
|
26
|
-
* return {
|
|
27
|
-
* ...options,
|
|
28
|
-
* awsLambdaInterceptors: [...(options.awsLambdaInterceptors || []), myInterceptor]
|
|
29
|
-
* }
|
|
30
|
-
* }
|
|
31
|
-
* ```
|
|
32
|
-
*/
|
|
33
|
-
initAwsLambdaHandlerOptions?(options: AwsLambdaHandlerOptions<T>): AwsLambdaHandlerOptions<T>;
|
|
34
|
-
}
|
|
35
|
-
declare class CompositeAwsLambdaHandlerPlugin<T extends Context> implements AwsLambdaHandlerPlugin<T> {
|
|
36
|
-
readonly name = "~composite/aws-lambda";
|
|
37
|
-
protected readonly plugins: AwsLambdaHandlerPlugin<T>[];
|
|
38
|
-
constructor(plugins?: AwsLambdaHandlerPlugin<T>[]);
|
|
39
|
-
initAwsLambdaHandlerOptions(options: AwsLambdaHandlerOptions<T>): AwsLambdaHandlerOptions<T>;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
12
|
type AwsLambdaHandlerHandleResult = {
|
|
43
13
|
matched: true;
|
|
44
14
|
} | {
|
|
45
15
|
matched: false;
|
|
46
16
|
};
|
|
47
|
-
interface
|
|
48
|
-
event: AnyAPIGatewayProxyEvent;
|
|
49
|
-
responseStream: HttpResponseStream;
|
|
50
|
-
sendStandardResponseOptions: SendStandardResponseOptions | undefined;
|
|
51
|
-
}
|
|
52
|
-
type AwsLambdaHandlerAwsLambdaInterceptor<T extends Context> = Interceptor<AwsLambdaHandlerAwsLambdaInterceptorOptions<T>, Promise<AwsLambdaHandlerHandleResult>>;
|
|
53
|
-
interface AwsLambdaHandlerOptions<T extends Context> {
|
|
17
|
+
interface AwsLambdaHandlerOptions<_T extends Context> {
|
|
54
18
|
/**
|
|
55
19
|
* Custom options for `sendStandardResponse`, used to send a `Standard Response`
|
|
56
20
|
*/
|
|
57
21
|
sendStandardResponse?: SendStandardResponseOptions | undefined;
|
|
58
|
-
/**
|
|
59
|
-
* Interceptors that run before the mapping between the Standard API and AWS Lambda API,
|
|
60
|
-
* useful for extending the AWS Lambda event/response stream before handling, ...
|
|
61
|
-
*/
|
|
62
|
-
awsLambdaInterceptors?: AwsLambdaHandlerAwsLambdaInterceptor<T>[] | undefined;
|
|
63
|
-
plugins?: AwsLambdaHandlerPlugin<T>[] | undefined;
|
|
64
22
|
}
|
|
65
23
|
/**
|
|
66
24
|
* Requires the AWS Lambda Node.js runtime with response streaming enabled,
|
|
@@ -69,12 +27,11 @@ interface AwsLambdaHandlerOptions<T extends Context> {
|
|
|
69
27
|
declare class AwsLambdaHandler<T extends Context> {
|
|
70
28
|
private readonly standardHandler;
|
|
71
29
|
private readonly sendStandardResponseOptions;
|
|
72
|
-
private readonly awsLambdaInterceptors;
|
|
73
30
|
constructor(standardHandler: StandardHandler<T>, options?: NoInfer<AwsLambdaHandlerOptions<T>>);
|
|
74
31
|
handle(event: AnyAPIGatewayProxyEvent, responseStream: HttpResponseStream, ...rest: MaybeOptionalOptions<FriendlyStandardHandlerHandleOptions<T>>): Promise<AwsLambdaHandlerHandleResult>;
|
|
75
32
|
}
|
|
76
33
|
|
|
77
|
-
interface RPCHandlerOptions<T extends Context> extends AwsLambdaHandlerOptions<T>,
|
|
34
|
+
interface RPCHandlerOptions<T extends Context> extends AwsLambdaHandlerOptions<T>, StandardHandlerOptions<T>, RPCHandlerCodecOptions<T> {
|
|
78
35
|
}
|
|
79
36
|
/**
|
|
80
37
|
* Serves an oRPC router over the RPC protocol on AWS Lambda,
|
|
@@ -89,5 +46,5 @@ declare class RPCHandler<T extends Context> extends AwsLambdaHandler<T> {
|
|
|
89
46
|
constructor(router: Router<T>, options?: NoInfer<RPCHandlerOptions<T>>);
|
|
90
47
|
}
|
|
91
48
|
|
|
92
|
-
export { AwsLambdaHandler,
|
|
93
|
-
export type {
|
|
49
|
+
export { AwsLambdaHandler, RPCHandler };
|
|
50
|
+
export type { AwsLambdaHandlerHandleResult, AwsLambdaHandlerOptions, RPCHandlerOptions };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { MaybeOptionalOptions } from '@orpc/shared';
|
|
2
2
|
import { SendStandardResponseOptions, AnyAPIGatewayProxyEvent, HttpResponseStream } from '@standard-server/aws-lambda';
|
|
3
3
|
import { Context } from '../../index.js';
|
|
4
|
-
import {
|
|
4
|
+
import { StandardHandler, StandardHandlerOptions } from '../standard/index.js';
|
|
5
5
|
import { FriendlyStandardHandlerHandleOptions } from '../standard/index.js';
|
|
6
6
|
import { Router } from '../../index.js';
|
|
7
7
|
import { RPCHandlerCodecOptions } from '../standard/index.js';
|
|
@@ -9,58 +9,16 @@ import '@orpc/client';
|
|
|
9
9
|
import '@orpc/contract';
|
|
10
10
|
import '@standard-server/core';
|
|
11
11
|
|
|
12
|
-
interface AwsLambdaHandlerPlugin<T extends Context> extends StandardHandlerPlugin<T> {
|
|
13
|
-
/**
|
|
14
|
-
* Initializes the plugin and returns new AWS Lambda handler options.
|
|
15
|
-
* Called once per plugin instance during composition.
|
|
16
|
-
*
|
|
17
|
-
* This method allows plugins to wrap, extend, or transform AWS Lambda handler options
|
|
18
|
-
* such as interceptors, or other configuration.
|
|
19
|
-
*
|
|
20
|
-
* @param options - The current handler options from previous plugins or base configuration
|
|
21
|
-
* @returns Transformed handler options with plugin's modifications applied
|
|
22
|
-
*
|
|
23
|
-
* @example
|
|
24
|
-
* ```ts
|
|
25
|
-
* initAwsLambdaHandlerOptions(options) {
|
|
26
|
-
* return {
|
|
27
|
-
* ...options,
|
|
28
|
-
* awsLambdaInterceptors: [...(options.awsLambdaInterceptors || []), myInterceptor]
|
|
29
|
-
* }
|
|
30
|
-
* }
|
|
31
|
-
* ```
|
|
32
|
-
*/
|
|
33
|
-
initAwsLambdaHandlerOptions?(options: AwsLambdaHandlerOptions<T>): AwsLambdaHandlerOptions<T>;
|
|
34
|
-
}
|
|
35
|
-
declare class CompositeAwsLambdaHandlerPlugin<T extends Context> implements AwsLambdaHandlerPlugin<T> {
|
|
36
|
-
readonly name = "~composite/aws-lambda";
|
|
37
|
-
protected readonly plugins: AwsLambdaHandlerPlugin<T>[];
|
|
38
|
-
constructor(plugins?: AwsLambdaHandlerPlugin<T>[]);
|
|
39
|
-
initAwsLambdaHandlerOptions(options: AwsLambdaHandlerOptions<T>): AwsLambdaHandlerOptions<T>;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
12
|
type AwsLambdaHandlerHandleResult = {
|
|
43
13
|
matched: true;
|
|
44
14
|
} | {
|
|
45
15
|
matched: false;
|
|
46
16
|
};
|
|
47
|
-
interface
|
|
48
|
-
event: AnyAPIGatewayProxyEvent;
|
|
49
|
-
responseStream: HttpResponseStream;
|
|
50
|
-
sendStandardResponseOptions: SendStandardResponseOptions | undefined;
|
|
51
|
-
}
|
|
52
|
-
type AwsLambdaHandlerAwsLambdaInterceptor<T extends Context> = Interceptor<AwsLambdaHandlerAwsLambdaInterceptorOptions<T>, Promise<AwsLambdaHandlerHandleResult>>;
|
|
53
|
-
interface AwsLambdaHandlerOptions<T extends Context> {
|
|
17
|
+
interface AwsLambdaHandlerOptions<_T extends Context> {
|
|
54
18
|
/**
|
|
55
19
|
* Custom options for `sendStandardResponse`, used to send a `Standard Response`
|
|
56
20
|
*/
|
|
57
21
|
sendStandardResponse?: SendStandardResponseOptions | undefined;
|
|
58
|
-
/**
|
|
59
|
-
* Interceptors that run before the mapping between the Standard API and AWS Lambda API,
|
|
60
|
-
* useful for extending the AWS Lambda event/response stream before handling, ...
|
|
61
|
-
*/
|
|
62
|
-
awsLambdaInterceptors?: AwsLambdaHandlerAwsLambdaInterceptor<T>[] | undefined;
|
|
63
|
-
plugins?: AwsLambdaHandlerPlugin<T>[] | undefined;
|
|
64
22
|
}
|
|
65
23
|
/**
|
|
66
24
|
* Requires the AWS Lambda Node.js runtime with response streaming enabled,
|
|
@@ -69,12 +27,11 @@ interface AwsLambdaHandlerOptions<T extends Context> {
|
|
|
69
27
|
declare class AwsLambdaHandler<T extends Context> {
|
|
70
28
|
private readonly standardHandler;
|
|
71
29
|
private readonly sendStandardResponseOptions;
|
|
72
|
-
private readonly awsLambdaInterceptors;
|
|
73
30
|
constructor(standardHandler: StandardHandler<T>, options?: NoInfer<AwsLambdaHandlerOptions<T>>);
|
|
74
31
|
handle(event: AnyAPIGatewayProxyEvent, responseStream: HttpResponseStream, ...rest: MaybeOptionalOptions<FriendlyStandardHandlerHandleOptions<T>>): Promise<AwsLambdaHandlerHandleResult>;
|
|
75
32
|
}
|
|
76
33
|
|
|
77
|
-
interface RPCHandlerOptions<T extends Context> extends AwsLambdaHandlerOptions<T>,
|
|
34
|
+
interface RPCHandlerOptions<T extends Context> extends AwsLambdaHandlerOptions<T>, StandardHandlerOptions<T>, RPCHandlerCodecOptions<T> {
|
|
78
35
|
}
|
|
79
36
|
/**
|
|
80
37
|
* Serves an oRPC router over the RPC protocol on AWS Lambda,
|
|
@@ -89,5 +46,5 @@ declare class RPCHandler<T extends Context> extends AwsLambdaHandler<T> {
|
|
|
89
46
|
constructor(router: Router<T>, options?: NoInfer<RPCHandlerOptions<T>>);
|
|
90
47
|
}
|
|
91
48
|
|
|
92
|
-
export { AwsLambdaHandler,
|
|
93
|
-
export type {
|
|
49
|
+
export { AwsLambdaHandler, RPCHandler };
|
|
50
|
+
export type { AwsLambdaHandlerHandleResult, AwsLambdaHandlerOptions, RPCHandlerOptions };
|
|
@@ -1,57 +1,30 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { resolveMaybeOptionalOptions } from '@orpc/shared';
|
|
2
2
|
import { toStandardLazyRequest, sendStandardResponse } from '@standard-server/aws-lambda';
|
|
3
3
|
import { r as resolveFriendlyStandardHandlerHandleOptions } from '../../shared/server.W91HSRkE.mjs';
|
|
4
|
-
import { R as RPCHandlerCodec, S as StandardHandler } from '../../shared/server.
|
|
4
|
+
import { R as RPCHandlerCodec, S as StandardHandler } from '../../shared/server.C0lFtoHU.mjs';
|
|
5
5
|
import '@orpc/client';
|
|
6
6
|
import '@standard-server/core';
|
|
7
7
|
import '../../shared/server.Djb_ebJT.mjs';
|
|
8
8
|
import '@orpc/contract';
|
|
9
|
-
import '../../shared/server.
|
|
10
|
-
|
|
11
|
-
class CompositeAwsLambdaHandlerPlugin {
|
|
12
|
-
name = "~composite/aws-lambda";
|
|
13
|
-
plugins;
|
|
14
|
-
constructor(plugins = []) {
|
|
15
|
-
this.plugins = sortPlugins(plugins);
|
|
16
|
-
}
|
|
17
|
-
initAwsLambdaHandlerOptions(options) {
|
|
18
|
-
for (const plugin of this.plugins) {
|
|
19
|
-
if (plugin.initAwsLambdaHandlerOptions) {
|
|
20
|
-
options = plugin.initAwsLambdaHandlerOptions(options);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
return options;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
9
|
+
import '../../shared/server.BynNaBBA.mjs';
|
|
26
10
|
|
|
27
11
|
class AwsLambdaHandler {
|
|
28
12
|
constructor(standardHandler, options = {}) {
|
|
29
13
|
this.standardHandler = standardHandler;
|
|
30
|
-
options = new CompositeAwsLambdaHandlerPlugin(options.plugins).initAwsLambdaHandlerOptions(options);
|
|
31
|
-
this.awsLambdaInterceptors = options.awsLambdaInterceptors;
|
|
32
14
|
this.sendStandardResponseOptions = options.sendStandardResponse;
|
|
33
15
|
}
|
|
34
16
|
sendStandardResponseOptions;
|
|
35
|
-
awsLambdaInterceptors;
|
|
36
17
|
async handle(event, responseStream, ...rest) {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
event,
|
|
42
|
-
responseStream,
|
|
43
|
-
sendStandardResponseOptions: this.sendStandardResponseOptions
|
|
44
|
-
},
|
|
45
|
-
async ({ event: event2, responseStream: responseStream2, sendStandardResponseOptions, ...options }) => {
|
|
46
|
-
const standardRequest = toStandardLazyRequest(event2, responseStream2);
|
|
47
|
-
const result = await this.standardHandler.handle(standardRequest, options);
|
|
48
|
-
if (!result.matched) {
|
|
49
|
-
return result;
|
|
50
|
-
}
|
|
51
|
-
await sendStandardResponse(responseStream2, result.response, sendStandardResponseOptions);
|
|
52
|
-
return result;
|
|
53
|
-
}
|
|
18
|
+
const standardRequest = toStandardLazyRequest(event, responseStream);
|
|
19
|
+
const result = await this.standardHandler.handle(
|
|
20
|
+
standardRequest,
|
|
21
|
+
resolveFriendlyStandardHandlerHandleOptions(resolveMaybeOptionalOptions(rest))
|
|
54
22
|
);
|
|
23
|
+
if (!result.matched) {
|
|
24
|
+
return result;
|
|
25
|
+
}
|
|
26
|
+
await sendStandardResponse(responseStream, result.response, this.sendStandardResponseOptions);
|
|
27
|
+
return result;
|
|
55
28
|
}
|
|
56
29
|
}
|
|
57
30
|
|
|
@@ -63,4 +36,4 @@ class RPCHandler extends AwsLambdaHandler {
|
|
|
63
36
|
}
|
|
64
37
|
}
|
|
65
38
|
|
|
66
|
-
export { AwsLambdaHandler,
|
|
39
|
+
export { AwsLambdaHandler, RPCHandler };
|
|
@@ -3,7 +3,7 @@ import { EncodePeerMessageOptions, DecodePeerMessageOptions } from '@standard-se
|
|
|
3
3
|
import { Message, Peer } from 'crossws';
|
|
4
4
|
import { Context } from '../../index.mjs';
|
|
5
5
|
import { StandardHandler, StandardHandlerOptions } from '../standard/index.mjs';
|
|
6
|
-
import {
|
|
6
|
+
import { FriendlyStandardHandlerHandleOptions } from '../standard/index.mjs';
|
|
7
7
|
import { Router } from '../../index.mjs';
|
|
8
8
|
import { RPCHandlerCodecOptions } from '../standard/index.mjs';
|
|
9
9
|
import '@orpc/client';
|
|
@@ -36,7 +36,7 @@ declare class experimental_CrosswsHandler<T extends Context> {
|
|
|
36
36
|
*
|
|
37
37
|
* @param ws The crossws peer instance. Use the same instance for all messages.
|
|
38
38
|
*/
|
|
39
|
-
message(ws: CrosswsPeerLike, message: CrosswsMessageLike, ...rest: MaybeOptionalOptions<
|
|
39
|
+
message(ws: CrosswsPeerLike, message: CrosswsMessageLike, ...rest: MaybeOptionalOptions<FriendlyStandardHandlerHandleOptions<T>>): Promise<{
|
|
40
40
|
matched: boolean;
|
|
41
41
|
}>;
|
|
42
42
|
/**
|
|
@@ -3,7 +3,7 @@ import { EncodePeerMessageOptions, DecodePeerMessageOptions } from '@standard-se
|
|
|
3
3
|
import { Message, Peer } from 'crossws';
|
|
4
4
|
import { Context } from '../../index.js';
|
|
5
5
|
import { StandardHandler, StandardHandlerOptions } from '../standard/index.js';
|
|
6
|
-
import {
|
|
6
|
+
import { FriendlyStandardHandlerHandleOptions } from '../standard/index.js';
|
|
7
7
|
import { Router } from '../../index.js';
|
|
8
8
|
import { RPCHandlerCodecOptions } from '../standard/index.js';
|
|
9
9
|
import '@orpc/client';
|
|
@@ -36,7 +36,7 @@ declare class experimental_CrosswsHandler<T extends Context> {
|
|
|
36
36
|
*
|
|
37
37
|
* @param ws The crossws peer instance. Use the same instance for all messages.
|
|
38
38
|
*/
|
|
39
|
-
message(ws: CrosswsPeerLike, message: CrosswsMessageLike, ...rest: MaybeOptionalOptions<
|
|
39
|
+
message(ws: CrosswsPeerLike, message: CrosswsMessageLike, ...rest: MaybeOptionalOptions<FriendlyStandardHandlerHandleOptions<T>>): Promise<{
|
|
40
40
|
matched: boolean;
|
|
41
41
|
}>;
|
|
42
42
|
/**
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { resolveMaybeOptionalOptions } from '@orpc/shared';
|
|
2
2
|
import { ServerPeer, encodePeerMessage, decodePeerMessage, isClientPeerSendMessage } from '@standard-server/peer';
|
|
3
|
-
import {
|
|
4
|
-
import { R as RPCHandlerCodec, S as StandardHandler } from '../../shared/server.
|
|
3
|
+
import { createStandardPeerRequestHandler } from '../standard-peer/index.mjs';
|
|
4
|
+
import { R as RPCHandlerCodec, S as StandardHandler } from '../../shared/server.C0lFtoHU.mjs';
|
|
5
|
+
import '../../shared/server.W91HSRkE.mjs';
|
|
5
6
|
import '@orpc/client';
|
|
6
7
|
import '@standard-server/core';
|
|
7
8
|
import '../../shared/server.Djb_ebJT.mjs';
|
|
8
9
|
import '@orpc/contract';
|
|
9
|
-
import '../../shared/server.
|
|
10
|
+
import '../../shared/server.BynNaBBA.mjs';
|
|
10
11
|
|
|
11
12
|
class experimental_CrosswsHandler {
|
|
12
13
|
constructor(handler, options = {}) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { MaybeOptionalOptions } from '@orpc/shared';
|
|
2
2
|
import { SendStandardResponseOptions, AnyFastifyRequest, AnyFastifyReply } from '@standard-server/fastify';
|
|
3
3
|
import { Context } from '../../index.mjs';
|
|
4
|
-
import {
|
|
4
|
+
import { StandardHandler, StandardHandlerOptions } from '../standard/index.mjs';
|
|
5
5
|
import { FriendlyStandardHandlerHandleOptions } from '../standard/index.mjs';
|
|
6
6
|
import { Router } from '../../index.mjs';
|
|
7
7
|
import { RPCHandlerCodecOptions } from '../standard/index.mjs';
|
|
@@ -9,68 +9,25 @@ import '@orpc/client';
|
|
|
9
9
|
import '@orpc/contract';
|
|
10
10
|
import '@standard-server/core';
|
|
11
11
|
|
|
12
|
-
interface FastifyHandlerPlugin<T extends Context> extends StandardHandlerPlugin<T> {
|
|
13
|
-
/**
|
|
14
|
-
* Initializes the plugin and returns new Fastify handler options.
|
|
15
|
-
* Called once per plugin instance during composition.
|
|
16
|
-
*
|
|
17
|
-
* This method allows plugins to wrap, extend, or transform Fastify handler options
|
|
18
|
-
* such as interceptors, or other configuration.
|
|
19
|
-
*
|
|
20
|
-
* @param options - The current handler options from previous plugins or base configuration
|
|
21
|
-
* @returns Transformed handler options with plugin's modifications applied
|
|
22
|
-
*
|
|
23
|
-
* @example
|
|
24
|
-
* ```ts
|
|
25
|
-
* initFastifyHandlerOptions(options) {
|
|
26
|
-
* return {
|
|
27
|
-
* ...options,
|
|
28
|
-
* fastifyInterceptors: [...(options.fastifyInterceptors || []), myInterceptor]
|
|
29
|
-
* }
|
|
30
|
-
* }
|
|
31
|
-
* ```
|
|
32
|
-
*/
|
|
33
|
-
initFastifyHandlerOptions?(options: FastifyHandlerOptions<T>): FastifyHandlerOptions<T>;
|
|
34
|
-
}
|
|
35
|
-
declare class CompositeFastifyHandlerPlugin<T extends Context> implements FastifyHandlerPlugin<T> {
|
|
36
|
-
readonly name = "~composite/fastify";
|
|
37
|
-
protected readonly plugins: FastifyHandlerPlugin<T>[];
|
|
38
|
-
constructor(plugins?: FastifyHandlerPlugin<T>[]);
|
|
39
|
-
initFastifyHandlerOptions(options: FastifyHandlerOptions<T>): FastifyHandlerOptions<T>;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
12
|
type FastifyHandlerHandleResult = {
|
|
43
13
|
matched: true;
|
|
44
14
|
} | {
|
|
45
15
|
matched: false;
|
|
46
16
|
};
|
|
47
|
-
interface
|
|
48
|
-
request: AnyFastifyRequest;
|
|
49
|
-
reply: AnyFastifyReply;
|
|
50
|
-
sendStandardResponseOptions: SendStandardResponseOptions | undefined;
|
|
51
|
-
}
|
|
52
|
-
type FastifyHandlerFastifyInterceptor<T extends Context> = Interceptor<FastifyHandlerFastifyInterceptorOptions<T>, Promise<FastifyHandlerHandleResult>>;
|
|
53
|
-
interface FastifyHandlerOptions<T extends Context> {
|
|
17
|
+
interface FastifyHandlerOptions<_T extends Context> {
|
|
54
18
|
/**
|
|
55
19
|
* Custom options for `sendStandardResponse`, used to send a `Standard Response`
|
|
56
20
|
*/
|
|
57
21
|
sendStandardResponse?: SendStandardResponseOptions | undefined;
|
|
58
|
-
/**
|
|
59
|
-
* Interceptors that run before the mapping between the Standard API and Fastify API,
|
|
60
|
-
* useful for extending the Fastify request/reply before handling, ...
|
|
61
|
-
*/
|
|
62
|
-
fastifyInterceptors?: FastifyHandlerFastifyInterceptor<T>[] | undefined;
|
|
63
|
-
plugins?: FastifyHandlerPlugin<T>[] | undefined;
|
|
64
22
|
}
|
|
65
23
|
declare class FastifyHandler<T extends Context> {
|
|
66
24
|
private readonly standardHandler;
|
|
67
25
|
private readonly sendStandardResponseOptions;
|
|
68
|
-
private readonly fastifyInterceptors;
|
|
69
26
|
constructor(standardHandler: StandardHandler<T>, options?: NoInfer<FastifyHandlerOptions<T>>);
|
|
70
27
|
handle(request: AnyFastifyRequest, reply: AnyFastifyReply, ...rest: MaybeOptionalOptions<FriendlyStandardHandlerHandleOptions<T>>): Promise<FastifyHandlerHandleResult>;
|
|
71
28
|
}
|
|
72
29
|
|
|
73
|
-
interface RPCHandlerOptions<T extends Context> extends FastifyHandlerOptions<T>,
|
|
30
|
+
interface RPCHandlerOptions<T extends Context> extends FastifyHandlerOptions<T>, StandardHandlerOptions<T>, RPCHandlerCodecOptions<T> {
|
|
74
31
|
}
|
|
75
32
|
/**
|
|
76
33
|
* Serves an oRPC router over the RPC protocol inside a Fastify server.
|
|
@@ -81,5 +38,5 @@ declare class RPCHandler<T extends Context> extends FastifyHandler<T> {
|
|
|
81
38
|
constructor(router: Router<T>, options?: NoInfer<RPCHandlerOptions<T>>);
|
|
82
39
|
}
|
|
83
40
|
|
|
84
|
-
export {
|
|
85
|
-
export type {
|
|
41
|
+
export { FastifyHandler, RPCHandler };
|
|
42
|
+
export type { FastifyHandlerHandleResult, FastifyHandlerOptions, RPCHandlerOptions };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { MaybeOptionalOptions } from '@orpc/shared';
|
|
2
2
|
import { SendStandardResponseOptions, AnyFastifyRequest, AnyFastifyReply } from '@standard-server/fastify';
|
|
3
3
|
import { Context } from '../../index.js';
|
|
4
|
-
import {
|
|
4
|
+
import { StandardHandler, StandardHandlerOptions } from '../standard/index.js';
|
|
5
5
|
import { FriendlyStandardHandlerHandleOptions } from '../standard/index.js';
|
|
6
6
|
import { Router } from '../../index.js';
|
|
7
7
|
import { RPCHandlerCodecOptions } from '../standard/index.js';
|
|
@@ -9,68 +9,25 @@ import '@orpc/client';
|
|
|
9
9
|
import '@orpc/contract';
|
|
10
10
|
import '@standard-server/core';
|
|
11
11
|
|
|
12
|
-
interface FastifyHandlerPlugin<T extends Context> extends StandardHandlerPlugin<T> {
|
|
13
|
-
/**
|
|
14
|
-
* Initializes the plugin and returns new Fastify handler options.
|
|
15
|
-
* Called once per plugin instance during composition.
|
|
16
|
-
*
|
|
17
|
-
* This method allows plugins to wrap, extend, or transform Fastify handler options
|
|
18
|
-
* such as interceptors, or other configuration.
|
|
19
|
-
*
|
|
20
|
-
* @param options - The current handler options from previous plugins or base configuration
|
|
21
|
-
* @returns Transformed handler options with plugin's modifications applied
|
|
22
|
-
*
|
|
23
|
-
* @example
|
|
24
|
-
* ```ts
|
|
25
|
-
* initFastifyHandlerOptions(options) {
|
|
26
|
-
* return {
|
|
27
|
-
* ...options,
|
|
28
|
-
* fastifyInterceptors: [...(options.fastifyInterceptors || []), myInterceptor]
|
|
29
|
-
* }
|
|
30
|
-
* }
|
|
31
|
-
* ```
|
|
32
|
-
*/
|
|
33
|
-
initFastifyHandlerOptions?(options: FastifyHandlerOptions<T>): FastifyHandlerOptions<T>;
|
|
34
|
-
}
|
|
35
|
-
declare class CompositeFastifyHandlerPlugin<T extends Context> implements FastifyHandlerPlugin<T> {
|
|
36
|
-
readonly name = "~composite/fastify";
|
|
37
|
-
protected readonly plugins: FastifyHandlerPlugin<T>[];
|
|
38
|
-
constructor(plugins?: FastifyHandlerPlugin<T>[]);
|
|
39
|
-
initFastifyHandlerOptions(options: FastifyHandlerOptions<T>): FastifyHandlerOptions<T>;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
12
|
type FastifyHandlerHandleResult = {
|
|
43
13
|
matched: true;
|
|
44
14
|
} | {
|
|
45
15
|
matched: false;
|
|
46
16
|
};
|
|
47
|
-
interface
|
|
48
|
-
request: AnyFastifyRequest;
|
|
49
|
-
reply: AnyFastifyReply;
|
|
50
|
-
sendStandardResponseOptions: SendStandardResponseOptions | undefined;
|
|
51
|
-
}
|
|
52
|
-
type FastifyHandlerFastifyInterceptor<T extends Context> = Interceptor<FastifyHandlerFastifyInterceptorOptions<T>, Promise<FastifyHandlerHandleResult>>;
|
|
53
|
-
interface FastifyHandlerOptions<T extends Context> {
|
|
17
|
+
interface FastifyHandlerOptions<_T extends Context> {
|
|
54
18
|
/**
|
|
55
19
|
* Custom options for `sendStandardResponse`, used to send a `Standard Response`
|
|
56
20
|
*/
|
|
57
21
|
sendStandardResponse?: SendStandardResponseOptions | undefined;
|
|
58
|
-
/**
|
|
59
|
-
* Interceptors that run before the mapping between the Standard API and Fastify API,
|
|
60
|
-
* useful for extending the Fastify request/reply before handling, ...
|
|
61
|
-
*/
|
|
62
|
-
fastifyInterceptors?: FastifyHandlerFastifyInterceptor<T>[] | undefined;
|
|
63
|
-
plugins?: FastifyHandlerPlugin<T>[] | undefined;
|
|
64
22
|
}
|
|
65
23
|
declare class FastifyHandler<T extends Context> {
|
|
66
24
|
private readonly standardHandler;
|
|
67
25
|
private readonly sendStandardResponseOptions;
|
|
68
|
-
private readonly fastifyInterceptors;
|
|
69
26
|
constructor(standardHandler: StandardHandler<T>, options?: NoInfer<FastifyHandlerOptions<T>>);
|
|
70
27
|
handle(request: AnyFastifyRequest, reply: AnyFastifyReply, ...rest: MaybeOptionalOptions<FriendlyStandardHandlerHandleOptions<T>>): Promise<FastifyHandlerHandleResult>;
|
|
71
28
|
}
|
|
72
29
|
|
|
73
|
-
interface RPCHandlerOptions<T extends Context> extends FastifyHandlerOptions<T>,
|
|
30
|
+
interface RPCHandlerOptions<T extends Context> extends FastifyHandlerOptions<T>, StandardHandlerOptions<T>, RPCHandlerCodecOptions<T> {
|
|
74
31
|
}
|
|
75
32
|
/**
|
|
76
33
|
* Serves an oRPC router over the RPC protocol inside a Fastify server.
|
|
@@ -81,5 +38,5 @@ declare class RPCHandler<T extends Context> extends FastifyHandler<T> {
|
|
|
81
38
|
constructor(router: Router<T>, options?: NoInfer<RPCHandlerOptions<T>>);
|
|
82
39
|
}
|
|
83
40
|
|
|
84
|
-
export {
|
|
85
|
-
export type {
|
|
41
|
+
export { FastifyHandler, RPCHandler };
|
|
42
|
+
export type { FastifyHandlerHandleResult, FastifyHandlerOptions, RPCHandlerOptions };
|