@orpc/nest 2.0.0-beta.52 → 2.0.0-beta.53

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
@@ -63,7 +63,7 @@ Read the full documentation at [orpc.dev](https://orpc.dev), starting with the [
63
63
 
64
64
  | Package | Purpose | Docs |
65
65
  | -------------------------------------------------------------- | -------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
66
- | [@orpc/contract](https://www.npmjs.com/package/@orpc/contract) | Define API contract as the single source of truth. | [Procedure Contract](https://orpc.dev/docs/contract/procedure), [Contract Router](https://orpc.dev/docs/contract/router), [Implementation](https://orpc.dev/docs/contract/implementation), [Generate from OpenAPI](https://orpc.dev/docs/contract/generate-from-openapi) |
66
+ | [@orpc/contract](https://www.npmjs.com/package/@orpc/contract) | Define API contract as the single source of truth. | [Procedure Contract](https://orpc.dev/docs/contract/procedure), [Router Contract](https://orpc.dev/docs/contract/router), [Implementation](https://orpc.dev/docs/contract/implementation), [Generate from OpenAPI](https://orpc.dev/docs/contract/generate-from-openapi) |
67
67
  | [@orpc/server](https://www.npmjs.com/package/@orpc/server) | Build APIs or implement contracts. | [Procedure](https://orpc.dev/docs/procedure), [Router](https://orpc.dev/docs/router), [Middleware](https://orpc.dev/docs/middleware), [Context](https://orpc.dev/docs/context), [RPC Handler](https://orpc.dev/docs/rpc/handler) |
68
68
  | [@orpc/client](https://www.npmjs.com/package/@orpc/client) | Consume APIs with end-to-end type safety. | [Client-Side Clients](https://orpc.dev/docs/client/client-side), [Server-Side Clients](https://orpc.dev/docs/client/server-side), [RPC Link](https://orpc.dev/docs/rpc/link), [Error Handling](https://orpc.dev/docs/client/error-handling) |
69
69
  | [@orpc/openapi](https://www.npmjs.com/package/@orpc/openapi) | Add OpenAPI compatibility to APIs. | [OpenAPI Handler](https://orpc.dev/docs/openapi/handler), [OpenAPI Link](https://orpc.dev/docs/openapi/link), [Specification](https://orpc.dev/docs/openapi/specification), [Scalar](https://orpc.dev/docs/openapi/scalar) |
@@ -1,5 +1,5 @@
1
1
  import { ORPCModuleConfig } from "./module.js";
2
- import { CallHandler, ExecutionContext, NestInterceptor } from "@nestjs/common";
2
+ import { CallHandler, ExecutionContext, HttpException, NestInterceptor } from "@nestjs/common";
3
3
  import { HttpAdapterHost } from "@nestjs/core";
4
4
  import { RouterContract } from "@orpc/contract";
5
5
  import { ContractedRouter, DefaultInitialContext } from "@orpc/server";
@@ -26,4 +26,11 @@ export declare class ImplementInterceptor implements NestInterceptor {
26
26
  private readonly httpAdapterHost;
27
27
  constructor(config: ORPCModuleConfig | undefined, httpAdapterHost: HttpAdapterHost);
28
28
  intercept(ctx: ExecutionContext, next: CallHandler): Observable<any>;
29
- }
29
+ }
30
+ /**
31
+ * The `HttpException` oRPC throws to let NestJS send an error response.
32
+ * Exception filters can use it to tell oRPC error responses apart from other exceptions.
33
+ *
34
+ * @see {@link https://orpc.dev/docs/integrations/nest#error-handling | Implement oRPC contract with NestJS - Error Handling}
35
+ */
36
+ export declare class ORPCHttpException extends HttpException {}
package/dist/implement.js CHANGED
@@ -151,7 +151,7 @@ let ImplementInterceptor = class ImplementInterceptor {
151
151
  if (index === 0) httpAdapter.setHeader(res, key, value);
152
152
  else httpAdapter.appendHeader(res, key, value);
153
153
  });
154
- if (nestBody instanceof HttpException) throw nestBody;
154
+ if (nestBody instanceof ORPCHttpException) throw nestBody;
155
155
  return nestBody;
156
156
  }));
157
157
  }
