@orpc/nest 2.0.0-beta.10 → 2.0.0-beta.11

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/dist/index.d.mts CHANGED
@@ -10,16 +10,22 @@ import { ToEventStreamOptions } from '@standardserver/node';
10
10
  import { HttpAdapterHost } from '@nestjs/core';
11
11
 
12
12
  declare const ORPC_MODULE_CONFIG_SYMBOL: unique symbol;
13
+ interface NestStandardLazyRequest extends StandardLazyRequest {
14
+ /**
15
+ * Route parameters extracted from the request path.
16
+ */
17
+ params?: undefined | Record<string, string | string[]>;
18
+ }
13
19
  type ORPCModuleConfig = OpenAPIHandlerCodecCoreOptions<DefaultInitialContext> & StandardHandlerOptions<DefaultInitialContext> & (object extends DefaultInitialContext ? {
14
20
  context?: DefaultInitialContext;
15
21
  } : {
16
22
  context: DefaultInitialContext;
17
23
  }) & {
18
24
  /**
19
- * Customize how convert next.js req and res to StandardLazyRequest,
20
- * You might need define this if you not using express or fastify adapters
25
+ * Customize how to convert NestJS `req` and `res` to {@link NestStandardLazyRequest}.
26
+ * You might need to define this if you are not using express or fastify adapters.
21
27
  */
22
- toStandardLazyRequest?: undefined | ((req: any, res: any) => StandardLazyRequest);
28
+ toNestStandardLazyRequest?: undefined | ((req: any, res: any) => NestStandardLazyRequest);
23
29
  /**
24
30
  * Options for how to convert the Standard Response to a Nest Response (returning value), like event iterator options, etc.
25
31
  */
@@ -43,11 +49,11 @@ declare function Implement<T extends RouterContract>(contract: T): <U extends Pr
43
49
  declare class ImplementInterceptor implements NestInterceptor {
44
50
  private readonly config;
45
51
  private readonly codec;
46
- private readonly toStandardLazyRequest;
52
+ private readonly toNestStandardLazyRequest;
47
53
  private readonly httpAdapterHost;
48
54
  constructor(config: ORPCModuleConfig | undefined, httpAdapterHost: HttpAdapterHost);
49
55
  intercept(ctx: ExecutionContext, next: CallHandler<any>): Observable<any>;
50
56
  }
51
57
 
52
58
  export { Implement as Impl, Implement, ImplementInterceptor, ORPCModule, ORPC_MODULE_CONFIG_SYMBOL };
53
- export type { ORPCModuleConfig };
59
+ export type { NestStandardLazyRequest, ORPCModuleConfig };
package/dist/index.d.ts CHANGED
@@ -10,16 +10,22 @@ import { ToEventStreamOptions } from '@standardserver/node';
10
10
  import { HttpAdapterHost } from '@nestjs/core';
11
11
 
12
12
  declare const ORPC_MODULE_CONFIG_SYMBOL: unique symbol;
13
+ interface NestStandardLazyRequest extends StandardLazyRequest {
14
+ /**
15
+ * Route parameters extracted from the request path.
16
+ */
17
+ params?: undefined | Record<string, string | string[]>;
18
+ }
13
19
  type ORPCModuleConfig = OpenAPIHandlerCodecCoreOptions<DefaultInitialContext> & StandardHandlerOptions<DefaultInitialContext> & (object extends DefaultInitialContext ? {
14
20
  context?: DefaultInitialContext;
15
21
  } : {
16
22
  context: DefaultInitialContext;
17
23
  }) & {
18
24
  /**
19
- * Customize how convert next.js req and res to StandardLazyRequest,
20
- * You might need define this if you not using express or fastify adapters
25
+ * Customize how to convert NestJS `req` and `res` to {@link NestStandardLazyRequest}.
26
+ * You might need to define this if you are not using express or fastify adapters.
21
27
  */
22
- toStandardLazyRequest?: undefined | ((req: any, res: any) => StandardLazyRequest);
28
+ toNestStandardLazyRequest?: undefined | ((req: any, res: any) => NestStandardLazyRequest);
23
29
  /**
24
30
  * Options for how to convert the Standard Response to a Nest Response (returning value), like event iterator options, etc.
25
31
  */
@@ -43,11 +49,11 @@ declare function Implement<T extends RouterContract>(contract: T): <U extends Pr
43
49
  declare class ImplementInterceptor implements NestInterceptor {
44
50
  private readonly config;
45
51
  private readonly codec;
46
- private readonly toStandardLazyRequest;
52
+ private readonly toNestStandardLazyRequest;
47
53
  private readonly httpAdapterHost;
48
54
  constructor(config: ORPCModuleConfig | undefined, httpAdapterHost: HttpAdapterHost);
49
55
  intercept(ctx: ExecutionContext, next: CallHandler<any>): Observable<any>;
50
56
  }
51
57
 
52
58
  export { Implement as Impl, Implement, ImplementInterceptor, ORPCModule, ORPC_MODULE_CONFIG_SYMBOL };
53
- export type { ORPCModuleConfig };
59
+ export type { NestStandardLazyRequest, ORPCModuleConfig };
package/dist/index.mjs CHANGED
@@ -119,13 +119,13 @@ function Implement(contract) {
119
119
  let ImplementInterceptor = class {
120
120
  config;
121
121
  codec;
122
- toStandardLazyRequest;
122
+ toNestStandardLazyRequest;
123
123
  httpAdapterHost;
124
124
  constructor(config, httpAdapterHost) {
125
125
  this.config = config ?? {};
126
126
  this.httpAdapterHost = httpAdapterHost;
127
127
  this.codec = new OpenAPIHandlerCodecCore(this.config);
128
- this.toStandardLazyRequest = this.config.toStandardLazyRequest ?? ((req, res) => {
128
+ this.toNestStandardLazyRequest = this.config.toNestStandardLazyRequest ?? ((req, res) => {
129
129
  const standardRequest = toStandardLazyRequest(
130
130
  "raw" in req ? req.raw : req,
131
131
  "raw" in res ? res.raw : res
@@ -133,6 +133,7 @@ let ImplementInterceptor = class {
133
133
  if (req.body !== void 0) {
134
134
  standardRequest.resolveBody = () => Promise.resolve(req.body);
135
135
  }
136
+ standardRequest.params = req.params;
136
137
  return standardRequest;
137
138
  });
138
139
  }
@@ -147,14 +148,14 @@ let ImplementInterceptor = class {
147
148
  }
148
149
  const req = ctx.switchToHttp().getRequest();
149
150
  const res = ctx.switchToHttp().getResponse();
150
- const standardRequest = this.toStandardLazyRequest(req, res);
151
+ const standardRequest = this.toNestStandardLazyRequest(req, res);
151
152
  const handler = new StandardHandler({
152
153
  resolveProcedure: () => Promise.resolve({
153
154
  path: getPathMeta(procedure) ?? [],
154
155
  procedure,
155
156
  decodeInput: () => this.codec.decodeInput({
156
157
  procedure,
157
- params: toORPCOpenAPIParams(procedure, req.params)
158
+ params: toORPCOpenAPIParams(procedure, standardRequest.params)
158
159
  }, standardRequest)
159
160
  }),
160
161
  encodeError: this.codec.encodeError.bind(this.codec),
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.10",
4
+ "version": "2.0.0-beta.11",
5
5
  "license": "MIT",
6
6
  "homepage": "https://orpc.dev",
7
7
  "repository": {
@@ -39,11 +39,11 @@
39
39
  "dependencies": {
40
40
  "@standardserver/core": "^0.0.25",
41
41
  "@standardserver/node": "^0.0.25",
42
- "@orpc/contract": "2.0.0-beta.10",
43
- "@orpc/server": "2.0.0-beta.10",
44
- "@orpc/client": "2.0.0-beta.10",
45
- "@orpc/shared": "2.0.0-beta.10",
46
- "@orpc/openapi": "2.0.0-beta.10"
42
+ "@orpc/contract": "2.0.0-beta.11",
43
+ "@orpc/server": "2.0.0-beta.11",
44
+ "@orpc/shared": "2.0.0-beta.11",
45
+ "@orpc/client": "2.0.0-beta.11",
46
+ "@orpc/openapi": "2.0.0-beta.11"
47
47
  },
48
48
  "devDependencies": {
49
49
  "@fastify/cookie": "^11.0.2",