@orpc/nest 2.0.0-beta.16 → 2.0.0-beta.18

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
@@ -7,6 +7,9 @@
7
7
  <a href="https://www.npmjs.com/package/@orpc/nest">
8
8
  <img alt="weekly downloads" src="https://img.shields.io/npm/dw/%40orpc%2Fnest?logo=npm" />
9
9
  </a>
10
+ <a href="https://app.codspeed.io/middleapi/orpc?utm_source=badge">
11
+ <img alt="CodSpeed" src="https://img.shields.io/endpoint?url=https://codspeed.io/badge.json" />
12
+ </a>
10
13
  <a href="https://github.com/middleapi/orpc/blob/main/LICENSE">
11
14
  <img alt="MIT License" src="https://img.shields.io/github/license/middleapi/orpc?logo=open-source-initiative" />
12
15
  </a>
@@ -175,7 +178,7 @@ Like what we build over at [middleapi](https://github.com/middleapi)? You can he
175
178
  <a href="https://github.com/illarionvk?ref=orpc" target="_blank" rel="noopener" title="Illarion Koperski"><img src="https://avatars.githubusercontent.com/u/5012724?u=7cfa13652f7ac5fb3c56d880e3eb3fbe40c3ea34&amp;v=4" width="32" height="32" alt="Illarion Koperski" /></a>
176
179
  <a href="https://github.com/steelbrain?ref=orpc" target="_blank" rel="noopener" title="Anees Iqbal"><img src="https://avatars.githubusercontent.com/u/4278113?u=22b80b5399eed68ac76cd58b02961b0481f1db11&amp;v=4" width="32" height="32" alt="Anees Iqbal" /></a>
177
180
  <a href="https://github.com/Scrumplex?ref=orpc" target="_blank" rel="noopener" title="Sefa Eyeoglu"><img src="https://avatars.githubusercontent.com/u/11587657?u=ab503582165c0bbff0cca47ce31c9450bb1553c9&amp;v=4" width="32" height="32" alt="Sefa Eyeoglu" /></a>
178
- <a href="https://github.com/nattstack?ref=orpc" target="_blank" rel="noopener" title="NΛTT"><img src="https://avatars.githubusercontent.com/u/31426677?u=fa9dbb8b3e66eb0ea3c88db5dc07f31c8c5418fe&amp;v=4" width="32" height="32" alt="NΛTT" /></a>
181
+ <a href="https://github.com/nattstack?ref=orpc" target="_blank" rel="noopener" title="natt"><img src="https://avatars.githubusercontent.com/u/31426677?u=fa9dbb8b3e66eb0ea3c88db5dc07f31c8c5418fe&amp;v=4" width="32" height="32" alt="natt" /></a>
179
182
  <a href="https://github.com/ChromeGG?ref=orpc" target="_blank" rel="noopener" title="Adam Tkaczyk"><img src="https://avatars.githubusercontent.com/u/39050595?u=a58ca6042a6950e94e6e92442db76ef584279bc0&amp;v=4" width="32" height="32" alt="Adam Tkaczyk" /></a>
180
183
  <a href="https://github.com/plancraft?ref=orpc" target="_blank" rel="noopener" title="plancraft"><img src="https://avatars.githubusercontent.com/u/46482287?v=4" width="32" height="32" alt="plancraft" /></a>
181
184
  </p>
package/dist/index.d.mts CHANGED
@@ -1,7 +1,7 @@
1
- import { DynamicModule, NestInterceptor, ExecutionContext, CallHandler } from '@nestjs/common';
1
+ import { ExecutionContext, DynamicModule, NestInterceptor, CallHandler } from '@nestjs/common';
2
2
  import { RouterContract } from '@orpc/contract';
3
3
  import { DefaultInitialContext, ContractedRouter } from '@orpc/server';
4
- import { Promisable } from '@orpc/shared';
4
+ import { Value, Promisable } from '@orpc/shared';
5
5
  import { Observable } from 'rxjs';
6
6
  import { OpenAPIHandlerCodecCoreOptions } from '@orpc/openapi/standard';
7
7
  import { StandardHandlerOptions } from '@orpc/server/standard';
@@ -17,9 +17,9 @@ interface NestStandardLazyRequest extends StandardLazyRequest {
17
17
  params?: undefined | Record<string, string | string[]>;
18
18
  }
19
19
  type ORPCModuleConfig = OpenAPIHandlerCodecCoreOptions<DefaultInitialContext> & StandardHandlerOptions<DefaultInitialContext> & (object extends DefaultInitialContext ? {
20
- context?: DefaultInitialContext;
20
+ context?: Value<Promisable<DefaultInitialContext>, [ctx: ExecutionContext]>;
21
21
  } : {
22
- context: DefaultInitialContext;
22
+ context: Value<Promisable<DefaultInitialContext>, [ctx: ExecutionContext]>;
23
23
  }) & {
24
24
  /**
25
25
  * Customize how to convert NestJS `req` and `res` to {@link NestStandardLazyRequest}.
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { DynamicModule, NestInterceptor, ExecutionContext, CallHandler } from '@nestjs/common';
1
+ import { ExecutionContext, DynamicModule, NestInterceptor, CallHandler } from '@nestjs/common';
2
2
  import { RouterContract } from '@orpc/contract';
3
3
  import { DefaultInitialContext, ContractedRouter } from '@orpc/server';
4
- import { Promisable } from '@orpc/shared';
4
+ import { Value, Promisable } from '@orpc/shared';
5
5
  import { Observable } from 'rxjs';
6
6
  import { OpenAPIHandlerCodecCoreOptions } from '@orpc/openapi/standard';
7
7
  import { StandardHandlerOptions } from '@orpc/server/standard';
@@ -17,9 +17,9 @@ interface NestStandardLazyRequest extends StandardLazyRequest {
17
17
  params?: undefined | Record<string, string | string[]>;
18
18
  }
19
19
  type ORPCModuleConfig = OpenAPIHandlerCodecCoreOptions<DefaultInitialContext> & StandardHandlerOptions<DefaultInitialContext> & (object extends DefaultInitialContext ? {
20
- context?: DefaultInitialContext;
20
+ context?: Value<Promisable<DefaultInitialContext>, [ctx: ExecutionContext]>;
21
21
  } : {
22
- context: DefaultInitialContext;
22
+ context: Value<Promisable<DefaultInitialContext>, [ctx: ExecutionContext]>;
23
23
  }) & {
24
24
  /**
25
25
  * Customize how to convert NestJS `req` and `res` to {@link NestStandardLazyRequest}.
package/dist/index.mjs CHANGED
@@ -6,7 +6,7 @@ import { getOpenAPIMeta, DEFAULT_OPENAPI_METHOD, getDynamicPathParams } from '@o
6
6
  import { OpenAPIHandlerCodecCore } from '@orpc/openapi/standard';
7
7
  import { DEFAULT_SUCCESS_STATUS, getRouter, unlazy, Procedure } from '@orpc/server';
8
8
  import { StandardHandler } from '@orpc/server/standard';
9
- import { mergeHttpPath, get, isAsyncIteratorObject, stringifyJSON } from '@orpc/shared';
9
+ import { mergeHttpPath, get, value, isAsyncIteratorObject, stringifyJSON } from '@orpc/shared';
10
10
  import { flattenStandardHeader, generateContentDisposition } from '@standardserver/core';
11
11
  import { toStandardLazyRequest, toEventStream } from '@standardserver/node';
12
12
  import { mergeMap } from 'rxjs';
@@ -162,7 +162,7 @@ let ImplementInterceptor = class {
162
162
  encodeOutput: this.codec.encodeOutput.bind(this.codec)
163
163
  }, this.config);
164
164
  const result = await handler.handle(standardRequest, {
165
- context: this.config.context ?? {}
165
+ context: await value(this.config.context ?? {}, ctx)
166
166
  });
167
167
  if (!result.matched) {
168
168
  throw new TypeError(
@@ -172,15 +172,15 @@ let ImplementInterceptor = class {
172
172
  const httpAdapter = this.httpAdapterHost.httpAdapter;
173
173
  httpAdapter.status(res, result.response.status);
174
174
  for (const key in result.response.headers) {
175
- const value = result.response.headers[key];
176
- if (typeof value === "string") {
177
- httpAdapter.setHeader(res, key, value);
175
+ const value2 = result.response.headers[key];
176
+ if (typeof value2 === "string") {
177
+ httpAdapter.setHeader(res, key, value2);
178
178
  } else {
179
- value?.forEach((value2, index) => {
179
+ value2?.forEach((value3, index) => {
180
180
  if (index === 0) {
181
- httpAdapter.setHeader(res, key, value2);
181
+ httpAdapter.setHeader(res, key, value3);
182
182
  } else {
183
- httpAdapter.appendHeader(res, key, value2);
183
+ httpAdapter.appendHeader(res, key, value3);
184
184
  }
185
185
  });
186
186
  }
@@ -234,8 +234,8 @@ ImplementInterceptor = __decorateClass([
234
234
  __decorateParam(0, Optional()),
235
235
  __decorateParam(1, Inject(HttpAdapterHost))
236
236
  ], ImplementInterceptor);
237
- function flattenParamValue(value) {
238
- return Array.isArray(value) ? value.join("/") : value;
237
+ function flattenParamValue(value2) {
238
+ return Array.isArray(value2) ? value2.join("/") : value2;
239
239
  }
240
240
  function toORPCOpenAPIParams(contract, params) {
241
241
  const meta = getOpenAPIMeta(contract);
@@ -247,11 +247,11 @@ function toORPCOpenAPIParams(contract, params) {
247
247
  return void 0;
248
248
  }
249
249
  return dynamicParams.reduce((acc, config) => {
250
- const value = config.allowsSlash ? flattenParamValue(params?.["*"] ?? params?.path) : flattenParamValue(params?.[config.parameterName]);
251
- if (value === void 0) {
250
+ const value2 = config.allowsSlash ? flattenParamValue(params?.["*"] ?? params?.path) : flattenParamValue(params?.[config.parameterName]);
251
+ if (value2 === void 0) {
252
252
  return acc;
253
253
  }
254
- acc[config.parameterName] = value;
254
+ acc[config.parameterName] = value2;
255
255
  return acc;
256
256
  }, {});
257
257
  }
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.16",
4
+ "version": "2.0.0-beta.18",
5
5
  "license": "MIT",
6
6
  "homepage": "https://orpc.dev",
7
7
  "repository": {
@@ -37,13 +37,13 @@
37
37
  }
38
38
  },
39
39
  "dependencies": {
40
- "@standardserver/core": "^0.2.0",
41
- "@standardserver/node": "^0.2.0",
42
- "@orpc/client": "2.0.0-beta.16",
43
- "@orpc/contract": "2.0.0-beta.16",
44
- "@orpc/shared": "2.0.0-beta.16",
45
- "@orpc/openapi": "2.0.0-beta.16",
46
- "@orpc/server": "2.0.0-beta.16"
40
+ "@standardserver/core": "^0.5.0",
41
+ "@standardserver/node": "^0.5.0",
42
+ "@orpc/client": "2.0.0-beta.18",
43
+ "@orpc/contract": "2.0.0-beta.18",
44
+ "@orpc/openapi": "2.0.0-beta.18",
45
+ "@orpc/server": "2.0.0-beta.18",
46
+ "@orpc/shared": "2.0.0-beta.18"
47
47
  },
48
48
  "devDependencies": {
49
49
  "@fastify/cookie": "^11.0.2",