@nestjs/common 8.4.6 → 9.0.0-next.2
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 +4 -3
- package/cache/cache.constants.d.ts +0 -1
- package/cache/cache.constants.js +1 -2
- package/cache/cache.module-definition.d.ts +2 -0
- package/cache/cache.module-definition.js +10 -0
- package/cache/cache.module.d.ts +2 -3
- package/cache/cache.module.js +6 -43
- package/cache/cache.providers.js +2 -1
- package/cache/interfaces/cache-module.interface.d.ts +6 -2
- package/decorators/core/controller.decorator.js +1 -1
- package/exceptions/http.exception.d.ts +9 -0
- package/exceptions/http.exception.js +13 -0
- package/index.d.ts +2 -2
- package/index.js +1 -1
- package/interfaces/http/http-server.interface.d.ts +3 -1
- package/interfaces/http/index.d.ts +1 -0
- package/interfaces/http/index.js +1 -0
- package/{http/interfaces → interfaces/http}/raw-body-request.interface.d.ts +0 -0
- package/{http/interfaces → interfaces/http}/raw-body-request.interface.js +0 -0
- package/interfaces/modules/provider.interface.d.ts +27 -1
- package/interfaces/nest-application.interface.d.ts +0 -16
- package/interfaces/nest-microservice.interface.d.ts +0 -7
- package/interfaces/scope-options.interface.d.ts +7 -0
- package/module-utils/configurable-module.builder.d.ts +93 -0
- package/module-utils/configurable-module.builder.js +195 -0
- package/module-utils/constants.d.ts +4 -0
- package/module-utils/constants.js +7 -0
- package/module-utils/index.d.ts +2 -0
- package/{http → module-utils}/index.js +1 -2
- package/module-utils/interfaces/configurable-module-async-options.interface.d.ts +36 -0
- package/{http/interfaces/http-module.interface.js → module-utils/interfaces/configurable-module-async-options.interface.js} +0 -0
- package/module-utils/interfaces/configurable-module-cls.interface.d.ts +13 -0
- package/module-utils/interfaces/configurable-module-cls.interface.js +2 -0
- package/module-utils/interfaces/configurable-module-host.interface.d.ts +62 -0
- package/module-utils/interfaces/configurable-module-host.interface.js +2 -0
- package/module-utils/interfaces/index.d.ts +3 -0
- package/module-utils/interfaces/index.js +6 -0
- package/module-utils/utils/generate-options-injection-token.util.d.ts +1 -0
- package/module-utils/utils/generate-options-injection-token.util.js +9 -0
- package/package.json +1 -2
- package/pipes/file/file-type.validator.d.ts +15 -0
- package/pipes/file/file-type.validator.js +26 -0
- package/pipes/file/file-validator.interface.d.ts +17 -0
- package/pipes/file/file-validator.interface.js +12 -0
- package/pipes/file/index.d.ts +6 -0
- package/pipes/file/index.js +9 -0
- package/pipes/file/max-file-size.validator.d.ts +15 -0
- package/pipes/file/max-file-size.validator.js +23 -0
- package/pipes/file/parse-file-options.interface.d.ts +7 -0
- package/pipes/file/parse-file-options.interface.js +2 -0
- package/pipes/file/parse-file-pipe.builder.d.ts +10 -0
- package/pipes/file/parse-file-pipe.builder.js +25 -0
- package/pipes/file/parse-file.pipe.d.ts +25 -0
- package/pipes/file/parse-file.pipe.js +57 -0
- package/pipes/index.d.ts +1 -0
- package/pipes/index.js +1 -0
- package/pipes/parse-uuid.pipe.d.ts +7 -0
- package/pipes/parse-uuid.pipe.js +19 -5
- package/pipes/validation.pipe.d.ts +1 -1
- package/pipes/validation.pipe.js +15 -4
- package/utils/cli-colors.util.d.ts +1 -0
- package/utils/cli-colors.util.js +1 -0
- package/utils/shared.utils.d.ts +0 -5
- package/utils/shared.utils.js +1 -6
- package/http/http.constants.d.ts +0 -3
- package/http/http.constants.js +0 -6
- package/http/http.module.d.ts +0 -11
- package/http/http.module.js +0 -88
- package/http/http.service.d.ts +0 -19
- package/http/http.service.js +0 -74
- package/http/index.d.ts +0 -3
- package/http/interfaces/http-module.interface.d.ts +0 -13
- package/http/interfaces/index.d.ts +0 -2
- package/http/interfaces/index.js +0 -5
- package/utils/is-uuid.d.ts +0 -1
- package/utils/is-uuid.js +0 -19
package/Readme.md
CHANGED
|
@@ -65,19 +65,20 @@ Nest is an MIT-licensed open source project. It can grow thanks to the sponsors
|
|
|
65
65
|
<td>
|
|
66
66
|
<a href="https://nx.dev" target="_blank"><img src="https://nestjs.com/img/nx-logo.png" height="45" valign="middle" /></a></td>
|
|
67
67
|
<td>
|
|
68
|
-
<a href="https://valor-software.com/" target="_blank"><img src="https://docs.nestjs.com/assets/sponsors/valor-software.png" width="170" valign="middle" /></a></td>
|
|
68
|
+
<a href="https://valor-software.com/" target="_blank"><img src="https://docs.nestjs.com/assets/sponsors/valor-software.png" width="170" valign="middle" /></a></td><td>
|
|
69
|
+
<a href="https://amplication.com/" target="_blank"><img src="https://nestjs.com/img/amplication-logo.svg" width="190" valign="middle" /></a></td>
|
|
69
70
|
</tr></table>
|
|
70
71
|
|
|
71
72
|
#### Gold Sponsors
|
|
72
73
|
|
|
73
74
|
<table style="text-align:center;"><tr><td>
|
|
74
|
-
<a href="https://careers.labster.com/departments/platform" target="_blank"><img src="https://nestjs.com/img/labster-logo.png" width="170" valign="middle" /></a></td><td>
|
|
75
75
|
<a href="https://weld.app/" target="_blank"><img src="https://nestjs.com/img/weld-logo.svg" width="140" valign="middle" /></a></td>
|
|
76
76
|
<td>
|
|
77
77
|
<a href="https://intrinsic.ventures/" target="_blank"><img src="https://nestjs.com/img/intrinisic-logo.png" width="210" valign="middle" /></a></td>
|
|
78
78
|
<td>
|
|
79
79
|
<a href="https://jetbrains.com/" target="_blank"><img src="https://nestjs.com/img/jetbrains-logo.svg" width="110" valign="middle" /></a></td><td>
|
|
80
|
-
<a href="https://snyk.co/nestjs" target="_blank"><img src="https://nestjs.com/img/snyk-logo-black.png" width="185" valign="middle" /></a></td
|
|
80
|
+
<a href="https://snyk.co/nestjs" target="_blank"><img src="https://nestjs.com/img/snyk-logo-black.png" width="185" valign="middle" /></a></td><td>
|
|
81
|
+
<a href="https://fuseautotech.com/" target="_blank"><img src="https://nestjs.com/img/fuse-logo.svg" width="105" valign="middle" /></a></td></</tr></table>
|
|
81
82
|
|
|
82
83
|
#### Silver Sponsors
|
|
83
84
|
|
package/cache/cache.constants.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CACHE_TTL_METADATA = exports.CACHE_KEY_METADATA = exports.
|
|
3
|
+
exports.CACHE_TTL_METADATA = exports.CACHE_KEY_METADATA = exports.CACHE_MANAGER = void 0;
|
|
4
4
|
exports.CACHE_MANAGER = 'CACHE_MANAGER';
|
|
5
|
-
exports.CACHE_MODULE_OPTIONS = 'CACHE_MODULE_OPTIONS';
|
|
6
5
|
exports.CACHE_KEY_METADATA = 'cache_module:cache_key';
|
|
7
6
|
exports.CACHE_TTL_METADATA = 'cache_module:cache_ttl';
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { CacheModuleOptions } from './interfaces/cache-module.interface';
|
|
2
|
+
export declare const ConfigurableModuleClass: import("../module-utils").ConfigurableModuleCls<CacheModuleOptions<Record<string, any>>, "register", "createCacheOptions", {}>, MODULE_OPTIONS_TOKEN: string | symbol;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var _a;
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.MODULE_OPTIONS_TOKEN = exports.ConfigurableModuleClass = void 0;
|
|
5
|
+
const module_utils_1 = require("../module-utils");
|
|
6
|
+
_a = new module_utils_1.ConfigurableModuleBuilder({
|
|
7
|
+
moduleName: 'Cache',
|
|
8
|
+
})
|
|
9
|
+
.setFactoryMethodName('createCacheOptions')
|
|
10
|
+
.build(), exports.ConfigurableModuleClass = _a.ConfigurableModuleClass, exports.MODULE_OPTIONS_TOKEN = _a.MODULE_OPTIONS_TOKEN;
|
package/cache/cache.module.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { DynamicModule } from '../interfaces';
|
|
2
|
+
import { ConfigurableModuleClass } from './cache.module-definition';
|
|
2
3
|
import { CacheModuleAsyncOptions, CacheModuleOptions } from './interfaces/cache-module.interface';
|
|
3
4
|
/**
|
|
4
5
|
* Module that provides Nest cache-manager.
|
|
@@ -7,7 +8,7 @@ import { CacheModuleAsyncOptions, CacheModuleOptions } from './interfaces/cache-
|
|
|
7
8
|
*
|
|
8
9
|
* @publicApi
|
|
9
10
|
*/
|
|
10
|
-
export declare class CacheModule {
|
|
11
|
+
export declare class CacheModule extends ConfigurableModuleClass {
|
|
11
12
|
/**
|
|
12
13
|
* Configure the cache manager statically.
|
|
13
14
|
*
|
|
@@ -25,6 +26,4 @@ export declare class CacheModule {
|
|
|
25
26
|
* @see [Async configuration](https://docs.nestjs.com/techniques/caching#async-configuration)
|
|
26
27
|
*/
|
|
27
28
|
static registerAsync<StoreConfig extends Record<any, any> = Record<string, any>>(options: CacheModuleAsyncOptions<StoreConfig>): DynamicModule;
|
|
28
|
-
private static createAsyncProviders;
|
|
29
|
-
private static createAsyncOptionsProvider;
|
|
30
29
|
}
|
package/cache/cache.module.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var CacheModule_1;
|
|
3
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
3
|
exports.CacheModule = void 0;
|
|
5
4
|
const tslib_1 = require("tslib");
|
|
6
5
|
const decorators_1 = require("../decorators");
|
|
7
6
|
const cache_constants_1 = require("./cache.constants");
|
|
7
|
+
const cache_module_definition_1 = require("./cache.module-definition");
|
|
8
8
|
const cache_providers_1 = require("./cache.providers");
|
|
9
9
|
/**
|
|
10
10
|
* Module that provides Nest cache-manager.
|
|
@@ -13,7 +13,7 @@ const cache_providers_1 = require("./cache.providers");
|
|
|
13
13
|
*
|
|
14
14
|
* @publicApi
|
|
15
15
|
*/
|
|
16
|
-
let CacheModule =
|
|
16
|
+
let CacheModule = class CacheModule extends cache_module_definition_1.ConfigurableModuleClass {
|
|
17
17
|
/**
|
|
18
18
|
* Configure the cache manager statically.
|
|
19
19
|
*
|
|
@@ -22,11 +22,7 @@ let CacheModule = CacheModule_1 = class CacheModule {
|
|
|
22
22
|
* @see [Customize caching](https://docs.nestjs.com/techniques/caching#customize-caching)
|
|
23
23
|
*/
|
|
24
24
|
static register(options = {}) {
|
|
25
|
-
return {
|
|
26
|
-
module: CacheModule_1,
|
|
27
|
-
global: options.isGlobal,
|
|
28
|
-
providers: [{ provide: cache_constants_1.CACHE_MODULE_OPTIONS, useValue: options }],
|
|
29
|
-
};
|
|
25
|
+
return Object.assign({ global: options.isGlobal }, super.register(options));
|
|
30
26
|
}
|
|
31
27
|
/**
|
|
32
28
|
* Configure the cache manager dynamically.
|
|
@@ -37,44 +33,11 @@ let CacheModule = CacheModule_1 = class CacheModule {
|
|
|
37
33
|
* @see [Async configuration](https://docs.nestjs.com/techniques/caching#async-configuration)
|
|
38
34
|
*/
|
|
39
35
|
static registerAsync(options) {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
global: options.isGlobal,
|
|
43
|
-
imports: options.imports,
|
|
44
|
-
providers: [
|
|
45
|
-
...this.createAsyncProviders(options),
|
|
46
|
-
...(options.extraProviders || []),
|
|
47
|
-
],
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
static createAsyncProviders(options) {
|
|
51
|
-
if (options.useExisting || options.useFactory) {
|
|
52
|
-
return [this.createAsyncOptionsProvider(options)];
|
|
53
|
-
}
|
|
54
|
-
return [
|
|
55
|
-
this.createAsyncOptionsProvider(options),
|
|
56
|
-
{
|
|
57
|
-
provide: options.useClass,
|
|
58
|
-
useClass: options.useClass,
|
|
59
|
-
},
|
|
60
|
-
];
|
|
61
|
-
}
|
|
62
|
-
static createAsyncOptionsProvider(options) {
|
|
63
|
-
if (options.useFactory) {
|
|
64
|
-
return {
|
|
65
|
-
provide: cache_constants_1.CACHE_MODULE_OPTIONS,
|
|
66
|
-
useFactory: options.useFactory,
|
|
67
|
-
inject: options.inject || [],
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
return {
|
|
71
|
-
provide: cache_constants_1.CACHE_MODULE_OPTIONS,
|
|
72
|
-
useFactory: async (optionsFactory) => optionsFactory.createCacheOptions(),
|
|
73
|
-
inject: [options.useExisting || options.useClass],
|
|
74
|
-
};
|
|
36
|
+
const moduleDefinition = super.registerAsync(options);
|
|
37
|
+
return Object.assign(Object.assign({ global: options.isGlobal }, moduleDefinition), { providers: moduleDefinition.providers.concat(options.extraProviders) });
|
|
75
38
|
}
|
|
76
39
|
};
|
|
77
|
-
CacheModule =
|
|
40
|
+
CacheModule = tslib_1.__decorate([
|
|
78
41
|
(0, decorators_1.Module)({
|
|
79
42
|
providers: [(0, cache_providers_1.createCacheManager)()],
|
|
80
43
|
exports: [cache_constants_1.CACHE_MANAGER],
|
package/cache/cache.providers.js
CHANGED
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.createCacheManager = void 0;
|
|
4
4
|
const load_package_util_1 = require("../utils/load-package.util");
|
|
5
5
|
const cache_constants_1 = require("./cache.constants");
|
|
6
|
+
const cache_module_definition_1 = require("./cache.module-definition");
|
|
6
7
|
const default_options_1 = require("./default-options");
|
|
7
8
|
/**
|
|
8
9
|
* Creates a CacheManager Provider.
|
|
@@ -18,7 +19,7 @@ function createCacheManager() {
|
|
|
18
19
|
? cacheManager.multiCaching(options.map(store => cacheManager.caching(Object.assign(Object.assign({}, default_options_1.defaultCacheOptions), (store || {})))))
|
|
19
20
|
: cacheManager.caching(Object.assign(Object.assign({}, default_options_1.defaultCacheOptions), (options || {})));
|
|
20
21
|
},
|
|
21
|
-
inject: [
|
|
22
|
+
inject: [cache_module_definition_1.MODULE_OPTIONS_TOKEN],
|
|
22
23
|
};
|
|
23
24
|
}
|
|
24
25
|
exports.createCacheManager = createCacheManager;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Provider, Type } from '../../interfaces';
|
|
2
|
+
import { ConfigurableModuleAsyncOptions } from '../../module-utils';
|
|
2
3
|
import { CacheManagerOptions } from './cache-manager.interface';
|
|
3
4
|
export declare type CacheModuleOptions<StoreConfig extends Record<any, any> = Record<string, any>> = CacheManagerOptions & StoreConfig & {
|
|
4
5
|
/**
|
|
@@ -24,7 +25,7 @@ export interface CacheOptionsFactory<StoreConfig extends Record<any, any> = Reco
|
|
|
24
25
|
*
|
|
25
26
|
* @publicApi
|
|
26
27
|
*/
|
|
27
|
-
export interface CacheModuleAsyncOptions<StoreConfig extends Record<any, any> = Record<string, any>> extends
|
|
28
|
+
export interface CacheModuleAsyncOptions<StoreConfig extends Record<any, any> = Record<string, any>> extends ConfigurableModuleAsyncOptions<CacheModuleOptions<StoreConfig>, keyof CacheOptionsFactory> {
|
|
28
29
|
/**
|
|
29
30
|
* Injection token resolving to an existing provider. The provider must implement
|
|
30
31
|
* the `CacheOptionsFactory` interface.
|
|
@@ -44,6 +45,9 @@ export interface CacheModuleAsyncOptions<StoreConfig extends Record<any, any> =
|
|
|
44
45
|
* Dependencies that a Factory may inject.
|
|
45
46
|
*/
|
|
46
47
|
inject?: any[];
|
|
48
|
+
/**
|
|
49
|
+
* Extra providers to be registered within a scope of this module.
|
|
50
|
+
*/
|
|
47
51
|
extraProviders?: Provider[];
|
|
48
52
|
/**
|
|
49
53
|
* If "true', register `CacheModule` as a global module.
|
|
@@ -46,7 +46,7 @@ function Controller(prefixOrOptions) {
|
|
|
46
46
|
: [
|
|
47
47
|
prefixOrOptions.path || defaultPath,
|
|
48
48
|
prefixOrOptions.host,
|
|
49
|
-
{ scope: prefixOrOptions.scope },
|
|
49
|
+
{ scope: prefixOrOptions.scope, durable: prefixOrOptions.durable },
|
|
50
50
|
Array.isArray(prefixOrOptions.version)
|
|
51
51
|
? Array.from(new Set(prefixOrOptions.version))
|
|
52
52
|
: prefixOrOptions.version,
|
|
@@ -35,6 +35,15 @@ export declare class HttpException extends Error {
|
|
|
35
35
|
* @param status HTTP response status code.
|
|
36
36
|
*/
|
|
37
37
|
constructor(response: string | Record<string, any>, status: number);
|
|
38
|
+
cause: Error | undefined;
|
|
39
|
+
/**
|
|
40
|
+
* Configures error chaining support
|
|
41
|
+
*
|
|
42
|
+
* See:
|
|
43
|
+
* - https://nodejs.org/en/blog/release/v16.9.0/#error-cause
|
|
44
|
+
* - https://github.com/microsoft/TypeScript/issues/45167
|
|
45
|
+
*/
|
|
46
|
+
initCause(): void;
|
|
38
47
|
initMessage(): void;
|
|
39
48
|
initName(): void;
|
|
40
49
|
getResponse(): string | object;
|
|
@@ -42,6 +42,19 @@ class HttpException extends Error {
|
|
|
42
42
|
this.status = status;
|
|
43
43
|
this.initMessage();
|
|
44
44
|
this.initName();
|
|
45
|
+
this.initCause();
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Configures error chaining support
|
|
49
|
+
*
|
|
50
|
+
* See:
|
|
51
|
+
* - https://nodejs.org/en/blog/release/v16.9.0/#error-cause
|
|
52
|
+
* - https://github.com/microsoft/TypeScript/issues/45167
|
|
53
|
+
*/
|
|
54
|
+
initCause() {
|
|
55
|
+
if (this.response instanceof Error) {
|
|
56
|
+
this.cause = this.response;
|
|
57
|
+
}
|
|
45
58
|
}
|
|
46
59
|
initMessage() {
|
|
47
60
|
if ((0, shared_utils_1.isString)(this.response)) {
|
package/index.d.ts
CHANGED
|
@@ -4,8 +4,8 @@ export * from './decorators';
|
|
|
4
4
|
export * from './enums';
|
|
5
5
|
export * from './exceptions';
|
|
6
6
|
export * from './file-stream';
|
|
7
|
-
export
|
|
8
|
-
export
|
|
7
|
+
export { Abstract, ArgumentMetadata, ArgumentsHost, BeforeApplicationShutdown, CallHandler, CanActivate, ClassProvider, ContextType, DynamicModule, ExceptionFilter, ExecutionContext, ExistingProvider, FactoryProvider, ForwardReference, HttpServer, INestApplication, INestApplicationContext, INestMicroservice, InjectionToken, IntrospectionResult, MessageEvent, MiddlewareConsumer, ModuleMetadata, NestApplicationOptions, NestHybridApplicationOptions, NestInterceptor, NestMiddleware, NestModule, OnApplicationBootstrap, OnApplicationShutdown, OnModuleDestroy, OnModuleInit, OptionalFactoryDependency, Paramtype, PipeTransform, Provider, RawBodyRequest, RpcExceptionFilter, Scope, ScopeOptions, Type, ValidationError, ValueProvider, VersioningOptions, VERSION_NEUTRAL, WebSocketAdapter, WsExceptionFilter, WsMessageHandler, } from './interfaces';
|
|
8
|
+
export * from './module-utils';
|
|
9
9
|
export * from './pipes';
|
|
10
10
|
export * from './serializer';
|
|
11
11
|
export * from './services';
|
package/index.js
CHANGED
|
@@ -14,10 +14,10 @@ tslib_1.__exportStar(require("./decorators"), exports);
|
|
|
14
14
|
tslib_1.__exportStar(require("./enums"), exports);
|
|
15
15
|
tslib_1.__exportStar(require("./exceptions"), exports);
|
|
16
16
|
tslib_1.__exportStar(require("./file-stream"), exports);
|
|
17
|
-
tslib_1.__exportStar(require("./http"), exports);
|
|
18
17
|
var interfaces_1 = require("./interfaces");
|
|
19
18
|
Object.defineProperty(exports, "Scope", { enumerable: true, get: function () { return interfaces_1.Scope; } });
|
|
20
19
|
Object.defineProperty(exports, "VERSION_NEUTRAL", { enumerable: true, get: function () { return interfaces_1.VERSION_NEUTRAL; } });
|
|
20
|
+
tslib_1.__exportStar(require("./module-utils"), exports);
|
|
21
21
|
tslib_1.__exportStar(require("./pipes"), exports);
|
|
22
22
|
tslib_1.__exportStar(require("./serializer"), exports);
|
|
23
23
|
tslib_1.__exportStar(require("./services"), exports);
|
|
@@ -27,8 +27,10 @@ export interface HttpServer<TRequest = any, TResponse = any> {
|
|
|
27
27
|
listen(port: number | string, hostname: string, callback?: () => void): any;
|
|
28
28
|
reply(response: any, body: any, statusCode?: number): any;
|
|
29
29
|
status(response: any, statusCode: number): any;
|
|
30
|
+
end(response: any, message?: string): any;
|
|
30
31
|
render(response: any, view: string, options: any): any;
|
|
31
32
|
redirect(response: any, statusCode: number, url: string): any;
|
|
33
|
+
isHeadersSent(response: any): boolean;
|
|
32
34
|
setHeader(response: any, name: string, value: string): any;
|
|
33
35
|
setErrorHandler?(handler: Function, prefix?: string): any;
|
|
34
36
|
setNotFoundHandler?(handler: Function, prefix?: string): any;
|
|
@@ -47,5 +49,5 @@ export interface HttpServer<TRequest = any, TResponse = any> {
|
|
|
47
49
|
close(): any;
|
|
48
50
|
getType(): string;
|
|
49
51
|
init?(): Promise<void>;
|
|
50
|
-
applyVersionFilter
|
|
52
|
+
applyVersionFilter(handler: Function, version: VersionValue, versioningOptions: VersioningOptions): (req: TRequest, res: TResponse, next: () => void) => Function;
|
|
51
53
|
}
|
package/interfaces/http/index.js
CHANGED
|
@@ -3,3 +3,4 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
tslib_1.__exportStar(require("./http-server.interface"), exports);
|
|
5
5
|
tslib_1.__exportStar(require("./message-event.interface"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./raw-body-request.interface"), exports);
|
|
File without changes
|
|
File without changes
|
|
@@ -39,6 +39,19 @@ export interface ClassProvider<T = any> {
|
|
|
39
39
|
* Optional enum defining lifetime of the provider that is injected.
|
|
40
40
|
*/
|
|
41
41
|
scope?: Scope;
|
|
42
|
+
/**
|
|
43
|
+
* This option is only available on factory providers!
|
|
44
|
+
*
|
|
45
|
+
* @see [Use factory](https://docs.nestjs.com/fundamentals/custom-providers#factory-providers-usefactory)
|
|
46
|
+
*/
|
|
47
|
+
inject?: never;
|
|
48
|
+
/**
|
|
49
|
+
* Flags provider as durable. This flag can be used in combination with custom context id
|
|
50
|
+
* factory strategy to construct lazy DI subtrees.
|
|
51
|
+
*
|
|
52
|
+
* This flag can be used only in conjunction with scope = Scope.REQUEST.
|
|
53
|
+
*/
|
|
54
|
+
durable?: boolean;
|
|
42
55
|
}
|
|
43
56
|
/**
|
|
44
57
|
* Interface defining a *Value* type provider.
|
|
@@ -64,6 +77,12 @@ export interface ValueProvider<T = any> {
|
|
|
64
77
|
* Instance of a provider to be injected.
|
|
65
78
|
*/
|
|
66
79
|
useValue: T;
|
|
80
|
+
/**
|
|
81
|
+
* This option is only available on factory providers!
|
|
82
|
+
*
|
|
83
|
+
* @see [Use factory](https://docs.nestjs.com/fundamentals/custom-providers#factory-providers-usefactory)
|
|
84
|
+
*/
|
|
85
|
+
inject?: never;
|
|
67
86
|
}
|
|
68
87
|
/**
|
|
69
88
|
* Interface defining a *Factory* type provider.
|
|
@@ -93,7 +112,7 @@ export interface FactoryProvider<T = any> {
|
|
|
93
112
|
/**
|
|
94
113
|
* Factory function that returns an instance of the provider to be injected.
|
|
95
114
|
*/
|
|
96
|
-
useFactory: (...args: any[]) => T
|
|
115
|
+
useFactory: (...args: any[]) => T | Promise<T>;
|
|
97
116
|
/**
|
|
98
117
|
* Optional list of providers to be injected into the context of the Factory function.
|
|
99
118
|
*/
|
|
@@ -102,6 +121,13 @@ export interface FactoryProvider<T = any> {
|
|
|
102
121
|
* Optional enum defining lifetime of the provider that is returned by the Factory function.
|
|
103
122
|
*/
|
|
104
123
|
scope?: Scope;
|
|
124
|
+
/**
|
|
125
|
+
* Flags provider as durable. This flag can be used in combination with custom context id
|
|
126
|
+
* factory strategy to construct lazy DI subtrees.
|
|
127
|
+
*
|
|
128
|
+
* This flag can be used only in conjunction with scope = Scope.REQUEST.
|
|
129
|
+
*/
|
|
130
|
+
durable?: boolean;
|
|
105
131
|
}
|
|
106
132
|
/**
|
|
107
133
|
* Interface defining an *Existing* (aliased) type provider.
|
|
@@ -44,15 +44,6 @@ export interface INestApplication extends INestApplicationContext {
|
|
|
44
44
|
*/
|
|
45
45
|
listen(port: number | string, callback?: () => void): Promise<any>;
|
|
46
46
|
listen(port: number | string, hostname: string, callback?: () => void): Promise<any>;
|
|
47
|
-
/**
|
|
48
|
-
* Starts the application (can be awaited).
|
|
49
|
-
* @deprecated use "listen" instead.
|
|
50
|
-
*
|
|
51
|
-
* @param {number|string} port
|
|
52
|
-
* @param {string} [hostname]
|
|
53
|
-
* @returns {Promise}
|
|
54
|
-
*/
|
|
55
|
-
listenAsync(port: number | string, hostname?: string): Promise<any>;
|
|
56
47
|
/**
|
|
57
48
|
* Returns the url the application is listening at, based on OS and IP version. Returns as an IP value either in IPv6 or IPv4
|
|
58
49
|
*
|
|
@@ -109,13 +100,6 @@ export interface INestApplication extends INestApplicationContext {
|
|
|
109
100
|
* @returns {Promise}
|
|
110
101
|
*/
|
|
111
102
|
startAllMicroservices(): Promise<this>;
|
|
112
|
-
/**
|
|
113
|
-
* Starts all connected microservices and can be awaited.
|
|
114
|
-
* @deprecated use "startAllMicroservices" instead.
|
|
115
|
-
*
|
|
116
|
-
* @returns {Promise}
|
|
117
|
-
*/
|
|
118
|
-
startAllMicroservicesAsync(): Promise<this>;
|
|
119
103
|
/**
|
|
120
104
|
* Registers exception filters as global filters (will be used within
|
|
121
105
|
* every HTTP route handler)
|
|
@@ -16,13 +16,6 @@ export interface INestMicroservice extends INestApplicationContext {
|
|
|
16
16
|
* @returns {void}
|
|
17
17
|
*/
|
|
18
18
|
listen(): Promise<any>;
|
|
19
|
-
/**
|
|
20
|
-
* Starts the microservice (can be awaited).
|
|
21
|
-
* @deprecated use "listen" instead.
|
|
22
|
-
*
|
|
23
|
-
* @returns {Promise}
|
|
24
|
-
*/
|
|
25
|
-
listenAsync(): Promise<any>;
|
|
26
19
|
/**
|
|
27
20
|
* Register Ws Adapter which will be used inside Gateways.
|
|
28
21
|
* Use when you want to override default `socket.io` library.
|
|
@@ -27,4 +27,11 @@ export interface ScopeOptions {
|
|
|
27
27
|
* Specifies the lifetime of an injected Provider or Controller.
|
|
28
28
|
*/
|
|
29
29
|
scope?: Scope;
|
|
30
|
+
/**
|
|
31
|
+
* Flags provider as durable. This flag can be used in combination with custom context id
|
|
32
|
+
* factory strategy to construct lazy DI subtrees.
|
|
33
|
+
*
|
|
34
|
+
* This flag can be used only in conjunction with scope = Scope.REQUEST.
|
|
35
|
+
*/
|
|
36
|
+
durable?: boolean;
|
|
30
37
|
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { DynamicModule } from '../interfaces';
|
|
2
|
+
import { Logger } from '../services/logger.service';
|
|
3
|
+
import { DEFAULT_FACTORY_CLASS_METHOD_KEY, DEFAULT_METHOD_KEY } from './constants';
|
|
4
|
+
import { ConfigurableModuleHost } from './interfaces/configurable-module-host.interface';
|
|
5
|
+
/**
|
|
6
|
+
* @publicApi
|
|
7
|
+
*/
|
|
8
|
+
export interface ConfigurableModuleBuilderOptions {
|
|
9
|
+
/**
|
|
10
|
+
* Specified what injection token should be used for the module options provider.
|
|
11
|
+
* By default, an auto-generated UUID will be used.
|
|
12
|
+
*/
|
|
13
|
+
optionsInjectionToken?: string | symbol;
|
|
14
|
+
/**
|
|
15
|
+
* By default, an UUID will be used as a module options provider token.
|
|
16
|
+
* Explicitly specifying the "moduleName" will instruct the "ConfigurableModuleBuilder"
|
|
17
|
+
* to use a more descriptive provider token.
|
|
18
|
+
*
|
|
19
|
+
* For example, if `moduleName: "Cache"` then auto-generated provider token will be "CACHE_MODULE_OPTIONS".
|
|
20
|
+
*/
|
|
21
|
+
moduleName?: string;
|
|
22
|
+
/**
|
|
23
|
+
* Indicates whether module should always be "transient", meaning,
|
|
24
|
+
* every time you call the static method to construct a dynamic module,
|
|
25
|
+
* regardless of what arguments you pass in, a new "unique" module will be created.
|
|
26
|
+
*
|
|
27
|
+
* @default false
|
|
28
|
+
*/
|
|
29
|
+
alwaysTransient?: boolean;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Factory that lets you create configurable modules and
|
|
33
|
+
* provides a way to reduce the majority of dynamic module boilerplate.
|
|
34
|
+
*
|
|
35
|
+
* @publicApi
|
|
36
|
+
*/
|
|
37
|
+
export declare class ConfigurableModuleBuilder<ModuleOptions, StaticMethodKey extends string = typeof DEFAULT_METHOD_KEY, FactoryClassMethodKey extends string = typeof DEFAULT_FACTORY_CLASS_METHOD_KEY, ExtraModuleDefinitionOptions = {}> {
|
|
38
|
+
protected readonly options: ConfigurableModuleBuilderOptions;
|
|
39
|
+
protected staticMethodKey: StaticMethodKey;
|
|
40
|
+
protected factoryClassMethodKey: FactoryClassMethodKey;
|
|
41
|
+
protected extras: ExtraModuleDefinitionOptions;
|
|
42
|
+
protected transformModuleDefinition: (definition: DynamicModule, extraOptions: ExtraModuleDefinitionOptions) => DynamicModule;
|
|
43
|
+
protected readonly logger: Logger;
|
|
44
|
+
constructor(options?: ConfigurableModuleBuilderOptions, parentBuilder?: ConfigurableModuleBuilder<ModuleOptions>);
|
|
45
|
+
/**
|
|
46
|
+
* Registers the "extras" object (a set of extra options that can be used to modify the dynamic module definition).
|
|
47
|
+
* Values you specify within the "extras" object will be used as default values (that can be overriden by module consumers).
|
|
48
|
+
*
|
|
49
|
+
* This method also applies the so-called "module definition transform function" that takes the auto-generated
|
|
50
|
+
* dynamic module object ("DynamicModule") and the actual consumer "extras" object as input parameters.
|
|
51
|
+
* The "extras" object consists of values explicitly specified by module consumers and default values.
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* ```typescript
|
|
55
|
+
* .setExtras<{ isGlobal?: boolean }>({ isGlobal: false }, (definition, extras) =>
|
|
56
|
+
* ({ ...definition, global: extras.isGlobal })
|
|
57
|
+
* )
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
setExtras<ExtraModuleDefinitionOptions>(extras: ExtraModuleDefinitionOptions, transformDefinition: (definition: DynamicModule, extras: ExtraModuleDefinitionOptions) => DynamicModule): ConfigurableModuleBuilder<ModuleOptions, StaticMethodKey, FactoryClassMethodKey, ExtraModuleDefinitionOptions>;
|
|
61
|
+
/**
|
|
62
|
+
* Dynamic modules must expose public static methods that let you pass in
|
|
63
|
+
* configuration parameters (control the module's behavior from the outside).
|
|
64
|
+
* Some frequently used names that you may have seen in other modules are:
|
|
65
|
+
* "forRoot", "forFeature", "register", "configure".
|
|
66
|
+
*
|
|
67
|
+
* This method "setClassMethodName" lets you specify the name of the
|
|
68
|
+
* method that will be auto-generated.
|
|
69
|
+
*
|
|
70
|
+
* @param key name of the method
|
|
71
|
+
*/
|
|
72
|
+
setClassMethodName<StaticMethodKey extends string>(key: StaticMethodKey): ConfigurableModuleBuilder<ModuleOptions, StaticMethodKey, FactoryClassMethodKey, ExtraModuleDefinitionOptions>;
|
|
73
|
+
/**
|
|
74
|
+
* Asynchronously configured modules (that rely on other modules, i.e. "ConfigModule")
|
|
75
|
+
* let you pass the configuration factory class that will be registered and instantiated as a provider.
|
|
76
|
+
* This provider then will be used to retrieve the module's configuration. To provide the configuration,
|
|
77
|
+
* the corresponding factory method must be implemented.
|
|
78
|
+
*
|
|
79
|
+
* This method ("setFactoryMethodName") lets you control what method name will have to be
|
|
80
|
+
* implemented by the config factory (default is "create").
|
|
81
|
+
*
|
|
82
|
+
* @param key name of the method
|
|
83
|
+
*/
|
|
84
|
+
setFactoryMethodName<FactoryClassMethodKey extends string>(key: FactoryClassMethodKey): ConfigurableModuleBuilder<ModuleOptions, StaticMethodKey, FactoryClassMethodKey, ExtraModuleDefinitionOptions>;
|
|
85
|
+
/**
|
|
86
|
+
* Returns an object consisting of multiple properties that lets you
|
|
87
|
+
* easily construct dynamic configurable modules. See "ConfigurableModuleHost" interface for more details.
|
|
88
|
+
*/
|
|
89
|
+
build(): ConfigurableModuleHost<ModuleOptions, StaticMethodKey, FactoryClassMethodKey, ExtraModuleDefinitionOptions>;
|
|
90
|
+
private constructInjectionTokenString;
|
|
91
|
+
private createConfigurableModuleCls;
|
|
92
|
+
private createTypeProxy;
|
|
93
|
+
}
|