@orpc/nest 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 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 | 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/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) |
54
- | [@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) |
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&amp;utm_source=middleapi&amp;utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Guillermo Rauch"><img src="https://avatars.githubusercontent.com/u/13041?u=1ee8d111657cdd02ff6d253df00978d17ee6d722&amp;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>
package/dist/index.d.mts CHANGED
@@ -66,6 +66,7 @@ declare class ORPCModule {
66
66
  * @remarks
67
67
  * **Note**: Every procedure contract must define an `openapi.path` meta;
68
68
  * use `populateRouterContractOpenAPIPaths` from `@orpc/openapi` to fill in missing paths.
69
+ * **Note**: The HTTP `QUERY` method requires NestJS v11.2+ (`QueryMethod`). Older NestJS versions throw; use `GET` instead.
69
70
  *
70
71
  * @see {@link https://orpc.dev/docs/integrations/nest#implement-your-contract | Implement oRPC contract with NestJS - Implement Your Contract}
71
72
  */
package/dist/index.d.ts CHANGED
@@ -66,6 +66,7 @@ declare class ORPCModule {
66
66
  * @remarks
67
67
  * **Note**: Every procedure contract must define an `openapi.path` meta;
68
68
  * use `populateRouterContractOpenAPIPaths` from `@orpc/openapi` to fill in missing paths.
69
+ * **Note**: The HTTP `QUERY` method requires NestJS v11.2+ (`QueryMethod`). Older NestJS versions throw; use `GET` instead.
69
70
  *
70
71
  * @see {@link https://orpc.dev/docs/integrations/nest#implement-your-contract | Implement oRPC contract with NestJS - Implement Your Contract}
71
72
  */
package/dist/index.mjs CHANGED
@@ -1,5 +1,6 @@
1
1
  import { Readable } from 'node:stream';
2
- import { Module, applyDecorators, UseInterceptors, StreamableFile, HttpException, Options, Delete, Patch, Put, Post, Get, Head, HttpCode, Injectable, Inject, Optional } from '@nestjs/common';
2
+ import * as NestCommon from '@nestjs/common';
3
+ import { Module, applyDecorators, UseInterceptors, StreamableFile, HttpException, HttpCode, Options, Delete, Patch, Put, Post, Get, Head, Injectable, Inject, Optional } from '@nestjs/common';
3
4
  import { HttpAdapterHost } from '@nestjs/core';
4
5
  import { ProcedureContract, getPathMeta } from '@orpc/contract';
5
6
  import { getOpenAPIMeta, DEFAULT_OPENAPI_METHOD, getDynamicPathParams } from '@orpc/openapi';
@@ -65,6 +66,7 @@ var __decorateClass = (decorators, target, key, kind) => {
65
66
  return result;
66
67
  };
67
68
  var __decorateParam = (index, decorator) => (target, key) => decorator(target, key, index);
69
+ const QueryMethod = NestCommon.QueryMethod;
68
70
  const MethodDecoratorMap = {
69
71
  HEAD: Head,
70
72
  GET: Get,
@@ -101,10 +103,16 @@ function toNestRouteDecorator(contract) {
101
103
  const path = toNestPattern(meta.prefix ? mergeHttpPath(meta.prefix, meta.path) : meta.path);
102
104
  const successStatus = meta.successStatus ?? DEFAULT_SUCCESS_STATUS;
103
105
  if (method === "QUERY") {
104
- throw new TypeError(`
105
- @Implement decorator does not support the 'QUERY' HTTP method because NestJS does not support it.
106
- Use the 'GET' method instead.
107
- `);
106
+ if (!QueryMethod) {
107
+ throw new TypeError(`
108
+ @Implement decorator does not support the 'QUERY' HTTP method because the installed version of NestJS does not support it.
109
+ The 'QUERY' HTTP method requires NestJS v11.2 or later. Alternatively, use 'GET' method.
110
+ `);
111
+ }
112
+ return applyDecorators(
113
+ QueryMethod(path),
114
+ HttpCode(successStatus)
115
+ );
108
116
  }
109
117
  return applyDecorators(
110
118
  MethodDecoratorMap[method](path),
@@ -112,7 +120,7 @@ function toNestRouteDecorator(contract) {
112
120
  );
113
121
  }
114
122
  function implementRouterContract(contract, target, propertyKey, descriptor) {
115
- for (const key in contract) {
123
+ for (const [key, childContract] of Object.entries(contract)) {
116
124
  let methodName = `${propertyKey}_${key}`;
117
125
  let i = 0;
118
126
  while (methodName in target) {
@@ -131,7 +139,6 @@ function implementRouterContract(contract, target, propertyKey, descriptor) {
131
139
  Reflect.defineMetadata(p, Reflect.getOwnMetadata(p, target.constructor, propertyKey), target.constructor, methodName);
132
140
  }
133
141
  });
134
- const childContract = contract[key];
135
142
  const childDescriptor = Object.getOwnPropertyDescriptor(target, methodName);
136
143
  if (childContract instanceof ProcedureContract) {
137
144
  const routeDecorator = toNestRouteDecorator(childContract);
@@ -198,7 +205,7 @@ let ImplementInterceptor = class {
198
205
  }
199
206
  const httpAdapter = this.httpAdapterHost.httpAdapter;
200
207
  httpAdapter.status(res, result.response.status);
201
- for (const key in result.response.headers) {
208
+ for (const key of Object.keys(result.response.headers)) {
202
209
  const value2 = result.response.headers[key];
203
210
  if (typeof value2 === "string") {
204
211
  httpAdapter.setHeader(res, key, value2);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@orpc/nest",
3
3
  "type": "module",
4
- "version": "2.0.0-beta.35",
4
+ "version": "2.0.0-beta.37",
5
5
  "description": "NestJS integration for oRPC: implement typesafe contracts in NestJS controllers",
6
6
  "license": "MIT",
7
7
  "funding": [
@@ -52,13 +52,13 @@
52
52
  }
53
53
  },
54
54
  "dependencies": {
55
- "@orpc/client": "2.0.0-beta.35",
56
- "@orpc/contract": "2.0.0-beta.35",
57
- "@orpc/openapi": "2.0.0-beta.35",
58
- "@orpc/server": "2.0.0-beta.35",
59
- "@orpc/shared": "2.0.0-beta.35",
60
- "@standard-server/core": "~0.9.0",
61
- "@standard-server/node": "~0.9.0"
55
+ "@orpc/client": "2.0.0-beta.37",
56
+ "@orpc/contract": "2.0.0-beta.37",
57
+ "@orpc/openapi": "2.0.0-beta.37",
58
+ "@orpc/server": "2.0.0-beta.37",
59
+ "@orpc/shared": "2.0.0-beta.37",
60
+ "@standard-server/core": "~0.9.2",
61
+ "@standard-server/node": "~0.9.2"
62
62
  },
63
63
  "devDependencies": {
64
64
  "@fastify/cookie": "^11.0.2",