@opra/nestjs 0.22.0 → 0.23.0

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.
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ApiDoc = exports.Context = void 0;
3
+ exports.Context = void 0;
4
4
  const handler_paramtype_enum_js_1 = require("../enums/handler-paramtype.enum.js");
5
5
  const param_utils_js_1 = require("../utils/param.utils.js");
6
6
  /**
@@ -8,8 +8,3 @@ const param_utils_js_1 = require("../utils/param.utils.js");
8
8
  * parameter with the value of `RequestContext`.
9
9
  */
10
10
  exports.Context = (0, param_utils_js_1.createOpraParamDecorator)(handler_paramtype_enum_js_1.HandlerParamType.CONTEXT);
11
- /**
12
- * Handler method parameter decorator. Populates the decorated
13
- * parameter with the value of `OpraService`.
14
- */
15
- exports.ApiDoc = (0, param_utils_js_1.createOpraParamDecorator)(handler_paramtype_enum_js_1.HandlerParamType.API);
@@ -4,7 +4,6 @@ exports.HandlerParamType = void 0;
4
4
  var HandlerParamType;
5
5
  (function (HandlerParamType) {
6
6
  HandlerParamType[HandlerParamType["CONTEXT"] = 0] = "CONTEXT";
7
- HandlerParamType[HandlerParamType["API"] = 1] = "API";
8
- HandlerParamType[HandlerParamType["REQUEST"] = 2] = "REQUEST";
9
- HandlerParamType[HandlerParamType["RESPONSE"] = 3] = "RESPONSE";
7
+ HandlerParamType[HandlerParamType["REQUEST"] = 1] = "REQUEST";
8
+ HandlerParamType[HandlerParamType["RESPONSE"] = 2] = "RESPONSE";
10
9
  })(HandlerParamType || (exports.HandlerParamType = HandlerParamType = {}));
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.OpraApiFactory = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const lodash_head_1 = tslib_1.__importDefault(require("lodash.head"));
6
- const lodash_identity_1 = tslib_1.__importDefault(require("lodash.identity"));
7
6
  const common_1 = require("@nestjs/common");
8
7
  const core_1 = require("@nestjs/core");
9
8
  const external_context_creator_1 = require("@nestjs/core/helpers/external-context-creator");
