@orpc/nest 0.0.0-next.f9e0a4c → 0.0.0-next.f9e5dec

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 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>
@@ -31,7 +34,7 @@
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.
34
- - **⚙️ Framework Integrations**: Seamlessly integrate with TanStack Query (React, Vue, Solid, Svelte, Angular), Pinia Colada, and more.
37
+ - **⚙️ Framework Integrations**: Seamlessly integrate with TanStack Query (React, Vue, Solid, Svelte, Angular), SWR, Pinia Colada, and more.
35
38
  - **🚀 Server Actions**: Fully compatible with React Server Actions on Next.js, TanStack Start, and other platforms.
36
39
  - **🔠 Standard Schema Support**: Works out of the box with Zod, Valibot, ArkType, and other schema validators.
37
40
  - **🗃️ Native Types**: Supports native types like Date, File, Blob, BigInt, URL, and more.
@@ -54,6 +57,7 @@ You can find the full documentation [here](https://orpc.unnoq.com).
54
57
  - [@orpc/nest](https://www.npmjs.com/package/@orpc/nest): Deeply integrate oRPC with [NestJS](https://nestjs.com/).
55
58
  - [@orpc/react](https://www.npmjs.com/package/@orpc/react): Utilities for integrating oRPC with React and React Server Actions.
56
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.
57
61
  - [@orpc/vue-colada](https://www.npmjs.com/package/@orpc/vue-colada): Integration with [Pinia Colada](https://pinia-colada.esm.dev/).
58
62
  - [@orpc/hey-api](https://www.npmjs.com/package/@orpc/hey-api): [Hey API](https://heyapi.dev/) integration.
59
63
  - [@orpc/zod](https://www.npmjs.com/package/@orpc/zod): More schemas that [Zod](https://zod.dev/) doesn't support yet.
@@ -86,7 +90,7 @@ export class PlanetController {
86
90
  }
87
91
 
88
92
  /**
89
- * Implement entire a contract
93
+ * Implement entire contract
90
94
  */
91
95
  @Implement(contract.planet)
92
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 { toStandardLazyRequest, sendStandardResponse } from '@orpc/standard-server-node';
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 nodeReq = "raw" in req ? req.raw : req;
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
- await sendStandardResponse(nodeRes, standardResponse, this.config);
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.f9e0a4c",
4
+ "version": "0.0.0-next.f9e5dec",
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/client": "0.0.0-next.f9e0a4c",
43
- "@orpc/contract": "0.0.0-next.f9e0a4c",
44
- "@orpc/openapi-client": "0.0.0-next.f9e0a4c",
45
- "@orpc/shared": "0.0.0-next.f9e0a4c",
46
- "@orpc/server": "0.0.0-next.f9e0a4c",
47
- "@orpc/openapi": "0.0.0-next.f9e0a4c",
48
- "@orpc/standard-server": "0.0.0-next.f9e0a4c",
49
- "@orpc/standard-server-node": "0.0.0-next.f9e0a4c"
42
+ "@orpc/contract": "0.0.0-next.f9e5dec",
43
+ "@orpc/client": "0.0.0-next.f9e5dec",
44
+ "@orpc/openapi": "0.0.0-next.f9e5dec",
45
+ "@orpc/server": "0.0.0-next.f9e5dec",
46
+ "@orpc/openapi-client": "0.0.0-next.f9e5dec",
47
+ "@orpc/shared": "0.0.0-next.f9e5dec",
48
+ "@orpc/standard-server-fastify": "0.0.0-next.f9e5dec",
49
+ "@orpc/standard-server-node": "0.0.0-next.f9e5dec",
50
+ "@orpc/standard-server": "0.0.0-next.f9e5dec"
50
51
  },
51
52
  "devDependencies": {
52
- "@nestjs/common": "^11.1.6",
53
- "@nestjs/core": "^11.1.6",
54
- "@nestjs/platform-express": "^11.1.6",
55
- "@nestjs/platform-fastify": "^11.1.6",
56
- "@nestjs/testing": "^11.1.6",
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.3",
60
+ "@types/express": "^5.0.5",
59
61
  "express": "^5.0.0",
60
- "fastify": "^5.4.0",
62
+ "fastify": "^5.6.2",
61
63
  "rxjs": "^7.8.1",
62
64
  "supertest": "^7.1.4",
63
- "zod": "^4.0.17"
65
+ "zod": "^4.1.12"
64
66
  },
65
67
  "scripts": {
66
68
  "build": "unbuild",