@@ -164,6 +164,13 @@ ImplementInterceptor = __decorate([
164
164
  __decorateMetadata("design:paramtypes", [Object, typeof HttpAdapterHost === "undefined" ? Object : HttpAdapterHost])
165
165
  ], ImplementInterceptor);
166
166
  /**
167
+ * The `HttpException` oRPC throws to let NestJS send an error response.
168
+ * Exception filters can use it to tell oRPC error responses apart from other exceptions.
169
+ *
170
+ * @see {@link https://orpc.dev/docs/integrations/nest#error-handling | Implement oRPC contract with NestJS - Error Handling}
171
+ */
172
+ var ORPCHttpException = class extends HttpException {};
173
+ /**
167
174
  * Mirrors `toNodeHttpBody` from `@standard-server/node`, but returns a body NestJS can respond with.
168
175
  */
169
176
  function toNestHttpBody(response, signal, options) {
@@ -204,7 +211,7 @@ function toNestHttpBody(response, signal, options) {
204
211
  }
205
212
  if (status >= 300 && typeof body === "object" && body !== null && !Array.isArray(body)) {
206
213
  if (headers["content-type"] !== void 0) headers["standard-server"] = getRequiredStandardBodyHint("json", headers);
207
- return [new HttpException(body, status), headers];
214
+ return [new ORPCHttpException(body, status), headers];
208
215
  }
209
216
  headers["content-type"] ??= "application/json";
210
217
  headers["standard-server"] = getRequiredStandardBodyHint("json", headers);
@@ -272,4 +279,4 @@ function toNestPattern(path) {
272
279
  }
273
280
  return path;
274
281
  }
275
- export { Implement, ImplementInterceptor };
282
+ export { Implement, ImplementInterceptor, ORPCHttpException };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  import { ORPC_MODULE_CONFIG_SYMBOL } from "./constants.js";
2
- import { Implement, ImplementInterceptor } from "./implement.js";
2
+ import { Implement, ImplementInterceptor, ORPCHttpException } from "./implement.js";
3
3
  import { NestStandardLazyRequest, ORPCModule, ORPCModuleConfig } from "./module.js";
4
- export { Implement as Impl, Implement, ImplementInterceptor, NestStandardLazyRequest, ORPCModule, ORPCModuleConfig, ORPC_MODULE_CONFIG_SYMBOL };
4
+ export { Implement as Impl, Implement, ImplementInterceptor, NestStandardLazyRequest, ORPCHttpException, ORPCModule, ORPCModuleConfig, ORPC_MODULE_CONFIG_SYMBOL };
package/dist/index.js CHANGED
@@ -1,3 +1,3 @@
1
1
  export { ORPC_MODULE_CONFIG_SYMBOL } from "./constants.js";
2
- export { Implement as Impl, Implement, ImplementInterceptor } from "./implement.js";
2
+ export { Implement as Impl, Implement, ImplementInterceptor, ORPCHttpException } from "./implement.js";
3
3
  export { ORPCModule } from "./module.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@orpc/nest",
3
- "version": "2.0.0-beta.52",
3
+ "version": "2.0.0-beta.53",
4
4
  "description": "NestJS integration for oRPC: implement typesafe contracts in NestJS controllers",
5
5
  "keywords": [
6
6
  "contract-first",
@@ -37,11 +37,10 @@
37
37
  }
38
38
  },
39
39
  "dependencies": {
40
- "@orpc/client": "2.0.0-beta.52",
41
- "@orpc/contract": "2.0.0-beta.52",
42
- "@orpc/openapi": "2.0.0-beta.52",
43
- "@orpc/server": "2.0.0-beta.52",
44
- "@orpc/shared": "2.0.0-beta.52",
40
+ "@orpc/contract": "2.0.0-beta.53",
41
+ "@orpc/openapi": "2.0.0-beta.53",
42
+ "@orpc/server": "2.0.0-beta.53",
43
+ "@orpc/shared": "2.0.0-beta.53",
45
44
  "@oxc-project/runtime": "^0.157.0",
46
45
  "@standard-server/core": "~0.16.0",
47
46
  "@standard-server/node": "~0.16.0"