@rsdk/core 3.1.0 → 3.2.0-next.1
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/CHANGELOG.md +12 -0
- package/dist/app/platform.app.js +1 -1
- package/dist/app/platform.app.js.map +1 -1
- package/dist/manifest/manifest.js +0 -2
- package/dist/manifest/manifest.js.map +1 -1
- package/dist/platform.context.d.ts +8 -4
- package/dist/platform.context.js +15 -7
- package/dist/platform.context.js.map +1 -1
- package/dist/types/transports.d.ts +2 -3
- package/dist/types/transports.js.map +1 -1
- package/package.json +6 -6
- package/src/app/platform.app.ts +1 -1
- package/src/manifest/manifest.ts +0 -2
- package/src/platform.context.ts +19 -10
- package/src/types/transports.ts +2 -3
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,18 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [3.2.0-next.1](https://github.com/R-Vision/rsdk/compare/v3.2.0-next.0...v3.2.0-next.1) (2023-08-09)
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* **testing:** create tests is possible outside of applications ([36455da](https://github.com/R-Vision/rsdk/commit/36455da408927b00e0c02bc37a94d0c0f9cbef20))
|
|
11
|
+
|
|
12
|
+
## [3.2.0-next.0](https://github.com/R-Vision/rsdk/compare/v3.1.0...v3.2.0-next.0) (2023-08-09)
|
|
13
|
+
|
|
14
|
+
### Features
|
|
15
|
+
|
|
16
|
+
* **http.server:** split to package by implementation @rsdk/http.server.{fastify,express} ([f3cdad1](https://github.com/R-Vision/rsdk/commit/f3cdad1c7372d2bfbaee21d91973d5354cebf46c))
|
|
17
|
+
|
|
6
18
|
## [3.1.0](https://github.com/R-Vision/rsdk/compare/v3.1.0-next.3...v3.1.0) (2023-08-09)
|
|
7
19
|
|
|
8
20
|
**Note:** Version bump only for package @rsdk/core
|
package/dist/app/platform.app.js
CHANGED
|
@@ -39,7 +39,7 @@ class PlatformApp {
|
|
|
39
39
|
*/
|
|
40
40
|
async createApplication() {
|
|
41
41
|
const context = this.context;
|
|
42
|
-
const nestContext = context.getNestFactoryCreateOptions();
|
|
42
|
+
const nestContext = await context.getNestFactoryCreateOptions();
|
|
43
43
|
const app = await core_1.NestFactory.create(await context.getRoot(), ...nestContext);
|
|
44
44
|
await context.configureApp(app);
|
|
45
45
|
return app;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"platform.app.js","sourceRoot":"","sources":["../../src/app/platform.app.ts"],"names":[],"mappings":";;;AACA,uCAA2C;AAE3C,0DAAsD;AAGtD;;;;;GAKG;AACH,MAAa,WAAW;IAGD;IAFZ,OAAO,CAAkB;IAElC,YAAqB,kBAAsC;QAAtC,uBAAkB,GAAlB,kBAAkB,CAAoB;QACzD,IAAI,CAAC,OAAO,GAAG,IAAI,kCAAe,CAAC,kBAAkB,CAAC,CAAC;IACzD,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,WAAW;QACf,OAAO,MAAM,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC;IAC1C,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,GAAG;QACP,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;QAC7B,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,iBAAiB,EAAE,CAAC;QAE3C,MAAM,OAAO,CAAC,wBAAwB,CAAC,GAAG,CAAC,CAAC;IAC9C,CAAC;IAED;;;;OAIG;IACK,KAAK,CAAC,iBAAiB;QAC7B,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;QAC7B,MAAM,WAAW,GAAG,OAAO,CAAC,2BAA2B,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"platform.app.js","sourceRoot":"","sources":["../../src/app/platform.app.ts"],"names":[],"mappings":";;;AACA,uCAA2C;AAE3C,0DAAsD;AAGtD;;;;;GAKG;AACH,MAAa,WAAW;IAGD;IAFZ,OAAO,CAAkB;IAElC,YAAqB,kBAAsC;QAAtC,uBAAkB,GAAlB,kBAAkB,CAAoB;QACzD,IAAI,CAAC,OAAO,GAAG,IAAI,kCAAe,CAAC,kBAAkB,CAAC,CAAC;IACzD,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,WAAW;QACf,OAAO,MAAM,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC;IAC1C,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,GAAG;QACP,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;QAC7B,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,iBAAiB,EAAE,CAAC;QAE3C,MAAM,OAAO,CAAC,wBAAwB,CAAC,GAAG,CAAC,CAAC;IAC9C,CAAC;IAED;;;;OAIG;IACK,KAAK,CAAC,iBAAiB;QAC7B,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;QAC7B,MAAM,WAAW,GAAG,MAAM,OAAO,CAAC,2BAA2B,EAAE,CAAC;QAChE,MAAM,GAAG,GAAG,MAAM,kBAAW,CAAC,MAAM,CAClC,MAAM,OAAO,CAAC,OAAO,EAAE,EACvB,GAAG,WAAW,CACf,CAAC;QAEF,MAAM,OAAO,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC;QAChC,OAAO,GAAG,CAAC;IACb,CAAC;CACF;AA1CD,kCA0CC"}
|
|
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.Manifest = void 0;
|
|
4
4
|
const node_path_1 = require("node:path");
|
|
5
5
|
const node_process_1 = require("node:process");
|
|
6
|
-
const app_metadata_1 = require("../app-metadata");
|
|
7
6
|
/**
|
|
8
7
|
* Утилитарный класс для вывода данных из `package.json`
|
|
9
8
|
*/
|
|
@@ -15,7 +14,6 @@ class Manifest {
|
|
|
15
14
|
const path = manifestPath || (0, node_path_1.join)((0, node_process_1.cwd)(), 'package.json');
|
|
16
15
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
17
16
|
const { name, description, version } = require(path);
|
|
18
|
-
(0, app_metadata_1.assertAppName)(name);
|
|
19
17
|
return { name, description, version };
|
|
20
18
|
}
|
|
21
19
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manifest.js","sourceRoot":"","sources":["../../src/manifest/manifest.ts"],"names":[],"mappings":";;;AAAA,yCAAiC;AACjC,+CAAmC;
|
|
1
|
+
{"version":3,"file":"manifest.js","sourceRoot":"","sources":["../../src/manifest/manifest.ts"],"names":[],"mappings":";;;AAAA,yCAAiC;AACjC,+CAAmC;AAInC;;GAEG;AACH,MAAa,QAAQ;IACnB,MAAM,CAAC,OAAO,CAAC,YAAqB;QAClC;;WAEG;QACH,MAAM,IAAI,GAAG,YAAY,IAAI,IAAA,gBAAI,EAAC,IAAA,kBAAG,GAAE,EAAE,cAAc,CAAC,CAAC;QAEzD,8DAA8D;QAC9D,MAAM,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,IAAI,CAAiB,CAAC;QAErE,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,CAAC;IACxC,CAAC;CACF;AAZD,4BAYC"}
|
|
@@ -9,10 +9,12 @@ import type { PlatformAppMetadata, PlatformExtendedOptions, PlatformOptions } fr
|
|
|
9
9
|
*/
|
|
10
10
|
export declare class PlatformContext {
|
|
11
11
|
readonly options: PlatformOptions;
|
|
12
|
+
readonly strictnessOptions?: {
|
|
13
|
+
skipAssertAppName?: boolean;
|
|
14
|
+
} | undefined;
|
|
12
15
|
readonly logger: import("@rsdk/logging").ILogger;
|
|
13
16
|
private microservices;
|
|
14
17
|
private readonly httpTransport;
|
|
15
|
-
private readonly httpAdapter;
|
|
16
18
|
private aggregator;
|
|
17
19
|
private _extendedOptions?;
|
|
18
20
|
/**
|
|
@@ -23,7 +25,9 @@ export declare class PlatformContext {
|
|
|
23
25
|
* А также инициализирует конфигурацию согласно требованиям платформы
|
|
24
26
|
* @param options
|
|
25
27
|
*/
|
|
26
|
-
constructor(options: PlatformOptions
|
|
28
|
+
constructor(options: PlatformOptions, strictnessOptions?: {
|
|
29
|
+
skipAssertAppName?: boolean;
|
|
30
|
+
} | undefined);
|
|
27
31
|
get extendedOptions(): PlatformExtendedOptions;
|
|
28
32
|
private static assertPluginCompatability;
|
|
29
33
|
private static assertTransportCompatability;
|
|
@@ -52,9 +56,9 @@ export declare class PlatformContext {
|
|
|
52
56
|
* testingModuleRef.createApplication(...context.getNestFactoryCreateOptions())
|
|
53
57
|
* NestFactory.create(context.root, ...context.getNestFactoryCreateOptions())
|
|
54
58
|
*/
|
|
55
|
-
getNestFactoryCreateOptions(): [
|
|
59
|
+
getNestFactoryCreateOptions(): Promise<[
|
|
56
60
|
httpAdapter: AbstractHttpAdapter,
|
|
57
61
|
options?: NestApplicationOptions
|
|
58
|
-
]
|
|
62
|
+
]>;
|
|
59
63
|
private getConfigContext;
|
|
60
64
|
}
|
package/dist/platform.context.js
CHANGED
|
@@ -5,6 +5,7 @@ const logging_1 = require("@rsdk/logging");
|
|
|
5
5
|
const lodash_1 = require("lodash");
|
|
6
6
|
const config_metadata_provider_1 = require("./config/metadata/config-metadata.provider");
|
|
7
7
|
const manifest_1 = require("./manifest/manifest");
|
|
8
|
+
const app_metadata_1 = require("./app-metadata");
|
|
8
9
|
const context_aggregator_1 = require("./context.aggregator");
|
|
9
10
|
const exceptions_1 = require("./exceptions");
|
|
10
11
|
const logging_2 = require("./logging");
|
|
@@ -15,10 +16,10 @@ const types_1 = require("./types");
|
|
|
15
16
|
*/
|
|
16
17
|
class PlatformContext {
|
|
17
18
|
options;
|
|
19
|
+
strictnessOptions;
|
|
18
20
|
logger = logging_1.LoggerFactory.create('App');
|
|
19
21
|
microservices = new Map();
|
|
20
22
|
httpTransport;
|
|
21
|
-
httpAdapter;
|
|
22
23
|
aggregator;
|
|
23
24
|
_extendedOptions;
|
|
24
25
|
/**
|
|
@@ -29,13 +30,12 @@ class PlatformContext {
|
|
|
29
30
|
* А также инициализирует конфигурацию согласно требованиям платформы
|
|
30
31
|
* @param options
|
|
31
32
|
*/
|
|
32
|
-
constructor(options) {
|
|
33
|
+
constructor(options, strictnessOptions) {
|
|
33
34
|
this.options = options;
|
|
35
|
+
this.strictnessOptions = strictnessOptions;
|
|
34
36
|
PlatformContext.assertTransportCompatability(options);
|
|
35
37
|
PlatformContext.assertPluginCompatability(options);
|
|
36
38
|
this.httpTransport = options.transports?.find?.(types_1.isHttpTransport);
|
|
37
|
-
this.httpAdapter =
|
|
38
|
-
this.httpTransport?.getAdapter() ?? new noop_http_adapter_1.NoopHttpAdapter();
|
|
39
39
|
this.aggregator = new context_aggregator_1.ContextAggregator(this);
|
|
40
40
|
}
|
|
41
41
|
get extendedOptions() {
|
|
@@ -44,6 +44,12 @@ class PlatformContext {
|
|
|
44
44
|
}
|
|
45
45
|
const manifestData = manifest_1.Manifest.getData(this.options.manifestPath);
|
|
46
46
|
const { name, description, version } = manifestData;
|
|
47
|
+
if (this.strictnessOptions?.skipAssertAppName) {
|
|
48
|
+
this.logger.warn('assert app name skipped');
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
(0, app_metadata_1.assertAppName)(name);
|
|
52
|
+
}
|
|
47
53
|
const extendedOptions = {
|
|
48
54
|
description,
|
|
49
55
|
name,
|
|
@@ -112,7 +118,7 @@ class PlatformContext {
|
|
|
112
118
|
*/
|
|
113
119
|
async configureApp(app) {
|
|
114
120
|
const configContext = await this.getConfigContext();
|
|
115
|
-
const awaiter = this.httpTransport?.
|
|
121
|
+
const awaiter = this.httpTransport?.configureApp(app, configContext);
|
|
116
122
|
if (awaiter instanceof Promise) {
|
|
117
123
|
await awaiter;
|
|
118
124
|
}
|
|
@@ -163,9 +169,11 @@ class PlatformContext {
|
|
|
163
169
|
* testingModuleRef.createApplication(...context.getNestFactoryCreateOptions())
|
|
164
170
|
* NestFactory.create(context.root, ...context.getNestFactoryCreateOptions())
|
|
165
171
|
*/
|
|
166
|
-
getNestFactoryCreateOptions() {
|
|
172
|
+
async getNestFactoryCreateOptions() {
|
|
173
|
+
const configContext = await this.getConfigContext();
|
|
174
|
+
const httpAdapter = await this.httpTransport?.createAdapter(configContext);
|
|
167
175
|
return [
|
|
168
|
-
|
|
176
|
+
httpAdapter ?? new noop_http_adapter_1.NoopHttpAdapter(),
|
|
169
177
|
{
|
|
170
178
|
// Leave body parser configuration to httpTransport implementation
|
|
171
179
|
bodyParser: false,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"platform.context.js","sourceRoot":"","sources":["../src/platform.context.ts"],"names":[],"mappings":";;;AAKA,2CAA8C;AAE9C,mCAA+C;AAE/C,yFAAoF;AACpF,kDAA+C;AAE/C,6DAAyD;AACzD,6CAGsB;AACtB,uCAA8C;AAC9C,2DAAsD;AAQtD,mCAMiB;AAEjB;;GAEG;AACH,MAAa,eAAe;
|
|
1
|
+
{"version":3,"file":"platform.context.js","sourceRoot":"","sources":["../src/platform.context.ts"],"names":[],"mappings":";;;AAKA,2CAA8C;AAE9C,mCAA+C;AAE/C,yFAAoF;AACpF,kDAA+C;AAC/C,iDAA+C;AAE/C,6DAAyD;AACzD,6CAGsB;AACtB,uCAA8C;AAC9C,2DAAsD;AAQtD,mCAMiB;AAEjB;;GAEG;AACH,MAAa,eAAe;IAkBf;IACA;IAlBF,MAAM,GAAG,uBAAa,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACtC,aAAa,GAAG,IAAI,GAAG,EAA6C,CAAC;IAE5D,aAAa,CAA6B;IACnD,UAAU,CAAoB;IAE9B,gBAAgB,CAA2B;IAEnD;;;;;;;OAOG;IACH,YACW,OAAwB,EACxB,iBAAmD;QADnD,YAAO,GAAP,OAAO,CAAiB;QACxB,sBAAiB,GAAjB,iBAAiB,CAAkC;QAE5D,eAAe,CAAC,4BAA4B,CAAC,OAAO,CAAC,CAAC;QACtD,eAAe,CA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aAAa,EAAE,aAAa,CAAC,aAAa,CAAC,CAAC;QAE3E,OAAO;YACL,WAAW,IAAI,IAAI,mCAAe,EAAE;YACpC;gBACE,kEAAkE;gBAClE,UAAU,EAAE,KAAK;gBACjB,MAAM,EAAE,IAAI,2BAAiB,CAAC,IAAI,CAAC,MAAM,CAAC;aAC3C;SACF,CAAC;IACJ,CAAC;IAEO,gBAAgB;QACtB,OAAO,IAAI,CAAC,UAAU,CAAC,gBAAgB,EAAE,CAAC;IAC5C,CAAC;CACF;AAxND,0CAwNC"}
|
|
@@ -77,14 +77,13 @@ export interface IHttpTransport extends IPrimaryTransport {
|
|
|
77
77
|
* Most common are ExpressAdapter and FastifyAdater,
|
|
78
78
|
* but custom adapter can be implemented if needed
|
|
79
79
|
*/
|
|
80
|
-
|
|
80
|
+
createAdapter(configContext: ConfigContext): AbstractHttpAdapter;
|
|
81
81
|
/**
|
|
82
82
|
* Applies any configuration to Nest application instance:
|
|
83
83
|
* middleware, body parsers and other.
|
|
84
84
|
* @param app INestApplication
|
|
85
|
-
* @param configContext
|
|
86
85
|
*/
|
|
87
|
-
|
|
86
|
+
configureApp(app: INestApplication, configContext: ConfigContext): Promise<void> | void;
|
|
88
87
|
createHttpOptions(configContext: ConfigContext): HttpOptions;
|
|
89
88
|
}
|
|
90
89
|
export declare const isPrimaryTransport: (t: ITransport) => t is IPrimaryTransport;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transports.js","sourceRoot":"","sources":["../../src/types/transports.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"transports.js","sourceRoot":"","sources":["../../src/types/transports.ts"],"names":[],"mappings":";;;AA8GO,MAAM,kBAAkB,GAAG,CAAC,CAAa,EAA0B,EAAE,CAC1E,OAAQ,CAAuB,CAAC,mBAAmB,KAAK,UAAU;IAClE,OAAQ,CAAuB,CAAC,oBAAoB,KAAK,UAAU,CAAC;AAFzD,QAAA,kBAAkB,sBAEuC;AAE/D,MAAM,eAAe,GAAG,CAAC,CAAa,EAAuB,EAAE,CACpE,CAAC,CAAC,WAAW,EAAE,KAAK,MAAM,CAAC;AADhB,QAAA,eAAe,mBACC;AAEtB,MAAM,uBAAuB,GAAG,CACrC,CAAa,EACgB,EAAE,CAC/B,OAAQ,CAA4B,CAAC,yBAAyB,KAAK,UAAU,CAAC;AAHnE,QAAA,uBAAuB,2BAG4C"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rsdk/core",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.2.0-next.1",
|
|
4
4
|
"description": "Nestjs based microservice chassis",
|
|
5
5
|
"license": "Apache License 2.0",
|
|
6
6
|
"publishConfig": {
|
|
@@ -31,17 +31,17 @@
|
|
|
31
31
|
"@nestjs/common": "^10.1.3",
|
|
32
32
|
"@nestjs/core": "^10.1.3",
|
|
33
33
|
"@nestjs/microservices": "^10.1.3",
|
|
34
|
-
"@rsdk/autodoc.protocol": "^3.
|
|
34
|
+
"@rsdk/autodoc.protocol": "^3.2.0-next.1",
|
|
35
35
|
"@rsdk/common": "^3.1.0",
|
|
36
36
|
"@rsdk/common.nestjs": "^3.1.0",
|
|
37
37
|
"@rsdk/common.node": "^3.1.0",
|
|
38
|
-
"@rsdk/decorators": "^3.
|
|
39
|
-
"@rsdk/logging": "^3.
|
|
40
|
-
"@rsdk/metadata": "^3.
|
|
38
|
+
"@rsdk/decorators": "^3.2.0-next.1",
|
|
39
|
+
"@rsdk/logging": "^3.2.0-next.1",
|
|
40
|
+
"@rsdk/metadata": "^3.2.0-next.1",
|
|
41
41
|
"@rsdk/nest-tools": "^3.1.0",
|
|
42
42
|
"axios": "^1.1.3",
|
|
43
43
|
"reflect-metadata": "^0.1.13",
|
|
44
44
|
"rxjs": "^7.0.0"
|
|
45
45
|
},
|
|
46
|
-
"gitHead": "
|
|
46
|
+
"gitHead": "9f5c3bb74ae420f57f0bcb4a2ea1a11db6f21a8f"
|
|
47
47
|
}
|
package/src/app/platform.app.ts
CHANGED
|
@@ -43,7 +43,7 @@ export class PlatformApp {
|
|
|
43
43
|
*/
|
|
44
44
|
private async createApplication(): Promise<INestApplication> {
|
|
45
45
|
const context = this.context;
|
|
46
|
-
const nestContext = context.getNestFactoryCreateOptions();
|
|
46
|
+
const nestContext = await context.getNestFactoryCreateOptions();
|
|
47
47
|
const app = await NestFactory.create(
|
|
48
48
|
await context.getRoot(),
|
|
49
49
|
...nestContext,
|
package/src/manifest/manifest.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { join } from 'node:path';
|
|
2
2
|
import { cwd } from 'node:process';
|
|
3
3
|
|
|
4
|
-
import { assertAppName } from '../app-metadata';
|
|
5
4
|
import type { ManifestData } from '../types';
|
|
6
5
|
|
|
7
6
|
/**
|
|
@@ -17,7 +16,6 @@ export class Manifest {
|
|
|
17
16
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
18
17
|
const { name, description, version } = require(path) as ManifestData;
|
|
19
18
|
|
|
20
|
-
assertAppName(name);
|
|
21
19
|
return { name, description, version };
|
|
22
20
|
}
|
|
23
21
|
}
|
package/src/platform.context.ts
CHANGED
|
@@ -9,6 +9,7 @@ import { groupBy, intersection } from 'lodash';
|
|
|
9
9
|
|
|
10
10
|
import { ConfigMetadataProvider } from './config/metadata/config-metadata.provider';
|
|
11
11
|
import { Manifest } from './manifest/manifest';
|
|
12
|
+
import { assertAppName } from './app-metadata';
|
|
12
13
|
import type { Config, ConfigContext, SectionMetadata } from './config';
|
|
13
14
|
import { ContextAggregator } from './context.aggregator';
|
|
14
15
|
import {
|
|
@@ -40,7 +41,6 @@ export class PlatformContext {
|
|
|
40
41
|
private microservices = new Map<INestMicroservice, IMicroserviceTransport>();
|
|
41
42
|
|
|
42
43
|
private readonly httpTransport: IHttpTransport | undefined;
|
|
43
|
-
private readonly httpAdapter: AbstractHttpAdapter;
|
|
44
44
|
private aggregator: ContextAggregator;
|
|
45
45
|
|
|
46
46
|
private _extendedOptions?: PlatformExtendedOptions;
|
|
@@ -53,13 +53,14 @@ export class PlatformContext {
|
|
|
53
53
|
* А также инициализирует конфигурацию согласно требованиям платформы
|
|
54
54
|
* @param options
|
|
55
55
|
*/
|
|
56
|
-
constructor(
|
|
56
|
+
constructor(
|
|
57
|
+
readonly options: PlatformOptions,
|
|
58
|
+
readonly strictnessOptions?: { skipAssertAppName?: boolean },
|
|
59
|
+
) {
|
|
57
60
|
PlatformContext.assertTransportCompatability(options);
|
|
58
61
|
PlatformContext.assertPluginCompatability(options);
|
|
59
62
|
|
|
60
63
|
this.httpTransport = options.transports?.find?.(isHttpTransport);
|
|
61
|
-
this.httpAdapter =
|
|
62
|
-
this.httpTransport?.getAdapter() ?? new NoopHttpAdapter();
|
|
63
64
|
this.aggregator = new ContextAggregator(this);
|
|
64
65
|
}
|
|
65
66
|
|
|
@@ -70,6 +71,12 @@ export class PlatformContext {
|
|
|
70
71
|
const manifestData = Manifest.getData(this.options.manifestPath);
|
|
71
72
|
const { name, description, version } = manifestData;
|
|
72
73
|
|
|
74
|
+
if (this.strictnessOptions?.skipAssertAppName) {
|
|
75
|
+
this.logger.warn('assert app name skipped');
|
|
76
|
+
} else {
|
|
77
|
+
assertAppName(name);
|
|
78
|
+
}
|
|
79
|
+
|
|
73
80
|
const extendedOptions: PlatformExtendedOptions = {
|
|
74
81
|
description,
|
|
75
82
|
name,
|
|
@@ -164,7 +171,7 @@ export class PlatformContext {
|
|
|
164
171
|
async configureApp(app: INestApplication): Promise<void> {
|
|
165
172
|
const configContext = await this.getConfigContext();
|
|
166
173
|
|
|
167
|
-
const awaiter = this.httpTransport?.
|
|
174
|
+
const awaiter = this.httpTransport?.configureApp(app, configContext);
|
|
168
175
|
if (awaiter instanceof Promise) {
|
|
169
176
|
await awaiter;
|
|
170
177
|
}
|
|
@@ -226,12 +233,14 @@ export class PlatformContext {
|
|
|
226
233
|
* testingModuleRef.createApplication(...context.getNestFactoryCreateOptions())
|
|
227
234
|
* NestFactory.create(context.root, ...context.getNestFactoryCreateOptions())
|
|
228
235
|
*/
|
|
229
|
-
getNestFactoryCreateOptions():
|
|
230
|
-
httpAdapter: AbstractHttpAdapter,
|
|
231
|
-
|
|
232
|
-
|
|
236
|
+
async getNestFactoryCreateOptions(): Promise<
|
|
237
|
+
[httpAdapter: AbstractHttpAdapter, options?: NestApplicationOptions]
|
|
238
|
+
> {
|
|
239
|
+
const configContext = await this.getConfigContext();
|
|
240
|
+
const httpAdapter = await this.httpTransport?.createAdapter(configContext);
|
|
241
|
+
|
|
233
242
|
return [
|
|
234
|
-
|
|
243
|
+
httpAdapter ?? new NoopHttpAdapter(),
|
|
235
244
|
{
|
|
236
245
|
// Leave body parser configuration to httpTransport implementation
|
|
237
246
|
bodyParser: false,
|
package/src/types/transports.ts
CHANGED
|
@@ -94,15 +94,14 @@ export interface IHttpTransport extends IPrimaryTransport {
|
|
|
94
94
|
* Most common are ExpressAdapter and FastifyAdater,
|
|
95
95
|
* but custom adapter can be implemented if needed
|
|
96
96
|
*/
|
|
97
|
-
|
|
97
|
+
createAdapter(configContext: ConfigContext): AbstractHttpAdapter;
|
|
98
98
|
|
|
99
99
|
/**
|
|
100
100
|
* Applies any configuration to Nest application instance:
|
|
101
101
|
* middleware, body parsers and other.
|
|
102
102
|
* @param app INestApplication
|
|
103
|
-
* @param configContext
|
|
104
103
|
*/
|
|
105
|
-
|
|
104
|
+
configureApp(
|
|
106
105
|
app: INestApplication,
|
|
107
106
|
configContext: ConfigContext,
|
|
108
107
|
): Promise<void> | void;
|