@tsed/di 6.72.2 → 6.73.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/lib/decorators/controller.d.ts +43 -0
- package/lib/decorators/index.d.ts +1 -0
- package/lib/index.js +64 -4
- package/lib/index.js.map +1 -1
- package/lib/index.modern.js +65 -6
- package/lib/index.modern.js.map +1 -1
- package/package.json +2 -2
package/lib/index.modern.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getClassOrSymbol, Store, isClass, classOf, nameOf, StoreSet, decoratorTypeOf, UnsupportedDecoratorType, DecoratorTypes, Metadata, useDecorators, isString, getConstructorArgNames, proxyDelegation, setValue, getValue, deepMerge, deepClone, ancestorsOf, prototypeOf, isPromise, isInheritedFrom, isFunction, Env } from '@tsed/core';
|
|
1
|
+
import { getClassOrSymbol, Store, isClass, classOf, nameOf, StoreSet, decoratorTypeOf, UnsupportedDecoratorType, DecoratorTypes, Metadata, useDecorators, isArrayOrArrayClass, isString, getConstructorArgNames, proxyDelegation, setValue, getValue, deepMerge, deepClone, ancestorsOf, prototypeOf, isPromise, isInheritedFrom, isFunction, Env } from '@tsed/core';
|
|
2
2
|
import { levels, Logger, $log } from '@tsed/logger';
|
|
3
3
|
import { __decorate, __metadata } from 'tslib';
|
|
4
4
|
import chalk from 'chalk';
|
|
@@ -596,7 +596,7 @@ class ContextLogger {
|
|
|
596
596
|
|
|
597
597
|
}
|
|
598
598
|
|
|
599
|
-
const _excluded$
|
|
599
|
+
const _excluded$2 = ["id", "injector", "logger", "ignoreLog"];
|
|
600
600
|
class DIContext extends Map {
|
|
601
601
|
constructor(_ref) {
|
|
602
602
|
let {
|
|
@@ -605,7 +605,7 @@ class DIContext extends Map {
|
|
|
605
605
|
logger,
|
|
606
606
|
ignoreLog
|
|
607
607
|
} = _ref,
|
|
608
|
-
options = _objectWithoutPropertiesLoose(_ref, _excluded$
|
|
608
|
+
options = _objectWithoutPropertiesLoose(_ref, _excluded$2);
|
|
609
609
|
|
|
610
610
|
super();
|
|
611
611
|
/**
|
|
@@ -1082,7 +1082,7 @@ function Configuration(configuration = {}) {
|
|
|
1082
1082
|
};
|
|
1083
1083
|
}
|
|
1084
1084
|
|
|
1085
|
-
const _excluded = ["scopes", "imports", "resolvers", "deps", "scope"];
|
|
1085
|
+
const _excluded$1 = ["scopes", "imports", "resolvers", "deps", "scope"];
|
|
1086
1086
|
/**
|
|
1087
1087
|
* Declare a new Ts.ED module
|
|
1088
1088
|
*
|
|
@@ -1101,7 +1101,7 @@ function Module(options = {}) {
|
|
|
1101
1101
|
resolvers,
|
|
1102
1102
|
deps
|
|
1103
1103
|
} = options,
|
|
1104
|
-
configuration = _objectWithoutPropertiesLoose(options, _excluded);
|
|
1104
|
+
configuration = _objectWithoutPropertiesLoose(options, _excluded$1);
|
|
1105
1105
|
|
|
1106
1106
|
return useDecorators(Configuration(configuration), Injectable({
|
|
1107
1107
|
type: ProviderType.MODULE,
|
|
@@ -1222,6 +1222,65 @@ function UseOpts(options) {
|
|
|
1222
1222
|
};
|
|
1223
1223
|
}
|
|
1224
1224
|
|
|
1225
|
+
const _excluded = ["children"];
|
|
1226
|
+
|
|
1227
|
+
function mapOptions(options) {
|
|
1228
|
+
if (typeof options === "string" || options instanceof RegExp || isArrayOrArrayClass(options)) {
|
|
1229
|
+
return {
|
|
1230
|
+
path: options
|
|
1231
|
+
};
|
|
1232
|
+
}
|
|
1233
|
+
|
|
1234
|
+
return options;
|
|
1235
|
+
}
|
|
1236
|
+
/**
|
|
1237
|
+
* Declare a new controller with his Rest path. His methods annotated will be collected to build the routing list.
|
|
1238
|
+
* This routing listing will be built with the `express.Router` object.
|
|
1239
|
+
*
|
|
1240
|
+
* ::: tip
|
|
1241
|
+
* See [Controllers](/docs/controllers.md) section for more details
|
|
1242
|
+
* :::
|
|
1243
|
+
*
|
|
1244
|
+
* ```typescript
|
|
1245
|
+
* @Controller("/calendars")
|
|
1246
|
+
* export provide CalendarCtrl {
|
|
1247
|
+
*
|
|
1248
|
+
* @Get("/:id")
|
|
1249
|
+
* public get(
|
|
1250
|
+
* @Req() request: Req,
|
|
1251
|
+
* @Res() response: Res,
|
|
1252
|
+
* @Next() next: Next
|
|
1253
|
+
* ): void {
|
|
1254
|
+
*
|
|
1255
|
+
* }
|
|
1256
|
+
* }
|
|
1257
|
+
* ```
|
|
1258
|
+
*
|
|
1259
|
+
* @param options
|
|
1260
|
+
* @controller
|
|
1261
|
+
* @decorator
|
|
1262
|
+
* @classDecorator
|
|
1263
|
+
*/
|
|
1264
|
+
|
|
1265
|
+
|
|
1266
|
+
function Controller(options) {
|
|
1267
|
+
const _mapOptions = mapOptions(options),
|
|
1268
|
+
{
|
|
1269
|
+
children = []
|
|
1270
|
+
} = _mapOptions,
|
|
1271
|
+
opts = _objectWithoutPropertiesLoose(_mapOptions, _excluded);
|
|
1272
|
+
|
|
1273
|
+
return target => {
|
|
1274
|
+
registerController(_extends({
|
|
1275
|
+
provide: target
|
|
1276
|
+
}, opts));
|
|
1277
|
+
Store.from(target).set("childrenControllers", children);
|
|
1278
|
+
children.forEach(childToken => {
|
|
1279
|
+
Store.from(childToken).set("parentController", target);
|
|
1280
|
+
});
|
|
1281
|
+
};
|
|
1282
|
+
}
|
|
1283
|
+
|
|
1225
1284
|
class InjectionError extends Error {
|
|
1226
1285
|
constructor(token, origin) {
|
|
1227
1286
|
super(isString(origin) ? origin : "");
|
|
@@ -2230,5 +2289,5 @@ function getConfiguration(module, configuration = {}) {
|
|
|
2230
2289
|
return config;
|
|
2231
2290
|
}
|
|
2232
2291
|
|
|
2233
|
-
export { Configuration, Constant, Container, ContextLogger, DIConfiguration, DIContext, DITest, DI_PARAMS, DI_PARAM_OPTIONS, GlobalProviderRegistry, GlobalProviders, INJECTABLE_PROP, Inject, Injectable, InjectablePropertyType, InjectionError, InjectorService, Intercept, Interceptor, LocalsContainer, Module, Opts, OverrideProvider, Provider, ProviderScope, ProviderType, Scope, Service, UndefinedTokenError, UseOpts, Value, createContainer, getConfiguration, registerController, registerFactory, registerProvider, registerValue, setLoggerLevel };
|
|
2292
|
+
export { Configuration, Constant, Container, ContextLogger, Controller, DIConfiguration, DIContext, DITest, DI_PARAMS, DI_PARAM_OPTIONS, GlobalProviderRegistry, GlobalProviders, INJECTABLE_PROP, Inject, Injectable, InjectablePropertyType, InjectionError, InjectorService, Intercept, Interceptor, LocalsContainer, Module, Opts, OverrideProvider, Provider, ProviderScope, ProviderType, Scope, Service, UndefinedTokenError, UseOpts, Value, createContainer, getConfiguration, registerController, registerFactory, registerProvider, registerValue, setLoggerLevel };
|
|
2234
2293
|
//# sourceMappingURL=index.modern.js.map
|