@orpc/nest 0.0.0-next.cff2b1a → 0.0.0-next.d12598b
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 +12 -7
- package/dist/index.d.mts +45 -11
- package/dist/index.d.ts +45 -11
- package/dist/index.mjs +66 -41
- package/package.json +22 -20
package/README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<div align="center">
|
|
2
|
-
<image align="center" src="https://orpc.
|
|
2
|
+
<image align="center" src="https://orpc.dev/logo.webp" width=280 alt="oRPC logo" />
|
|
3
3
|
</div>
|
|
4
4
|
|
|
5
5
|
<h1></h1>
|
|
@@ -17,6 +17,9 @@
|
|
|
17
17
|
<a href="https://discord.gg/TXEbwRBvQn">
|
|
18
18
|
<img alt="Discord" src="https://img.shields.io/discord/1308966753044398161?color=7389D8&label&logo=discord&logoColor=ffffff" />
|
|
19
19
|
</a>
|
|
20
|
+
<a href="https://deepwiki.com/unnoq/orpc">
|
|
21
|
+
<img src="https://deepwiki.com/badge.svg" alt="Ask DeepWiki">
|
|
22
|
+
</a>
|
|
20
23
|
</div>
|
|
21
24
|
|
|
22
25
|
<h3 align="center">Typesafe APIs Made Simple 🪄</h3>
|
|
@@ -30,7 +33,8 @@
|
|
|
30
33
|
- **🔗 End-to-End Type Safety**: Ensure type-safe inputs, outputs, and errors from client to server.
|
|
31
34
|
- **📘 First-Class OpenAPI**: Built-in support that fully adheres to the OpenAPI standard.
|
|
32
35
|
- **📝 Contract-First Development**: Optionally define your API contract before implementation.
|
|
33
|
-
-
|
|
36
|
+
- **🔍 First-Class OpenTelemetry**: Seamlessly integrate with OpenTelemetry for observability.
|
|
37
|
+
- **⚙️ Framework Integrations**: Seamlessly integrate with TanStack Query (React, Vue, Solid, Svelte, Angular), SWR, Pinia Colada, and more.
|
|
34
38
|
- **🚀 Server Actions**: Fully compatible with React Server Actions on Next.js, TanStack Start, and other platforms.
|
|
35
39
|
- **🔠 Standard Schema Support**: Works out of the box with Zod, Valibot, ArkType, and other schema validators.
|
|
36
40
|
- **🗃️ Native Types**: Supports native types like Date, File, Blob, BigInt, URL, and more.
|
|
@@ -38,11 +42,10 @@
|
|
|
38
42
|
- **📡 SSE & Streaming**: Enjoy full type-safe support for SSE and streaming.
|
|
39
43
|
- **🌍 Multi-Runtime Support**: Fast and lightweight on Cloudflare, Deno, Bun, Node.js, and beyond.
|
|
40
44
|
- **🔌 Extendability**: Easily extend functionality with plugins, middleware, and interceptors.
|
|
41
|
-
- **🛡️ Reliability**: Well-tested, TypeScript-based, production-ready, and MIT licensed.
|
|
42
45
|
|
|
43
46
|
## Documentation
|
|
44
47
|
|
|
45
|
-
You can find the full documentation [here](https://orpc.
|
|
48
|
+
You can find the full documentation [here](https://orpc.dev).
|
|
46
49
|
|
|
47
50
|
## Packages
|
|
48
51
|
|
|
@@ -50,9 +53,11 @@ You can find the full documentation [here](https://orpc.unnoq.com).
|
|
|
50
53
|
- [@orpc/server](https://www.npmjs.com/package/@orpc/server): Build your API or implement API contract.
|
|
51
54
|
- [@orpc/client](https://www.npmjs.com/package/@orpc/client): Consume your API on the client with type-safety.
|
|
52
55
|
- [@orpc/openapi](https://www.npmjs.com/package/@orpc/openapi): Generate OpenAPI specs and handle OpenAPI requests.
|
|
56
|
+
- [@orpc/otel](https://www.npmjs.com/package/@orpc/otel): [OpenTelemetry](https://opentelemetry.io/) integration for observability.
|
|
53
57
|
- [@orpc/nest](https://www.npmjs.com/package/@orpc/nest): Deeply integrate oRPC with [NestJS](https://nestjs.com/).
|
|
54
58
|
- [@orpc/react](https://www.npmjs.com/package/@orpc/react): Utilities for integrating oRPC with React and React Server Actions.
|
|
55
59
|
- [@orpc/tanstack-query](https://www.npmjs.com/package/@orpc/tanstack-query): [TanStack Query](https://tanstack.com/query/latest) integration.
|
|
60
|
+
- [@orpc/experimental-react-swr](https://www.npmjs.com/package/@orpc/experimental-react-swr): [SWR](https://swr.vercel.app/) integration.
|
|
56
61
|
- [@orpc/vue-colada](https://www.npmjs.com/package/@orpc/vue-colada): Integration with [Pinia Colada](https://pinia-colada.esm.dev/).
|
|
57
62
|
- [@orpc/hey-api](https://www.npmjs.com/package/@orpc/hey-api): [Hey API](https://heyapi.dev/) integration.
|
|
58
63
|
- [@orpc/zod](https://www.npmjs.com/package/@orpc/zod): More schemas that [Zod](https://zod.dev/) doesn't support yet.
|
|
@@ -61,11 +66,11 @@ You can find the full documentation [here](https://orpc.unnoq.com).
|
|
|
61
66
|
|
|
62
67
|
## `@orpc/nest`
|
|
63
68
|
|
|
64
|
-
Deeply integrate oRPC with [NestJS](https://nestjs.com/). Read the [documentation](https://orpc.
|
|
69
|
+
Deeply integrate oRPC with [NestJS](https://nestjs.com/). Read the [documentation](https://orpc.dev/docs/openapi/integrations/implement-contract-in-nest) for more information.
|
|
65
70
|
|
|
66
71
|
### Implement Contract
|
|
67
72
|
|
|
68
|
-
An overview of how to implement an [oRPC contract](https://orpc.
|
|
73
|
+
An overview of how to implement an [oRPC contract](https://orpc.dev/docs/contract-first/define-contract) in NestJS.
|
|
69
74
|
|
|
70
75
|
```ts
|
|
71
76
|
import { Implement, implement, ORPCError } from '@orpc/nest'
|
|
@@ -85,7 +90,7 @@ export class PlanetController {
|
|
|
85
90
|
}
|
|
86
91
|
|
|
87
92
|
/**
|
|
88
|
-
* Implement entire
|
|
93
|
+
* Implement entire contract
|
|
89
94
|
*/
|
|
90
95
|
@Implement(contract.planet)
|
|
91
96
|
planet() {
|
package/dist/index.d.mts
CHANGED
|
@@ -1,26 +1,55 @@
|
|
|
1
|
-
import { DynamicModule, NestInterceptor, ExecutionContext, CallHandler } from '@nestjs/common';
|
|
2
1
|
import { AnySchema, ContractRouter, HTTPPath, AnyContractRouter, ContractProcedure } from '@orpc/contract';
|
|
3
|
-
import { CreateProcedureClientOptions, Router } from '@orpc/server';
|
|
4
|
-
export { ImplementedProcedure, Implementer, ImplementerInternal, ImplementerInternalWithMiddlewares, ORPCError, ProcedureImplementer, RouterImplementer, RouterImplementerWithMiddlewares,
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
2
|
+
import { CreateProcedureClientOptions, Router, Context, BuilderConfig, Implementer } from '@orpc/server';
|
|
3
|
+
export { ImplementedProcedure, Implementer, ImplementerInternal, ImplementerInternalWithMiddlewares, ORPCError, ProcedureImplementer, RouterImplementer, RouterImplementerWithMiddlewares, onError, onFinish, onStart, onSuccess } from '@orpc/server';
|
|
4
|
+
import { DynamicModule, NestInterceptor, ExecutionContext, CallHandler } from '@nestjs/common';
|
|
5
|
+
import { StandardOpenAPIJsonSerializerOptions, StandardBracketNotationSerializerOptions } from '@orpc/openapi-client/standard';
|
|
6
|
+
import { StandardOpenAPICodecOptions } from '@orpc/openapi/standard';
|
|
7
|
+
import { StandardHandlerOptions } from '@orpc/server/standard';
|
|
8
|
+
import { Interceptor, Promisable } from '@orpc/shared';
|
|
9
|
+
import { StandardResponse } from '@orpc/standard-server';
|
|
7
10
|
import { SendStandardResponseOptions } from '@orpc/standard-server-node';
|
|
11
|
+
import { Observable } from 'rxjs';
|
|
8
12
|
|
|
9
13
|
declare const ORPC_MODULE_CONFIG_SYMBOL: unique symbol;
|
|
10
|
-
|
|
14
|
+
/**
|
|
15
|
+
* You can extend this interface to add global context properties.
|
|
16
|
+
* @example
|
|
17
|
+
* ```ts
|
|
18
|
+
* declare module '@orpc/nest' {
|
|
19
|
+
* interface ORPCGlobalContext {
|
|
20
|
+
* user: { id: string; name: string }
|
|
21
|
+
* }
|
|
22
|
+
* }
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
interface ORPCGlobalContext {
|
|
26
|
+
}
|
|
27
|
+
interface ORPCModuleConfig extends CreateProcedureClientOptions<ORPCGlobalContext, AnySchema, object, object, object>, SendStandardResponseOptions, StandardOpenAPIJsonSerializerOptions, StandardBracketNotationSerializerOptions, StandardOpenAPICodecOptions {
|
|
28
|
+
plugins?: StandardHandlerOptions<ORPCGlobalContext>['plugins'];
|
|
29
|
+
sendResponseInterceptors?: Interceptor<{
|
|
30
|
+
request: any;
|
|
31
|
+
response: any;
|
|
32
|
+
standardResponse: StandardResponse;
|
|
33
|
+
}, unknown>[];
|
|
11
34
|
}
|
|
12
35
|
declare class ORPCModule {
|
|
13
36
|
static forRoot(config: ORPCModuleConfig): DynamicModule;
|
|
37
|
+
static forRootAsync(options: {
|
|
38
|
+
imports?: any[];
|
|
39
|
+
useFactory: (...args: any[]) => Promise<ORPCModuleConfig> | ORPCModuleConfig;
|
|
40
|
+
inject?: any[];
|
|
41
|
+
}): DynamicModule;
|
|
14
42
|
}
|
|
15
43
|
|
|
16
44
|
/**
|
|
17
45
|
* Decorator in controller handler to implement a oRPC contract.
|
|
18
46
|
*
|
|
19
|
-
* @see {@link https://orpc.
|
|
47
|
+
* @see {@link https://orpc.dev/docs/openapi/integrations/implement-contract-in-nest#implement-your-contract NestJS Implement Contract Docs}
|
|
20
48
|
*/
|
|
21
|
-
declare function Implement<T extends ContractRouter<any>>(contract: T): <U extends Promisable<Router<T,
|
|
49
|
+
declare function Implement<T extends ContractRouter<any>>(contract: T): <U extends Promisable<Router<T, ORPCGlobalContext>>>(target: Record<PropertyKey, any>, propertyKey: string, descriptor: TypedPropertyDescriptor<(...args: any[]) => U>) => void;
|
|
22
50
|
declare class ImplementInterceptor implements NestInterceptor {
|
|
23
51
|
private readonly config;
|
|
52
|
+
private readonly codec;
|
|
24
53
|
constructor(config: ORPCModuleConfig | undefined);
|
|
25
54
|
intercept(ctx: ExecutionContext, next: CallHandler<any>): Observable<any>;
|
|
26
55
|
}
|
|
@@ -38,9 +67,14 @@ interface PopulateContractRouterPathsOptions {
|
|
|
38
67
|
* This utility automatically populates any missing paths
|
|
39
68
|
* Using the router's keys + `/`.
|
|
40
69
|
*
|
|
41
|
-
* @see {@link https://orpc.
|
|
70
|
+
* @see {@link https://orpc.dev/docs/openapi/integrations/implement-contract-in-nest#define-your-contract NestJS Implement Contract Docs}
|
|
42
71
|
*/
|
|
43
72
|
declare function populateContractRouterPaths<T extends AnyContractRouter>(router: T, options?: PopulateContractRouterPathsOptions): PopulatedContractRouterPaths<T>;
|
|
44
73
|
|
|
45
|
-
|
|
46
|
-
|
|
74
|
+
/**
|
|
75
|
+
* Alias for `implement` from `@orpc/server` with default context set to `ORPCGlobalContext`
|
|
76
|
+
*/
|
|
77
|
+
declare function implement<T extends AnyContractRouter, TContext extends Context = ORPCGlobalContext>(contract: T, config?: BuilderConfig): Implementer<T, TContext, TContext>;
|
|
78
|
+
|
|
79
|
+
export { Implement as Impl, Implement, ImplementInterceptor, ORPCModule, ORPC_MODULE_CONFIG_SYMBOL, implement, populateContractRouterPaths, toNestPattern };
|
|
80
|
+
export type { ORPCGlobalContext, ORPCModuleConfig, PopulateContractRouterPathsOptions, PopulatedContractRouterPaths };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,26 +1,55 @@
|
|
|
1
|
-
import { DynamicModule, NestInterceptor, ExecutionContext, CallHandler } from '@nestjs/common';
|
|
2
1
|
import { AnySchema, ContractRouter, HTTPPath, AnyContractRouter, ContractProcedure } from '@orpc/contract';
|
|
3
|
-
import { CreateProcedureClientOptions, Router } from '@orpc/server';
|
|
4
|
-
export { ImplementedProcedure, Implementer, ImplementerInternal, ImplementerInternalWithMiddlewares, ORPCError, ProcedureImplementer, RouterImplementer, RouterImplementerWithMiddlewares,
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
2
|
+
import { CreateProcedureClientOptions, Router, Context, BuilderConfig, Implementer } from '@orpc/server';
|
|
3
|
+
export { ImplementedProcedure, Implementer, ImplementerInternal, ImplementerInternalWithMiddlewares, ORPCError, ProcedureImplementer, RouterImplementer, RouterImplementerWithMiddlewares, onError, onFinish, onStart, onSuccess } from '@orpc/server';
|
|
4
|
+
import { DynamicModule, NestInterceptor, ExecutionContext, CallHandler } from '@nestjs/common';
|
|
5
|
+
import { StandardOpenAPIJsonSerializerOptions, StandardBracketNotationSerializerOptions } from '@orpc/openapi-client/standard';
|
|
6
|
+
import { StandardOpenAPICodecOptions } from '@orpc/openapi/standard';
|
|
7
|
+
import { StandardHandlerOptions } from '@orpc/server/standard';
|
|
8
|
+
import { Interceptor, Promisable } from '@orpc/shared';
|
|
9
|
+
import { StandardResponse } from '@orpc/standard-server';
|
|
7
10
|
import { SendStandardResponseOptions } from '@orpc/standard-server-node';
|
|
11
|
+
import { Observable } from 'rxjs';
|
|
8
12
|
|
|
9
13
|
declare const ORPC_MODULE_CONFIG_SYMBOL: unique symbol;
|
|
10
|
-
|
|
14
|
+
/**
|
|
15
|
+
* You can extend this interface to add global context properties.
|
|
16
|
+
* @example
|
|
17
|
+
* ```ts
|
|
18
|
+
* declare module '@orpc/nest' {
|
|
19
|
+
* interface ORPCGlobalContext {
|
|
20
|
+
* user: { id: string; name: string }
|
|
21
|
+
* }
|
|
22
|
+
* }
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
interface ORPCGlobalContext {
|
|
26
|
+
}
|
|
27
|
+
interface ORPCModuleConfig extends CreateProcedureClientOptions<ORPCGlobalContext, AnySchema, object, object, object>, SendStandardResponseOptions, StandardOpenAPIJsonSerializerOptions, StandardBracketNotationSerializerOptions, StandardOpenAPICodecOptions {
|
|
28
|
+
plugins?: StandardHandlerOptions<ORPCGlobalContext>['plugins'];
|
|
29
|
+
sendResponseInterceptors?: Interceptor<{
|
|
30
|
+
request: any;
|
|
31
|
+
response: any;
|
|
32
|
+
standardResponse: StandardResponse;
|
|
33
|
+
}, unknown>[];
|
|
11
34
|
}
|
|
12
35
|
declare class ORPCModule {
|
|
13
36
|
static forRoot(config: ORPCModuleConfig): DynamicModule;
|
|
37
|
+
static forRootAsync(options: {
|
|
38
|
+
imports?: any[];
|
|
39
|
+
useFactory: (...args: any[]) => Promise<ORPCModuleConfig> | ORPCModuleConfig;
|
|
40
|
+
inject?: any[];
|
|
41
|
+
}): DynamicModule;
|
|
14
42
|
}
|
|
15
43
|
|
|
16
44
|
/**
|
|
17
45
|
* Decorator in controller handler to implement a oRPC contract.
|
|
18
46
|
*
|
|
19
|
-
* @see {@link https://orpc.
|
|
47
|
+
* @see {@link https://orpc.dev/docs/openapi/integrations/implement-contract-in-nest#implement-your-contract NestJS Implement Contract Docs}
|
|
20
48
|
*/
|
|
21
|
-
declare function Implement<T extends ContractRouter<any>>(contract: T): <U extends Promisable<Router<T,
|
|
49
|
+
declare function Implement<T extends ContractRouter<any>>(contract: T): <U extends Promisable<Router<T, ORPCGlobalContext>>>(target: Record<PropertyKey, any>, propertyKey: string, descriptor: TypedPropertyDescriptor<(...args: any[]) => U>) => void;
|
|
22
50
|
declare class ImplementInterceptor implements NestInterceptor {
|
|
23
51
|
private readonly config;
|
|
52
|
+
private readonly codec;
|
|
24
53
|
constructor(config: ORPCModuleConfig | undefined);
|
|
25
54
|
intercept(ctx: ExecutionContext, next: CallHandler<any>): Observable<any>;
|
|
26
55
|
}
|
|
@@ -38,9 +67,14 @@ interface PopulateContractRouterPathsOptions {
|
|
|
38
67
|
* This utility automatically populates any missing paths
|
|
39
68
|
* Using the router's keys + `/`.
|
|
40
69
|
*
|
|
41
|
-
* @see {@link https://orpc.
|
|
70
|
+
* @see {@link https://orpc.dev/docs/openapi/integrations/implement-contract-in-nest#define-your-contract NestJS Implement Contract Docs}
|
|
42
71
|
*/
|
|
43
72
|
declare function populateContractRouterPaths<T extends AnyContractRouter>(router: T, options?: PopulateContractRouterPathsOptions): PopulatedContractRouterPaths<T>;
|
|
44
73
|
|
|
45
|
-
|
|
46
|
-
|
|
74
|
+
/**
|
|
75
|
+
* Alias for `implement` from `@orpc/server` with default context set to `ORPCGlobalContext`
|
|
76
|
+
*/
|
|
77
|
+
declare function implement<T extends AnyContractRouter, TContext extends Context = ORPCGlobalContext>(contract: T, config?: BuilderConfig): Implementer<T, TContext, TContext>;
|
|
78
|
+
|
|
79
|
+
export { Implement as Impl, Implement, ImplementInterceptor, ORPCModule, ORPC_MODULE_CONFIG_SYMBOL, implement, populateContractRouterPaths, toNestPattern };
|
|
80
|
+
export type { ORPCGlobalContext, ORPCModuleConfig, PopulateContractRouterPathsOptions, PopulatedContractRouterPaths };
|
package/dist/index.mjs
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { getRouter, unlazy, isProcedure, implement as implement$1 } from '@orpc/server';
|
|
2
|
+
export { ORPCError, onError, onFinish, onStart, onSuccess } from '@orpc/server';
|
|
3
|
+
import { Module, Injectable, Inject, Optional, applyDecorators, Delete, Patch, Put, Post, Get, Head, HttpCode, UseInterceptors } from '@nestjs/common';
|
|
3
4
|
import { isContractProcedure, ContractProcedure, fallbackContractConfig } from '@orpc/contract';
|
|
4
5
|
import { standardizeHTTPPath, StandardOpenAPISerializer, StandardOpenAPIJsonSerializer, StandardBracketNotationSerializer } from '@orpc/openapi-client/standard';
|
|
5
6
|
import { StandardOpenAPICodec } from '@orpc/openapi/standard';
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import { toStandardLazyRequest, sendStandardResponse } from '@orpc/standard-server-node';
|
|
7
|
+
import { StandardHandler } from '@orpc/server/standard';
|
|
8
|
+
import { toArray, get, intercept } from '@orpc/shared';
|
|
9
|
+
import * as StandardServerFastify from '@orpc/standard-server-fastify';
|
|
10
|
+
import * as StandardServerNode from '@orpc/standard-server-node';
|
|
11
11
|
import { mergeMap } from 'rxjs';
|
|
12
12
|
import { toHttpPath } from '@orpc/client/standard';
|
|
13
13
|
|
|
@@ -35,6 +35,22 @@ let ORPCModule = class {
|
|
|
35
35
|
global: true
|
|
36
36
|
};
|
|
37
37
|
}
|
|
38
|
+
static forRootAsync(options) {
|
|
39
|
+
return {
|
|
40
|
+
module: ORPCModule,
|
|
41
|
+
imports: options.imports,
|
|
42
|
+
providers: [
|
|
43
|
+
{
|
|
44
|
+
provide: ORPC_MODULE_CONFIG_SYMBOL,
|
|
45
|
+
useFactory: options.useFactory,
|
|
46
|
+
inject: options.inject
|
|
47
|
+
},
|
|
48
|
+
ImplementInterceptor
|
|
49
|
+
],
|
|
50
|
+
exports: [ORPC_MODULE_CONFIG_SYMBOL, ImplementInterceptor],
|
|
51
|
+
global: true
|
|
52
|
+
};
|
|
53
|
+
}
|
|
38
54
|
};
|
|
39
55
|
ORPCModule = __decorateClass$1([
|
|
40
56
|
Module({})
|
|
@@ -95,6 +111,7 @@ function Implement(contract) {
|
|
|
95
111
|
return (target, propertyKey, descriptor) => {
|
|
96
112
|
applyDecorators(
|
|
97
113
|
MethodDecoratorMap[method](toNestPattern(path)),
|
|
114
|
+
HttpCode(fallbackContractConfig("defaultSuccessStatus", contract["~orpc"].route.successStatus)),
|
|
98
115
|
UseInterceptors(ImplementInterceptor)
|
|
99
116
|
)(target, propertyKey, descriptor);
|
|
100
117
|
};
|
|
@@ -120,15 +137,18 @@ function Implement(contract) {
|
|
|
120
137
|
}
|
|
121
138
|
};
|
|
122
139
|
}
|
|
123
|
-
const codec = new StandardOpenAPICodec(
|
|
124
|
-
new StandardOpenAPISerializer(
|
|
125
|
-
new StandardOpenAPIJsonSerializer(),
|
|
126
|
-
new StandardBracketNotationSerializer()
|
|
127
|
-
)
|
|
128
|
-
);
|
|
129
140
|
let ImplementInterceptor = class {
|
|
141
|
+
config;
|
|
142
|
+
codec;
|
|
130
143
|
constructor(config) {
|
|
131
|
-
this.config = config;
|
|
144
|
+
this.config = config ?? {};
|
|
145
|
+
this.codec = new StandardOpenAPICodec(
|
|
146
|
+
new StandardOpenAPISerializer(
|
|
147
|
+
new StandardOpenAPIJsonSerializer(this.config),
|
|
148
|
+
new StandardBracketNotationSerializer(this.config)
|
|
149
|
+
),
|
|
150
|
+
this.config
|
|
151
|
+
);
|
|
132
152
|
}
|
|
133
153
|
intercept(ctx, next) {
|
|
134
154
|
return next.handle().pipe(
|
|
@@ -141,32 +161,33 @@ let ImplementInterceptor = class {
|
|
|
141
161
|
}
|
|
142
162
|
const req = ctx.switchToHttp().getRequest();
|
|
143
163
|
const res = ctx.switchToHttp().getResponse();
|
|
144
|
-
const
|
|
145
|
-
const
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
164
|
+
const standardRequest = "raw" in req ? StandardServerFastify.toStandardLazyRequest(req, res) : StandardServerNode.toStandardLazyRequest(req, res);
|
|
165
|
+
const handler = new StandardHandler(procedure, {
|
|
166
|
+
init: () => {
|
|
167
|
+
},
|
|
168
|
+
match: () => Promise.resolve({ path: toArray(this.config.path), procedure, params: flattenParams(req.params) })
|
|
169
|
+
}, this.codec, {
|
|
170
|
+
// Since plugins can modify options directly, so we need to clone to avoid affecting other handlers/requests
|
|
171
|
+
// TODO: improve plugins system to avoid this cloning
|
|
172
|
+
clientInterceptors: [...toArray(this.config.interceptors)],
|
|
173
|
+
plugins: [...toArray(this.config.plugins)]
|
|
174
|
+
});
|
|
175
|
+
const result = await handler.handle(standardRequest, {
|
|
176
|
+
context: this.config.context
|
|
177
|
+
});
|
|
178
|
+
if (result.matched) {
|
|
179
|
+
return intercept(
|
|
180
|
+
toArray(this.config.sendResponseInterceptors),
|
|
181
|
+
{ request: req, response: res, standardResponse: result.response },
|
|
182
|
+
async ({ response, standardResponse }) => {
|
|
183
|
+
if ("raw" in response) {
|
|
184
|
+
await StandardServerFastify.sendStandardResponse(response, standardResponse, this.config);
|
|
185
|
+
} else {
|
|
186
|
+
await StandardServerNode.sendStandardResponse(response, standardResponse, this.config);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
);
|
|
190
|
+
}
|
|
170
191
|
})
|
|
171
192
|
);
|
|
172
193
|
}
|
|
@@ -188,4 +209,8 @@ function flattenParams(params) {
|
|
|
188
209
|
return flatten;
|
|
189
210
|
}
|
|
190
211
|
|
|
191
|
-
|
|
212
|
+
function implement(contract, config = {}) {
|
|
213
|
+
return implement$1(contract, config);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
export { Implement as Impl, Implement, ImplementInterceptor, ORPCModule, ORPC_MODULE_CONFIG_SYMBOL, implement, populateContractRouterPaths, toNestPattern };
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@orpc/nest",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.0-next.
|
|
4
|
+
"version": "0.0.0-next.d12598b",
|
|
5
5
|
"license": "MIT",
|
|
6
|
-
"homepage": "https://orpc.
|
|
6
|
+
"homepage": "https://orpc.dev",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
9
9
|
"url": "git+https://github.com/unnoq/orpc.git",
|
|
@@ -39,28 +39,30 @@
|
|
|
39
39
|
}
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@orpc/client": "0.0.0-next.
|
|
43
|
-
"@orpc/contract": "0.0.0-next.
|
|
44
|
-
"@orpc/openapi": "0.0.0-next.
|
|
45
|
-
"@orpc/openapi-client": "0.0.0-next.
|
|
46
|
-
"@orpc/server": "0.0.0-next.
|
|
47
|
-
"@orpc/
|
|
48
|
-
"@orpc/standard-server": "0.0.0-next.
|
|
49
|
-
"@orpc/standard-server-node": "0.0.0-next.
|
|
42
|
+
"@orpc/client": "0.0.0-next.d12598b",
|
|
43
|
+
"@orpc/contract": "0.0.0-next.d12598b",
|
|
44
|
+
"@orpc/openapi": "0.0.0-next.d12598b",
|
|
45
|
+
"@orpc/openapi-client": "0.0.0-next.d12598b",
|
|
46
|
+
"@orpc/server": "0.0.0-next.d12598b",
|
|
47
|
+
"@orpc/standard-server": "0.0.0-next.d12598b",
|
|
48
|
+
"@orpc/standard-server-fastify": "0.0.0-next.d12598b",
|
|
49
|
+
"@orpc/standard-server-node": "0.0.0-next.d12598b",
|
|
50
|
+
"@orpc/shared": "0.0.0-next.d12598b"
|
|
50
51
|
},
|
|
51
52
|
"devDependencies": {
|
|
52
|
-
"@
|
|
53
|
-
"@nestjs/
|
|
54
|
-
"@nestjs/
|
|
55
|
-
"@nestjs/platform-
|
|
56
|
-
"@nestjs/
|
|
53
|
+
"@fastify/cookie": "^11.0.2",
|
|
54
|
+
"@nestjs/common": "^11.1.9",
|
|
55
|
+
"@nestjs/core": "^11.1.9",
|
|
56
|
+
"@nestjs/platform-express": "^11.1.9",
|
|
57
|
+
"@nestjs/platform-fastify": "^11.1.9",
|
|
58
|
+
"@nestjs/testing": "^11.1.9",
|
|
57
59
|
"@ts-rest/core": "^3.52.1",
|
|
58
|
-
"@types/express": "^5.0.
|
|
59
|
-
"express": "^5.
|
|
60
|
-
"fastify": "^5.
|
|
60
|
+
"@types/express": "^5.0.6",
|
|
61
|
+
"express": "^5.2.1",
|
|
62
|
+
"fastify": "^5.6.2",
|
|
61
63
|
"rxjs": "^7.8.1",
|
|
62
|
-
"supertest": "^7.1.
|
|
63
|
-
"zod": "^4.
|
|
64
|
+
"supertest": "^7.1.4",
|
|
65
|
+
"zod": "^4.1.12"
|
|
64
66
|
},
|
|
65
67
|
"scripts": {
|
|
66
68
|
"build": "unbuild",
|