@@ -53,70 +52,68 @@ let OpraApiFactory = exports.OpraApiFactory = class OpraApiFactory {
53
52
  continue;
54
53
  resources.push(instance);
55
54
  /* Wrap resolver functions */
56
- const prototype = Object.getPrototypeOf(instance);
57
55
  const isRequestScoped = !wrapper.isDependencyTreeStatic();
58
56
  // const methodsToWrap = OpraSchema.isCollectionResource(resourceDef) ? collectionMethods : [];
59
57
  if ((common_2.OpraSchema.isCollection(resourceDef) || common_2.OpraSchema.isSingleton(resourceDef)) && resourceDef.operations) {
60
- for (const opr of Object.values(resourceDef.operations)) {
61
- const { handlerName } = opr;
62
- const fn = prototype[handlerName];
63
- if (typeof fn !== 'function')
58
+ for (const methodName of Object.keys(resourceDef.operations)) {
59
+ const operationFunction = instance[methodName];
60
+ const nestHandlerName = methodName + '_nestjs';
61
+ // Skip patch if controller do not have function for operation or already patched before
62
+ if (typeof operationFunction !== 'function')
64
63
  continue;
65
64
  // NestJs requires calling handler function in different order than Opra.
66
65
  // In NestJS, handler functions must be called with these parameters (req, res, next)
67
66
  // In Opra, handler functions must be called with these parameters (context)
68
67
  // To work handlers properly we create new handlers that will work as a proxy to wrap parameters
69
68
  // Opra request (context) -> Nest (req, res, next, context: QueryRequestContext) -> Opra response (context)
70
- const nestHandlerName = handlerName + '::nestjs';
71
- const paramArgsMetadata = Reflect.getMetadata(constants_js_1.PARAM_ARGS_METADATA, instance.constructor, handlerName);
69
+ const paramArgsMetadata = Reflect.getMetadata(constants_js_1.PARAM_ARGS_METADATA, instance.constructor, methodName);
72
70
  const hasParamsArgs = !!paramArgsMetadata;
73
- const patchedFn = prototype[nestHandlerName] = function (...args) {
71
+ const patchedFn = instance[nestHandlerName] = function (...args) {
74
72
  if (hasParamsArgs)
75
- return fn.apply(this, args);
76
- return fn.call(this, args[3]);
73
+ return operationFunction.apply(this, args);
74
+ return operationFunction.call(this, args[3]);
77
75
  };
78
76
  if (paramArgsMetadata)
79
77
  Reflect.defineMetadata(constants_js_1.PARAM_ARGS_METADATA, paramArgsMetadata, instance.constructor, nestHandlerName);
80
78
  // Copy all metadata from old Function to new one
81
- Reflect.getMetadataKeys(fn).forEach(k => {
82
- const m = Reflect.getMetadata(k, fn);
79
+ Reflect.getMetadataKeys(operationFunction).forEach(k => {
80
+ const m = Reflect.getMetadata(k, operationFunction);
83
81
  Reflect.defineMetadata(k, m, patchedFn);
84
82
  });
85
- const callback = this._createContextCallback(instance, prototype, wrapper, rootModule, nestHandlerName, isRequestScoped, undefined, contextType);
86
- opr.handler = function (ctx) {
87
- switch (ctx.protocol) {
88
- case 'http':
89
- const httpContext = ctx.switchToHttp();
90
- return callback(httpContext.request, httpContext.response, noOpFunction, ctx);
91
- default:
92
- throw new Error(`"${ctx.protocol}" context type is not implemented yet`);
93
- }
94
- };
95
- Object.defineProperty(opr.handler, 'name', {
96
- configurable: false,
97
- writable: false,
98
- enumerable: true,
99
- value: handlerName
100
- });
83
+ this._createContextCallback(instance, wrapper, rootModule, methodName, isRequestScoped, contextType);
101
84
  }
102
85
  }
103
86
  }
104
87
  // Create api document
105
88
  return common_2.DocumentFactory.createDocument(apiSchema);
106
89
  }
107
- _createContextCallback(instance, prototype, wrapper, moduleRef, methodName, isRequestScoped, transform = lodash_identity_1.default, contextType, options) {
90
+ _createHandler(instance, callback) {
91
+ return function (ctx) {
92
+ switch (ctx.protocol) {
93
+ case 'http':
94
+ const httpContext = ctx.switchToHttp();
95
+ return callback(httpContext.incoming, httpContext.outgoing, noOpFunction, ctx);
96
+ default:
97
+ throw new Error(`"${ctx.protocol}" context type is not implemented yet`);
98
+ }
99
+ };
100
+ }
101
+ _createContextCallback(instance, wrapper, moduleRef, methodName, isRequestScoped, contextType, options) {
108
102
  const paramsFactory = this.paramsFactory;
109
- if (isRequestScoped) {
110
- return async (...args) => {
103
+ const nestHandlerName = methodName + '_nestjs';
104
+ const callback = isRequestScoped
105
+ ? async (...args) => {
111
106
  const opraContext = paramsFactory.exchangeKeyForValue(handler_paramtype_enum_js_1.HandlerParamType.CONTEXT, undefined, args);
112
107
  const contextId = this.getContextId(opraContext);
113
108
  this.registerContextProvider(opraContext, contextId);
114
109
  const contextInstance = await this.injector.loadPerContext(instance, moduleRef, moduleRef.providers, contextId);
115
- const callback = this.externalContextCreator.create(contextInstance, transform(contextInstance[methodName]), methodName, constants_js_1.PARAM_ARGS_METADATA, paramsFactory, contextId, wrapper.id, options, opraContext.protocol);
116
- return callback(...args);
117
- };
118
- }
119
- return this.externalContextCreator.create(instance, prototype[methodName], methodName, constants_js_1.PARAM_ARGS_METADATA, paramsFactory, undefined, undefined, options, contextType);
110
+ const contextCallback = this.externalContextCreator.create(contextInstance, contextInstance[methodName], nestHandlerName, constants_js_1.PARAM_ARGS_METADATA, paramsFactory, contextId, wrapper.id, options, opraContext.protocol);
111
+ contextInstance[methodName] = this._createHandler(instance, contextCallback);
112
+ return contextCallback(...args);
113
+ }
114
+ : this.externalContextCreator.create(instance, instance[nestHandlerName], nestHandlerName, constants_js_1.PARAM_ARGS_METADATA, paramsFactory, undefined, undefined, options, contextType);
115
+ instance[methodName] = this._createHandler(instance, callback);
116
+ return callback;
120
117
  }
121
118
  // noinspection JSMethodCanBeStatic
122
119
  getContextId(gqlContext) {
@@ -11,8 +11,6 @@ class OpraParamsFactory {
11
11
  switch (type) {
12
12
  case handler_paramtype_enum_js_1.HandlerParamType.CONTEXT:
13
13
  return args[3];
14
- case handler_paramtype_enum_js_1.HandlerParamType.API:
15
- return args[3].api;
16
14
  case handler_paramtype_enum_js_1.HandlerParamType.REQUEST:
17
15
  return args[3].request;
18
16
  case handler_paramtype_enum_js_1.HandlerParamType.RESPONSE:
@@ -17,11 +17,13 @@ class OpraApiLoader {
17
17
  const globalPrefix = this.applicationConfig.getGlobalPrefix();
18
18
  const platformName = httpAdapter.getType();
19
19
  const moduleOptions = this.opraModuleOptions;
20
- const prefix = '/' + (0, common_2.normalizePath)((0, common_2.joinPath)((moduleOptions.useGlobalPrefix !== false ? globalPrefix : ''), moduleOptions.prefix || ''), true);
20
+ let prefixPath = new common_2.OpraURLPath((moduleOptions.useGlobalPrefix !== false ? globalPrefix : ''));
21
+ if (moduleOptions.basePath)
22
+ prefixPath = prefixPath.join(moduleOptions.basePath);
21
23
  const name = moduleOptions.info?.title || 'untitled service';
22
24
  const options = {
23
25
  ...moduleOptions,
24
- prefix
26
+ basePath: prefixPath.toString()
25
27
  };
26
28
  try {
27
29
  const serviceHost = await this.opraFactory.generateService(rootModule, options, 'http');
@@ -37,7 +39,7 @@ class OpraApiLoader {
37
39
  else { // noinspection ExceptionCaughtLocallyJS
38
40
  throw new Error(`No support for current HttpAdapter: ${platformName}`);
39
41
  }
40
- this.logger.log(`Mapped {${prefix}} to "${name}" service`);
42
+ this.logger.log(`Mapped {${prefixPath.toString() || '/'}} to "${name}" service`);
41
43
  }
42
44
  catch (e) {
43
45
  this.logger.error(e);
@@ -52,14 +54,10 @@ class OpraApiLoader {
52
54
  if (!httpAdapter)
53
55
  return;
54
56
  const app = httpAdapter.getInstance();
55
- let logger = moduleOptions.logger;
56
- if (!logger) {
57
- logger = new common_1.Logger(service.info.title);
58
- logger.fatal = logger.error.bind(logger);
59
- }
60
- return core_2.OpraExpressAdapter.create(app, service, {
57
+ const logger = moduleOptions.logger || new common_1.Logger(service.info.title);
58
+ return await core_2.ExpressAdapter.create(app, service, {
59
+ ...moduleOptions,
61
60
  logger,
62
- ...moduleOptions
63
61
  });
64
62
  }
65
63
  }
@@ -5,8 +5,3 @@ import { createOpraParamDecorator } from '../utils/param.utils.js';
5
5
  * parameter with the value of `RequestContext`.
6
6
  */
7
7
  export const Context = createOpraParamDecorator(HandlerParamType.CONTEXT);
8
- /**
9
- * Handler method parameter decorator. Populates the decorated
10
- * parameter with the value of `OpraService`.
11
- */
12
- export const ApiDoc = createOpraParamDecorator(HandlerParamType.API);
@@ -1,7 +1,6 @@
1
1
  export var HandlerParamType;
2
2
  (function (HandlerParamType) {
3
3
  HandlerParamType[HandlerParamType["CONTEXT"] = 0] = "CONTEXT";
4
- HandlerParamType[HandlerParamType["API"] = 1] = "API";
5
- HandlerParamType[HandlerParamType["REQUEST"] = 2] = "REQUEST";
6
- HandlerParamType[HandlerParamType["RESPONSE"] = 3] = "RESPONSE";
4
+ HandlerParamType[HandlerParamType["REQUEST"] = 1] = "REQUEST";
5
+ HandlerParamType[HandlerParamType["RESPONSE"] = 2] = "RESPONSE";
7
6
  })(HandlerParamType || (HandlerParamType = {}));
@@ -1,6 +1,5 @@
1
1
  import { __decorate, __metadata } from "tslib";
2
2
  import head from 'lodash.head';
3
- import identity from 'lodash.identity';
4
3
  import { Inject, Injectable } from '@nestjs/common';
5
4
  import { ContextIdFactory, createContextId, ModulesContainer, REQUEST } from '@nestjs/core';
6
5
  import { ExternalContextCreator } from '@nestjs/core/helpers/external-context-creator';
@@ -50,70 +49,68 @@ export let OpraApiFactory = class OpraApiFactory {
50
49
  continue;
51
50
  resources.push(instance);
52
51
  /* Wrap resolver functions */
53
- const prototype = Object.getPrototypeOf(instance);
54
52
  const isRequestScoped = !wrapper.isDependencyTreeStatic();
55
53
  // const methodsToWrap = OpraSchema.isCollectionResource(resourceDef) ? collectionMethods : [];
56
54
  if ((OpraSchema.isCollection(resourceDef) || OpraSchema.isSingleton(resourceDef)) && resourceDef.operations) {
57
- for (const opr of Object.values(resourceDef.operations)) {
58
- const { handlerName } = opr;
59
- const fn = prototype[handlerName];
60
- if (typeof fn !== 'function')
55
+ for (const methodName of Object.keys(resourceDef.operations)) {
56
+ const operationFunction = instance[methodName];
57
+ const nestHandlerName = methodName + '_nestjs';
58
+ // Skip patch if controller do not have function for operation or already patched before
59
+ if (typeof operationFunction !== 'function')
61
60
  continue;
62
61
  // NestJs requires calling handler function in different order than Opra.
63
62
  // In NestJS, handler functions must be called with these parameters (req, res, next)
64
63
  // In Opra, handler functions must be called with these parameters (context)
65
64
  // To work handlers properly we create new handlers that will work as a proxy to wrap parameters
66
65
  // Opra request (context) -> Nest (req, res, next, context: QueryRequestContext) -> Opra response (context)
67
- const nestHandlerName = handlerName + '::nestjs';
68
- const paramArgsMetadata = Reflect.getMetadata(PARAM_ARGS_METADATA, instance.constructor, handlerName);
66
+ const paramArgsMetadata = Reflect.getMetadata(PARAM_ARGS_METADATA, instance.constructor, methodName);
69
67
  const hasParamsArgs = !!paramArgsMetadata;
70
- const patchedFn = prototype[nestHandlerName] = function (...args) {
68
+ const patchedFn = instance[nestHandlerName] = function (...args) {
71
69
  if (hasParamsArgs)
72
- return fn.apply(this, args);
73
- return fn.call(this, args[3]);
70
+ return operationFunction.apply(this, args);
71
+ return operationFunction.call(this, args[3]);
74
72
  };
75
73
  if (paramArgsMetadata)
76
74
  Reflect.defineMetadata(PARAM_ARGS_METADATA, paramArgsMetadata, instance.constructor, nestHandlerName);
77
75
  // Copy all metadata from old Function to new one
78
- Reflect.getMetadataKeys(fn).forEach(k => {
79
- const m = Reflect.getMetadata(k, fn);
76
+ Reflect.getMetadataKeys(operationFunction).forEach(k => {
77
+ const m = Reflect.getMetadata(k, operationFunction);
80
78
  Reflect.defineMetadata(k, m, patchedFn);
81
79
  });
82
- const callback = this._createContextCallback(instance, prototype, wrapper, rootModule, nestHandlerName, isRequestScoped, undefined, contextType);
83
- opr.handler = function (ctx) {
84
- switch (ctx.protocol) {
85
- case 'http':
86
- const httpContext = ctx.switchToHttp();
87
- return callback(httpContext.request, httpContext.response, noOpFunction, ctx);
88
- default:
89
- throw new Error(`"${ctx.protocol}" context type is not implemented yet`);
90
- }
91
- };
92
- Object.defineProperty(opr.handler, 'name', {
93
- configurable: false,
94
- writable: false,
95
- enumerable: true,
96
- value: handlerName
97
- });
80
+ this._createContextCallback(instance, wrapper, rootModule, methodName, isRequestScoped, contextType);
98
81
  }
99
82
  }
100
83
  }
101
84
  // Create api document
102
85
  return DocumentFactory.createDocument(apiSchema);
103
86
  }
104
- _createContextCallback(instance, prototype, wrapper, moduleRef, methodName, isRequestScoped, transform = identity, contextType, options) {
87
+ _createHandler(instance, callback) {
88
+ return function (ctx) {
89
+ switch (ctx.protocol) {
90
+ case 'http':
91
+ const httpContext = ctx.switchToHttp();
92
+ return callback(httpContext.incoming, httpContext.outgoing, noOpFunction, ctx);
93
+ default:
94
+ throw new Error(`"${ctx.protocol}" context type is not implemented yet`);
95
+ }
96
+ };
97
+ }
98
+ _createContextCallback(instance, wrapper, moduleRef, methodName, isRequestScoped, contextType, options) {
105
99
  const paramsFactory = this.paramsFactory;
106
- if (isRequestScoped) {
107
- return async (...args) => {
100
+ const nestHandlerName = methodName + '_nestjs';
101
+ const callback = isRequestScoped
102
+ ? async (...args) => {
108
103
  const opraContext = paramsFactory.exchangeKeyForValue(HandlerParamType.CONTEXT, undefined, args);
109
104
  const contextId = this.getContextId(opraContext);
110
105
  this.registerContextProvider(opraContext, contextId);
111
106
  const contextInstance = await this.injector.loadPerContext(instance, moduleRef, moduleRef.providers, contextId);
112
- const callback = this.externalContextCreator.create(contextInstance, transform(contextInstance[methodName]), methodName, PARAM_ARGS_METADATA, paramsFactory, contextId, wrapper.id, options, opraContext.protocol);
113
- return callback(...args);
114
- };
115
- }
116
- return this.externalContextCreator.create(instance, prototype[methodName], methodName, PARAM_ARGS_METADATA, paramsFactory, undefined, undefined, options, contextType);
107
+ const contextCallback = this.externalContextCreator.create(contextInstance, contextInstance[methodName], nestHandlerName, PARAM_ARGS_METADATA, paramsFactory, contextId, wrapper.id, options, opraContext.protocol);
108
+ contextInstance[methodName] = this._createHandler(instance, contextCallback);
109
+ return contextCallback(...args);
110
+ }
111
+ : this.externalContextCreator.create(instance, instance[nestHandlerName], nestHandlerName, PARAM_ARGS_METADATA, paramsFactory, undefined, undefined, options, contextType);
112
+ instance[methodName] = this._createHandler(instance, callback);
113
+ return callback;
117
114
  }
118
115
  // noinspection JSMethodCanBeStatic
119
116
  getContextId(gqlContext) {
@@ -8,8 +8,6 @@ export class OpraParamsFactory {
8
8
  switch (type) {
9
9
  case HandlerParamType.CONTEXT:
10
10
  return args[3];
11
- case HandlerParamType.API:
12
- return args[3].api;
13
11
  case HandlerParamType.REQUEST:
14
12
  return args[3].request;
15
13
  case HandlerParamType.RESPONSE:
@@ -1,8 +1,8 @@
1
1
  import { __decorate, __metadata } from "tslib";
2
2
  import { Inject, Logger } from '@nestjs/common';
3
3
  import { ApplicationConfig, HttpAdapterHost } from '@nestjs/core';
4
- import { joinPath, normalizePath } from '@opra/common';
5
- import { OpraExpressAdapter } from '@opra/core';
4
+ import { OpraURLPath } from '@opra/common';
5
+ import { ExpressAdapter } from '@opra/core';
6
6
  import { OPRA_MODULE_OPTIONS } from '../constants.js';
7
7
  import { OpraApiFactory } from '../factories/opra-api.factory.js';
8
8
  export class OpraApiLoader {
@@ -14,11 +14,13 @@ export class OpraApiLoader {
14
14
  const globalPrefix = this.applicationConfig.getGlobalPrefix();
15
15
  const platformName = httpAdapter.getType();
16
16
  const moduleOptions = this.opraModuleOptions;
17
- const prefix = '/' + normalizePath(joinPath((moduleOptions.useGlobalPrefix !== false ? globalPrefix : ''), moduleOptions.prefix || ''), true);
17
+ let prefixPath = new OpraURLPath((moduleOptions.useGlobalPrefix !== false ? globalPrefix : ''));
18
+ if (moduleOptions.basePath)
19
+ prefixPath = prefixPath.join(moduleOptions.basePath);
18
20
  const name = moduleOptions.info?.title || 'untitled service';
19
21
  const options = {
20
22
  ...moduleOptions,
21
- prefix
23
+ basePath: prefixPath.toString()
22
24
  };
23
25
  try {
24
26
  const serviceHost = await this.opraFactory.generateService(rootModule, options, 'http');
@@ -34,7 +36,7 @@ export class OpraApiLoader {
34
36
  else { // noinspection ExceptionCaughtLocallyJS
35
37
  throw new Error(`No support for current HttpAdapter: ${platformName}`);
36
38
  }
37
- this.logger.log(`Mapped {${prefix}} to "${name}" service`);
39
+ this.logger.log(`Mapped {${prefixPath.toString() || '/'}} to "${name}" service`);
38
40
  }
39
41
  catch (e) {
40
42
  this.logger.error(e);
@@ -49,14 +51,10 @@ export class OpraApiLoader {
49
51
  if (!httpAdapter)
50
52
  return;
51
53
  const app = httpAdapter.getInstance();
52
- let logger = moduleOptions.logger;
53
- if (!logger) {
54
- logger = new Logger(service.info.title);
55
- logger.fatal = logger.error.bind(logger);
56
- }
57
- return OpraExpressAdapter.create(app, service, {
54
+ const logger = moduleOptions.logger || new Logger(service.info.title);
55
+ return await ExpressAdapter.create(app, service, {
56
+ ...moduleOptions,
58
57
  logger,
59
- ...moduleOptions
60
58
  });
61
59
  }
62
60
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opra/nestjs",
3
- "version": "0.22.0",
3
+ "version": "0.23.0",
4
4
  "description": "Opra NestJS module",
5
5
  "author": "Panates",
6
6
  "license": "MIT",
@@ -25,8 +25,8 @@
25
25
  "clean:cover": "rimraf ../../coverage/nestjs"
26
26
  },
27
27
  "dependencies": {
28
- "@opra/common": "^0.22.0",
29
- "@opra/core": "^0.22.0",
28
+ "@opra/common": "^0.23.0",
29
+ "@opra/core": "^0.23.0",
30
30
  "fast-tokenizer": "^1.2.2",
31
31
  "lodash.head": "^4.0.1",
32
32
  "lodash.identity": "^3.0.0",
@@ -39,7 +39,8 @@
39
39
  "@nestjs/platform-express": "^10.1.0",
40
40
  "@nestjs/testing": "^10.1.0",
41
41
  "@types/lodash": "^4.14.195",
42
- "filedirname": "^2.7.0"
42
+ "filedirname": "^2.7.0",
43
+ "ts-gems": "^2.4.1"
43
44
  },
44
45
  "type": "module",
45
46
  "types": "types/index.d.ts",
@@ -3,8 +3,3 @@
3
3
  * parameter with the value of `RequestContext`.
4
4
  */
5
5
  export declare const Context: ParameterDecorator;
6
- /**
7
- * Handler method parameter decorator. Populates the decorated
8
- * parameter with the value of `OpraService`.
9
- */
10
- export declare const ApiDoc: ParameterDecorator;
@@ -1,6 +1,5 @@
1
1
  export declare enum HandlerParamType {
2
2
  CONTEXT = 0,
3
- API = 1,
4
- REQUEST = 2,
5
- RESPONSE = 3
3
+ REQUEST = 1,
4
+ RESPONSE = 2
6
5
  }
@@ -9,6 +9,7 @@ export declare class OpraApiFactory {
9
9
  private readonly externalContextCreator;
10
10
  private readonly explorerService;
11
11
  generateService(rootModule: Module, moduleOptions: OpraModuleOptions, contextType: ContextType): Promise<ApiDocument>;
12
+ private _createHandler;
12
13
  private _createContextCallback;
13
14
  private getContextId;
14
15
  private registerContextProvider;
@@ -1,7 +1,7 @@
1
1
  import { ModuleMetadata, Type } from '@nestjs/common';
2
2
  import { OpraSchema } from '@opra/common';
3
- import { OpraHttpAdapter } from '@opra/core';
4
- export type OpraModuleOptions = OpraHttpAdapter.Options & {
3
+ import { HttpAdapter } from '@opra/core';
4
+ export type OpraModuleOptions = HttpAdapter.Options & {
5
5
  info?: OpraSchema.DocumentInfo;
6
6
  /**
7
7
  * @default true
@@ -1,17 +1,18 @@
1
+ import { Logger } from '@nestjs/common';
1
2
  import { ApplicationConfig, HttpAdapterHost } from '@nestjs/core';
2
3
  import { Module } from '@nestjs/core/injector/module.js';
3
4
  import { ApiDocument } from '@opra/common';
4
- import { OpraExpressAdapter } from '@opra/core';
5
+ import { ExpressAdapter, PlatformAdapter } from '@opra/core';
5
6
  import { OpraApiFactory } from '../factories/opra-api.factory.js';
6
7
  import { OpraModuleOptions } from '../interfaces/opra-module-options.interface.js';
7
8
  export declare class OpraApiLoader {
8
- private readonly logger;
9
- private adapter;
9
+ protected readonly logger: Logger;
10
+ protected adapter: PlatformAdapter | undefined;
10
11
  protected readonly httpAdapterHost: HttpAdapterHost;
11
12
  protected readonly applicationConfig: ApplicationConfig;
12
13
  protected readonly opraFactory: OpraApiFactory;
13
14
  protected readonly opraModuleOptions: OpraModuleOptions;
14
15
  initialize(rootModule: Module): Promise<void>;
15
16
  stop(): Promise<void>;
16
- protected registerExpress(service: ApiDocument, moduleOptions: OpraModuleOptions): Promise<OpraExpressAdapter | undefined>;
17
+ protected registerExpress(service: ApiDocument, moduleOptions: OpraModuleOptions): Promise<ExpressAdapter | undefined>;
17
18
  }