@orpc/nest 0.0.0-next.fe5c63f → 0.0.0-next.fe89a39
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 +8 -3
- package/dist/index.d.mts +5 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.mjs +24 -7
- package/package.json +19 -17
package/README.md
CHANGED
|
@@ -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,7 +42,6 @@
|
|
|
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
|
|
|
@@ -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.
|
|
@@ -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
|
@@ -11,6 +11,11 @@ interface ORPCModuleConfig extends CreateProcedureClientOptions<object, AnySchem
|
|
|
11
11
|
}
|
|
12
12
|
declare class ORPCModule {
|
|
13
13
|
static forRoot(config: ORPCModuleConfig): DynamicModule;
|
|
14
|
+
static forRootAsync(options: {
|
|
15
|
+
imports?: any[];
|
|
16
|
+
useFactory: (...args: any[]) => Promise<ORPCModuleConfig> | ORPCModuleConfig;
|
|
17
|
+
inject?: any[];
|
|
18
|
+
}): DynamicModule;
|
|
14
19
|
}
|
|
15
20
|
|
|
16
21
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -11,6 +11,11 @@ interface ORPCModuleConfig extends CreateProcedureClientOptions<object, AnySchem
|
|
|
11
11
|
}
|
|
12
12
|
declare class ORPCModule {
|
|
13
13
|
static forRoot(config: ORPCModuleConfig): DynamicModule;
|
|
14
|
+
static forRootAsync(options: {
|
|
15
|
+
imports?: any[];
|
|
16
|
+
useFactory: (...args: any[]) => Promise<ORPCModuleConfig> | ORPCModuleConfig;
|
|
17
|
+
inject?: any[];
|
|
18
|
+
}): DynamicModule;
|
|
14
19
|
}
|
|
15
20
|
|
|
16
21
|
/**
|
package/dist/index.mjs
CHANGED
|
@@ -7,7 +7,8 @@ import { getRouter, unlazy, isProcedure, createProcedureClient, ORPCError } from
|
|
|
7
7
|
export { ORPCError, implement, onError, onFinish, onStart, onSuccess } from '@orpc/server';
|
|
8
8
|
import { toArray, get } from '@orpc/shared';
|
|
9
9
|
import { flattenHeader } from '@orpc/standard-server';
|
|
10
|
-
import
|
|
10
|
+
import * as StandardServerFastify from '@orpc/standard-server-fastify';
|
|
11
|
+
import * as StandardServerNode from '@orpc/standard-server-node';
|
|
11
12
|
import { mergeMap } from 'rxjs';
|
|
12
13
|
import { toHttpPath } from '@orpc/client/standard';
|
|
13
14
|
|
|
@@ -35,6 +36,22 @@ let ORPCModule = class {
|
|
|
35
36
|
global: true
|
|
36
37
|
};
|
|
37
38
|
}
|
|
39
|
+
static forRootAsync(options) {
|
|
40
|
+
return {
|
|
41
|
+
module: ORPCModule,
|
|
42
|
+
imports: options.imports,
|
|
43
|
+
providers: [
|
|
44
|
+
{
|
|
45
|
+
provide: ORPC_MODULE_CONFIG_SYMBOL,
|
|
46
|
+
useFactory: options.useFactory,
|
|
47
|
+
inject: options.inject
|
|
48
|
+
},
|
|
49
|
+
ImplementInterceptor
|
|
50
|
+
],
|
|
51
|
+
exports: [ORPC_MODULE_CONFIG_SYMBOL, ImplementInterceptor],
|
|
52
|
+
global: true
|
|
53
|
+
};
|
|
54
|
+
}
|
|
38
55
|
};
|
|
39
56
|
ORPCModule = __decorateClass$1([
|
|
40
57
|
Module({})
|
|
@@ -141,11 +158,7 @@ let ImplementInterceptor = class {
|
|
|
141
158
|
}
|
|
142
159
|
const req = ctx.switchToHttp().getRequest();
|
|
143
160
|
const res = ctx.switchToHttp().getResponse();
|
|
144
|
-
const
|
|
145
|
-
const nodeRes = "raw" in res ? res.raw : res;
|
|
146
|
-
const standardRequest = toStandardLazyRequest(nodeReq, nodeRes);
|
|
147
|
-
const fallbackStandardBody = standardRequest.body.bind(standardRequest);
|
|
148
|
-
standardRequest.body = () => Promise.resolve(req.body ?? fallbackStandardBody());
|
|
161
|
+
const standardRequest = "raw" in req ? StandardServerFastify.toStandardLazyRequest(req, res) : StandardServerNode.toStandardLazyRequest(req, res);
|
|
149
162
|
const standardResponse = await (async () => {
|
|
150
163
|
let isDecoding = false;
|
|
151
164
|
try {
|
|
@@ -166,7 +179,11 @@ let ImplementInterceptor = class {
|
|
|
166
179
|
return codec.encodeError(error);
|
|
167
180
|
}
|
|
168
181
|
})();
|
|
169
|
-
|
|
182
|
+
if ("raw" in res) {
|
|
183
|
+
await StandardServerFastify.sendStandardResponse(res, standardResponse, this.config);
|
|
184
|
+
} else {
|
|
185
|
+
await StandardServerNode.sendStandardResponse(res, standardResponse, this.config);
|
|
186
|
+
}
|
|
170
187
|
})
|
|
171
188
|
);
|
|
172
189
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@orpc/nest",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.0-next.
|
|
4
|
+
"version": "0.0.0-next.fe89a39",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://orpc.unnoq.com",
|
|
7
7
|
"repository": {
|
|
@@ -39,28 +39,30 @@
|
|
|
39
39
|
}
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@orpc/
|
|
43
|
-
"@orpc/
|
|
44
|
-
"@orpc/openapi": "0.0.0-next.
|
|
45
|
-
"@orpc/openapi-client": "0.0.0-next.
|
|
46
|
-
"@orpc/
|
|
47
|
-
"@orpc/
|
|
48
|
-
"@orpc/standard-server-
|
|
49
|
-
"@orpc/server": "0.0.0-next.
|
|
42
|
+
"@orpc/contract": "0.0.0-next.fe89a39",
|
|
43
|
+
"@orpc/client": "0.0.0-next.fe89a39",
|
|
44
|
+
"@orpc/openapi": "0.0.0-next.fe89a39",
|
|
45
|
+
"@orpc/openapi-client": "0.0.0-next.fe89a39",
|
|
46
|
+
"@orpc/server": "0.0.0-next.fe89a39",
|
|
47
|
+
"@orpc/shared": "0.0.0-next.fe89a39",
|
|
48
|
+
"@orpc/standard-server-fastify": "0.0.0-next.fe89a39",
|
|
49
|
+
"@orpc/standard-server-node": "0.0.0-next.fe89a39",
|
|
50
|
+
"@orpc/standard-server": "0.0.0-next.fe89a39"
|
|
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.7",
|
|
55
|
+
"@nestjs/core": "^11.1.7",
|
|
56
|
+
"@nestjs/platform-express": "^11.1.7",
|
|
57
|
+
"@nestjs/platform-fastify": "^11.1.7",
|
|
58
|
+
"@nestjs/testing": "^11.1.7",
|
|
57
59
|
"@ts-rest/core": "^3.52.1",
|
|
58
60
|
"@types/express": "^5.0.3",
|
|
59
61
|
"express": "^5.0.0",
|
|
60
|
-
"fastify": "^5.
|
|
62
|
+
"fastify": "^5.6.1",
|
|
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",
|