@tsed/di 7.0.0-beta.13 → 7.0.0-beta.16
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/jest.config.js +4 -4
- package/lib/cjs/decorators/controller.js.map +1 -1
- package/lib/cjs/domain/ContextLogger.js +0 -1
- package/lib/cjs/domain/ContextLogger.js.map +1 -1
- package/lib/cjs/domain/ControllerProvider.js +37 -0
- package/lib/cjs/domain/ControllerProvider.js.map +1 -0
- package/lib/cjs/domain/DIContext.js +4 -1
- package/lib/cjs/domain/DIContext.js.map +1 -1
- package/lib/cjs/index.js +1 -0
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/utils/runInContext.js +11 -1
- package/lib/cjs/utils/runInContext.js.map +1 -1
- package/lib/esm/decorators/controller.js.map +1 -1
- package/lib/esm/domain/ContextLogger.js +0 -1
- package/lib/esm/domain/ContextLogger.js.map +1 -1
- package/lib/esm/domain/ControllerProvider.js +33 -0
- package/lib/esm/domain/ControllerProvider.js.map +1 -0
- package/lib/esm/domain/DIContext.js +4 -1
- package/lib/esm/domain/DIContext.js.map +1 -1
- package/lib/esm/index.js +1 -0
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/utils/runInContext.js +11 -1
- package/lib/esm/utils/runInContext.js.map +1 -1
- package/lib/types/decorators/controller.d.ts +0 -1
- package/lib/types/domain/ContextLogger.d.ts +2 -2
- package/lib/types/domain/ControllerProvider.d.ts +17 -0
- package/lib/types/domain/DIContext.d.ts +2 -1
- package/lib/types/index.d.ts +1 -0
- package/package.json +5 -5
- package/readme.md +1 -1
package/jest.config.js
CHANGED
|
@@ -5,10 +5,10 @@ module.exports = {
|
|
|
5
5
|
...require("@tsed/jest-config")(__dirname, "di"),
|
|
6
6
|
coverageThreshold: {
|
|
7
7
|
global: {
|
|
8
|
-
statements:
|
|
9
|
-
branches: 92.
|
|
10
|
-
functions:
|
|
11
|
-
lines:
|
|
8
|
+
statements: 99.1,
|
|
9
|
+
branches: 92.91,
|
|
10
|
+
functions: 99.23,
|
|
11
|
+
lines: 99.21
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
14
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"controller.js","sourceRoot":"","sources":["../../../src/decorators/controller.ts"],"names":[],"mappings":";;;AAAA,qCAAoE;AACpE,yCAA4C;AAE5C,qEAAkE;
|
|
1
|
+
{"version":3,"file":"controller.js","sourceRoot":"","sources":["../../../src/decorators/controller.ts"],"names":[],"mappings":";;;AAAA,qCAAoE;AACpE,yCAA4C;AAE5C,qEAAkE;AAgBlE,SAAS,UAAU,CAAC,OAAY;IAC9B,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,YAAY,MAAM,IAAI,IAAA,0BAAmB,EAAC,OAAO,CAAC,EAAE;QAC5F,OAAO;YACL,IAAI,EAAE,OAAO;SACd,CAAC;KACH;IAED,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,SAAgB,UAAU,CAAC,OAAqC;IAC9D,MAAM,EAAC,QAAQ,GAAG,EAAE,EAAE,IAAI,EAAE,GAAG,IAAI,EAAC,GAAG,UAAU,CAAC,OAAO,CAAC,CAAC;IAE3D,OAAO,IAAA,oBAAa,EAClB,CAAC,MAAY,EAAE,EAAE;QACf,IAAA,qCAAkB,EAAC;YACjB,OAAO,EAAE,MAAM;YACf,GAAG,IAAI;SACR,CAAC,CAAC;IACL,CAAC,EACD,IAAI,IAAI,IAAA,aAAI,EAAC,IAAW,CAAC,EACzB,IAAA,iBAAQ,EAAC,GAAG,QAAQ,CAAC,CACtB,CAAC;AACJ,CAAC;AAbD,gCAaC","sourcesContent":["import {isArrayOrArrayClass, Type, useDecorators} from \"@tsed/core\";\nimport {Children, Path} from \"@tsed/schema\";\nimport {ProviderOpts} from \"../interfaces/ProviderOpts\";\nimport {registerController} from \"../registries/ProviderRegistry\";\n\nexport type PathType = string | RegExp | (string | RegExp)[];\n\nexport interface ControllerMiddlewares {\n useBefore: any[];\n use: any[];\n useAfter: any[];\n}\n\nexport interface ControllerOptions extends Partial<ProviderOpts<any>> {\n path?: PathType;\n children?: Type<any>[];\n middlewares?: Partial<ControllerMiddlewares>;\n}\n\nfunction mapOptions(options: any): ControllerOptions {\n if (typeof options === \"string\" || options instanceof RegExp || isArrayOrArrayClass(options)) {\n return {\n path: options\n };\n }\n\n return options;\n}\n\n/**\n * Declare a new controller with his Rest path. His methods annotated will be collected to build the routing list.\n * This routing listing will be built with the `express.Router` object.\n *\n * ::: tip\n * See [Controllers](/docs/controllers.md) section for more details\n * :::\n *\n * ```typescript\n * @Controller(\"/calendars\")\n * export provide CalendarCtrl {\n *\n * @Get(\"/:id\")\n * public get(\n * @Req() request: Req,\n * @Res() response: Res,\n * @Next() next: Next\n * ): void {\n *\n * }\n * }\n * ```\n *\n * @param options\n * @controller\n * @decorator\n * @classDecorator\n */\nexport function Controller(options: PathType | ControllerOptions): ClassDecorator {\n const {children = [], path, ...opts} = mapOptions(options);\n\n return useDecorators(\n (target: Type) => {\n registerController({\n provide: target,\n ...opts\n });\n },\n path && Path(path as any),\n Children(...children)\n );\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContextLogger.js","sourceRoot":"","sources":["../../../src/domain/ContextLogger.ts"],"names":[],"mappings":";;;AAAA,qCAAiC;AACjC,yCAA8C;AAY9C,MAAM,MAAM,GAA6B,IAAA,eAAM,GAAE,CAAC;AAElD,MAAa,aAAa;
|
|
1
|
+
{"version":3,"file":"ContextLogger.js","sourceRoot":"","sources":["../../../src/domain/ContextLogger.ts"],"names":[],"mappings":";;;AAAA,qCAAiC;AACjC,yCAA8C;AAY9C,MAAM,MAAM,GAA6B,IAAA,eAAM,GAAE,CAAC;AAElD,MAAa,aAAa;IAUO;IATtB,SAAS,CAAO;IAChB,gBAAgB,CAA2B;IAEpD,MAAM,CAAS;IACf,aAAa,CAAS;IACtB,MA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AE,CAAC;SACd;IACH,CAAC;CACF;AA5HD,sCA4HC","sourcesContent":["import {Hooks} from \"@tsed/core\";\nimport {levels, LogLevel} from \"@tsed/logger\";\nimport {DILogger} from \"../interfaces/DILogger\";\nimport type {DIContext} from \"./DIContext\";\n\nexport interface ContextLoggerOptions extends Record<string, any> {\n id: string;\n logger?: DILogger;\n level?: \"debug\" | \"info\" | \"warn\" | \"error\" | \"off\" | \"all\";\n maxStackSize?: number;\n additionalProps?: Record<any, any>;\n}\n\nconst LEVELS: Record<string, LogLevel> = levels();\n\nexport class ContextLogger {\n readonly dateStart: Date;\n readonly #additionalProps?: Record<string, unknown>;\n\n #hooks?: Hooks;\n #maxStackSize: number;\n #stack?: any[];\n #level: LogLevel;\n #logger: any;\n\n constructor(protected readonly $ctx: DIContext) {\n const {logger, dateStart = new Date(), level = \"all\", maxStackSize = 30, additionalProps} = $ctx.opts;\n this.dateStart = dateStart;\n this.#logger = logger;\n this.#additionalProps = additionalProps;\n this.#level = (LEVELS[level.toUpperCase()] || LEVELS.ALL) as LogLevel;\n this.#maxStackSize = maxStackSize;\n }\n\n get id() {\n return this.$ctx.id;\n }\n\n set maxStackSize(maxStackSize: number) {\n this.#maxStackSize = maxStackSize;\n }\n\n get hooks() {\n return (this.#hooks = this.#hooks || new Hooks());\n }\n\n private get stack() {\n return (this.#stack = this.#stack || []);\n }\n\n alterLog(cb: (data: any, level: \"debug\" | \"info\" | \"warn\" | \"error\" | \"off\" | \"all\", withRequest: boolean) => any) {\n return this.hooks.on(\"log\", cb);\n }\n\n alterIgnoreLog(cb: (ignore: boolean, data: any) => boolean) {\n return this.hooks.on(\"ignore\", cb);\n }\n\n info(obj: any) {\n this.run(levels().INFO, obj);\n return this;\n }\n\n debug(obj: any, withRequest: boolean = true) {\n this.run(levels().DEBUG, obj, withRequest);\n return this;\n }\n\n warn(obj: any) {\n this.run(levels().WARN, obj);\n return this;\n }\n\n error(obj: any) {\n this.run(levels().ERROR, obj);\n return this;\n }\n\n trace(obj: any) {\n this.run(levels().TRACE, obj);\n return this;\n }\n\n public flush() {\n if (this.stack.length) {\n this.stack.forEach(({level, data}: any) => {\n this.#logger[level](data);\n });\n\n this.#stack = [];\n }\n }\n\n public isLevelEnabled(otherLevel: string | LogLevel) {\n return this.#level.isLessThanOrEqualTo(otherLevel);\n }\n\n destroy() {\n this.flush();\n this.#maxStackSize = 0;\n this.#stack = [];\n this.#logger = null;\n }\n\n /**\n * Return the duration between the time when LogIncomingRequest has handle the request and now.\n * @returns {number}\n */\n protected getDuration(): number {\n return new Date().getTime() - this.dateStart.getTime();\n }\n\n protected getData(obj: any) {\n if (typeof obj === \"string\") {\n obj = {message: obj};\n }\n\n return {...this.#additionalProps, reqId: this.id, time: new Date(), duration: this.getDuration(), ...obj};\n }\n\n protected run(level: LogLevel, obj: any, withRequest?: boolean) {\n if (!this.isLevelEnabled(level)) {\n return;\n }\n\n const ignore = this.#hooks?.alter(\"ignore\", false, [obj]);\n\n if (!ignore) {\n const levelStr = level.levelStr.toLowerCase();\n\n obj = this.hooks.alter(\"log\", this.getData(obj), [levelStr, withRequest]);\n\n this.stack.push({level: levelStr, data: obj});\n }\n\n if (this.#maxStackSize < this.stack.length) {\n this.flush();\n }\n }\n}\n"]}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ControllerProvider = void 0;
|
|
4
|
+
const Provider_1 = require("./Provider");
|
|
5
|
+
const ProviderType_1 = require("./ProviderType");
|
|
6
|
+
class ControllerProvider extends Provider_1.Provider {
|
|
7
|
+
tokenRouter;
|
|
8
|
+
constructor(provide, options = {}) {
|
|
9
|
+
super(provide, options);
|
|
10
|
+
this.type = ProviderType_1.ProviderType.CONTROLLER;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
*
|
|
14
|
+
* @returns {any[]}
|
|
15
|
+
*/
|
|
16
|
+
get middlewares() {
|
|
17
|
+
return Object.assign({
|
|
18
|
+
use: [],
|
|
19
|
+
useAfter: [],
|
|
20
|
+
useBefore: []
|
|
21
|
+
}, this.store.get("middlewares", {}));
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
*
|
|
25
|
+
* @param middlewares
|
|
26
|
+
*/
|
|
27
|
+
set middlewares(middlewares) {
|
|
28
|
+
const mdlwrs = this.middlewares;
|
|
29
|
+
const concat = (key, a, b) => (a[key] = a[key].concat(b[key]));
|
|
30
|
+
Object.keys(middlewares).forEach((key) => {
|
|
31
|
+
concat(key, mdlwrs, middlewares);
|
|
32
|
+
});
|
|
33
|
+
this.store.set("middlewares", mdlwrs);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
exports.ControllerProvider = ControllerProvider;
|
|
37
|
+
//# sourceMappingURL=ControllerProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ControllerProvider.js","sourceRoot":"","sources":["../../../src/domain/ControllerProvider.ts"],"names":[],"mappings":";;;AAEA,yCAAoC;AACpC,iDAA4C;AAE5C,MAAa,kBAA4B,SAAQ,mBAAW;IACnD,WAAW,CAAS;IAE3B,YAAY,OAAsB,EAAE,UAA6B,EAAE;QACjE,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACxB,IAAI,CAAC,IAAI,GAAG,2BAAY,CAAC,UAAU,CAAC;IACtC,CAAC;IAED;;;OAGG;IACH,IAAI,WAAW;QACb,OAAO,MAAM,CAAC,MAAM,CAClB;YACE,GAAG,EAAE,EAAE;YACP,QAAQ,EAAE,EAAE;YACZ,SAAS,EAAE,EAAE;SACd,EACD,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,aAAa,EAAE,EAAE,CAAC,CAClC,CAAC;IACJ,CAAC;IAED;;;OAGG;IACH,IAAI,WAAW,CAAC,WAAkC;QAChD,MAAM,MAAM,GAAG,IAAI,CAAC,WAAW,CAAC;QAChC,MAAM,MAAM,GAAG,CAAC,GAAW,EAAE,CAAM,EAAE,CAAM,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QAEjF,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,OAAO,CAAC,CAAC,GAAW,EAAE,EAAE;YAC/C,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC;QACnC,CAAC,CAAC,CAAC;QAEH,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,aAAa,EAAE,MAAM,CAAC,CAAC;IACxC,CAAC;CACF;AArCD,gDAqCC","sourcesContent":["import {ControllerMiddlewares} from \"../decorators/controller\";\nimport {TokenProvider} from \"../interfaces/TokenProvider\";\nimport {Provider} from \"./Provider\";\nimport {ProviderType} from \"./ProviderType\";\n\nexport class ControllerProvider<T = any> extends Provider<T> {\n public tokenRouter: string;\n\n constructor(provide: TokenProvider, options: Partial<Provider> = {}) {\n super(provide, options);\n this.type = ProviderType.CONTROLLER;\n }\n\n /**\n *\n * @returns {any[]}\n */\n get middlewares(): ControllerMiddlewares {\n return Object.assign(\n {\n use: [],\n useAfter: [],\n useBefore: []\n },\n this.store.get(\"middlewares\", {})\n );\n }\n\n /**\n *\n * @param middlewares\n */\n set middlewares(middlewares: ControllerMiddlewares) {\n const mdlwrs = this.middlewares;\n const concat = (key: string, a: any, b: any) => (a[key] = a[key].concat(b[key]));\n\n Object.keys(middlewares).forEach((key: string) => {\n concat(key, mdlwrs, middlewares);\n });\n\n this.store.set(\"middlewares\", mdlwrs);\n }\n}\n"]}
|
|
@@ -6,6 +6,7 @@ const ContextLogger_1 = require("./ContextLogger");
|
|
|
6
6
|
const LocalsContainer_1 = require("./LocalsContainer");
|
|
7
7
|
class DIContext extends Map {
|
|
8
8
|
options;
|
|
9
|
+
opts;
|
|
9
10
|
/**
|
|
10
11
|
* The request container used by the Ts.ED DI. It contain all services annotated with `@Scope(ProviderScope.REQUEST)`
|
|
11
12
|
*/
|
|
@@ -59,7 +60,9 @@ class DIContext extends Map {
|
|
|
59
60
|
async destroy() {
|
|
60
61
|
await this.container.destroy();
|
|
61
62
|
this.logger.destroy();
|
|
62
|
-
this.opts =
|
|
63
|
+
this.opts = {
|
|
64
|
+
id: this.opts.id
|
|
65
|
+
};
|
|
63
66
|
this.container = null;
|
|
64
67
|
}
|
|
65
68
|
async emit(eventName, ...args) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DIContext.js","sourceRoot":"","sources":["../../../src/domain/DIContext.ts"],"names":[],"mappings":";;;AAEA,wDAAmD;AACnD,mDAAoE;AACpE,uDAAkD;AAkBlD,MAAa,SAAU,SAAQ,GAAa;
|
|
1
|
+
{"version":3,"file":"DIContext.js","sourceRoot":"","sources":["../../../src/domain/DIContext.ts"],"names":[],"mappings":";;;AAEA,wDAAmD;AACnD,mDAAoE;AACpE,uDAAkD;AAkBlD,MAAa,SAAU,SAAQ,GAAa;IAcrB;IAXrB,IAAI,CAAmB;IAEvB;;OAEG;IACI,SAAS,GAAG,IAAI,iCAAe,EAAO,CAAC;IAC9C;;OAEG;IACM,MAAM,CAAgB;IAE/B,YAAqB,OAAyB;QAC5C,KAAK,EAAE,CAAC;QADW,YAAO,GAAP,OAAO,CAAkB;QAE5C,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC;QACpB,IAAI,CAAC,MAAM,GAAG,IAAI,6BAAa,CAAC,IAAI,CAAC,CAAC;IACxC,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACH,IAAI,EAAE;QACJ,OAAO,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;IACtB,CAAC;IAED,IAAI,SAAS;QACX,OAAO,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC;IAC/B,CAAC;IAED,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,IAAI,CAAC,QAAS,CAAC;IAC7B,CAAC;IAED,IAAI,GAAG;QACL,OAAO,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IAC3C,CAAC;IAED,KAAK,CAAC,OAAO;QACX,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC;QAC/B,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QACtB,IAAI,CAAC,IAAI,GAAG;YACV,EAAE,EAAE,IAAI,CAAC,IAAI,CAAC,EAAE;SACV,CAAC;QACT,IAAI,CAAC,SAAS,GAAG,IAAW,CAAC;IAC/B,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,SAAiB,EAAE,GAAG,IAAW;QAC1C,OAAO,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,SAAS,EAAE,GAAG,IAAI,CAAC,CAAC;IACjD,CAAC;IAED,KAAK,CAAC,YAAY,CAAC,IAAc;QAC/B,IAAI,GAAG,CAAC,MAAM,IAAI,CAAC,QAAQ,EAAE,UAAU,CAAC,oBAAoB,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC;QAEnF,OAAO,IAAA,2BAAY,EAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAClC,CAAC;CACF;AA9ED,8BA8EC","sourcesContent":["import type {Env} from \"@tsed/core\";\nimport {InjectorService} from \"../services/InjectorService\";\nimport {runInContext} from \"../utils/runInContext\";\nimport {ContextLogger, ContextLoggerOptions} from \"./ContextLogger\";\nimport {LocalsContainer} from \"./LocalsContainer\";\n\nexport interface ContextMethods extends Map<any, any> {\n readonly id: string;\n readonly logger: ContextLogger;\n readonly injector: InjectorService;\n readonly container: LocalsContainer;\n readonly env: Env;\n\n destroy(): any;\n}\n\nexport interface DIContextOptions extends Omit<ContextLoggerOptions, \"dateStart\"> {\n id: string;\n injector: InjectorService;\n logger: any;\n}\n\nexport class DIContext extends Map<any, any> implements ContextMethods {\n [x: string]: any;\n\n opts: DIContextOptions;\n\n /**\n * The request container used by the Ts.ED DI. It contain all services annotated with `@Scope(ProviderScope.REQUEST)`\n */\n public container = new LocalsContainer<any>();\n /**\n * Logger attached to the context request.\n */\n readonly logger: ContextLogger;\n\n constructor(readonly options: DIContextOptions) {\n super();\n this.opts = options;\n this.logger = new ContextLogger(this);\n }\n\n /**\n * Request id generated by @@contextMiddleware@@.\n *\n * ::: tip\n * By default Ts.ED generate uuid like that `uuidv4().replace(/-/gi, \"\"))`.\n * Dash are removed to simplify tracking logs in Kibana\n * :::\n *\n * ::: tip\n * Request id can by customized by changing the server configuration.\n *\n * ```typescript\n * @Configuration({\n * logger: {\n * reqIdBuilder: createUniqId // give your own id generator function\n * }\n * })\n * class Server {\n *\n * }\n * ```\n * :::\n *\n */\n get id() {\n return this.opts.id;\n }\n\n get dateStart() {\n return this.logger.dateStart;\n }\n\n get injector(): InjectorService {\n return this.opts.injector!;\n }\n\n get env() {\n return this.injector.settings.get(\"env\");\n }\n\n async destroy() {\n await this.container.destroy();\n this.logger.destroy();\n this.opts = {\n id: this.opts.id\n } as any;\n this.container = null as any;\n }\n\n async emit(eventName: string, ...args: any[]) {\n return this.injector?.emit(eventName, ...args);\n }\n\n async runInContext(next: Function) {\n next = (await this.injector?.alterAsync(\"$alterRunInContext\", next, this)) || next;\n\n return runInContext(this, next);\n }\n}\n\nexport type BaseContext = DIContext & TsED.Context;\n"]}
|
package/lib/cjs/index.js
CHANGED
|
@@ -22,6 +22,7 @@ tslib_1.__exportStar(require("./decorators/useOpts"), exports);
|
|
|
22
22
|
tslib_1.__exportStar(require("./decorators/value"), exports);
|
|
23
23
|
tslib_1.__exportStar(require("./domain/Container"), exports);
|
|
24
24
|
tslib_1.__exportStar(require("./domain/ContextLogger"), exports);
|
|
25
|
+
tslib_1.__exportStar(require("./domain/ControllerProvider"), exports);
|
|
25
26
|
tslib_1.__exportStar(require("./domain/DIContext"), exports);
|
|
26
27
|
tslib_1.__exportStar(require("./domain/InjectablePropertyType"), exports);
|
|
27
28
|
tslib_1.__exportStar(require("./domain/LocalsContainer"), exports);
|
package/lib/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,gEAAsC;AACtC,qEAA2C;AAC3C,gEAAsC;AACtC,kEAAwC;AACxC,8DAAoC;AACpC,kEAAwC;AACxC,iEAAuC;AACvC,mEAAyC;AACzC,kEAAwC;AACxC,8DAAoC;AACpC,4DAAkC;AAClC,wEAA8C;AAC9C,6DAAmC;AACnC,+DAAqC;AACrC,+DAAqC;AACrC,6DAAmC;AACnC,6DAAmC;AACnC,iEAAuC;AACvC,6DAAmC;AACnC,0EAAgD;AAChD,mEAAyC;AACzC,4DAAkC;AAClC,iEAAuC;AACvC,gEAAsC;AACtC,kEAAwC;AACxC,uEAA6C;AAC7C,yEAA+C;AAC/C,8EAAoD;AACpD,gEAAsC;AACtC,uEAA6C;AAC7C,kEAAwC;AACxC,4EAAkD;AAClD,0EAAgD;AAChD,0EAAgD;AAChD,qEAA2C;AAC3C,iEAAuC;AACvC,8DAAoC;AACpC,oEAA0C;AAC1C,wEAA8C;AAC9C,6EAAmD;AACnD,qEAA2C;AAC3C,kEAAwC;AACxC,uEAA6C;AAC7C,wEAA8C;AAC9C,qEAA2C;AAC3C,8DAAoC;AACpC,4DAAkC;AAClC,qEAA2C;AAC3C,yDAA+B;AAC/B,kEAAwC;AACxC,mEAAyC;AACzC,qEAA2C;AAC3C,+DAAqC;AACrC,yEAA+C;AAC/C,kEAAwC;AACxC,iEAAuC","sourcesContent":["/**\n * @file Automatically generated by barrelsby.\n */\n\nexport * from \"./constants/constants\";\nexport * from \"./decorators/configuration\";\nexport * from \"./decorators/constant\";\nexport * from \"./decorators/controller\";\nexport * from \"./decorators/inject\";\nexport * from \"./decorators/injectable\";\nexport * from \"./decorators/intercept\";\nexport * from \"./decorators/interceptor\";\nexport * from \"./decorators/lazyInject\";\nexport * from \"./decorators/module\";\nexport * from \"./decorators/opts\";\nexport * from \"./decorators/overrideProvider\";\nexport * from \"./decorators/scope\";\nexport * from \"./decorators/service\";\nexport * from \"./decorators/useOpts\";\nexport * from \"./decorators/value\";\nexport * from \"./domain/Container\";\nexport * from \"./domain/ContextLogger\";\nexport * from \"./domain/DIContext\";\nexport * from \"./domain/InjectablePropertyType\";\nexport * from \"./domain/LocalsContainer\";\nexport * from \"./domain/Provider\";\nexport * from \"./domain/ProviderScope\";\nexport * from \"./domain/ProviderType\";\nexport * from \"./errors/InjectionError\";\nexport * from \"./errors/UndefinedTokenError\";\nexport * from \"./interfaces/AlterRunInContext\";\nexport * from \"./interfaces/DIConfigurationOptions\";\nexport * from \"./interfaces/DILogger\";\nexport * from \"./interfaces/DILoggerOptions\";\nexport * from \"./interfaces/DIResolver\";\nexport * from \"./interfaces/InjectableProperties\";\nexport * from \"./interfaces/InterceptorContext\";\nexport * from \"./interfaces/InterceptorMethods\";\nexport * from \"./interfaces/InvokeOptions\";\nexport * from \"./interfaces/OnDestroy\";\nexport * from \"./interfaces/OnInit\";\nexport * from \"./interfaces/ProviderOpts\";\nexport * from \"./interfaces/RegistrySettings\";\nexport * from \"./interfaces/ResolvedInvokeOptions\";\nexport * from \"./interfaces/TokenProvider\";\nexport * from \"./interfaces/TokenRoute\";\nexport * from \"./registries/GlobalProviders\";\nexport * from \"./registries/ProviderRegistry\";\nexport * from \"./services/DIConfiguration\";\nexport * from \"./services/DILogger\";\nexport * from \"./services/DITest\";\nexport * from \"./services/InjectorService\";\nexport * from \"./utils/colors\";\nexport * from \"./utils/createContainer\";\nexport * from \"./utils/getConfiguration\";\nexport * from \"./utils/resolveControllers\";\nexport * from \"./utils/runInContext\";\nexport * from \"./utils/setLoggerConfiguration\";\nexport * from \"./utils/setLoggerFormat\";\nexport * from \"./utils/setLoggerLevel\";\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,gEAAsC;AACtC,qEAA2C;AAC3C,gEAAsC;AACtC,kEAAwC;AACxC,8DAAoC;AACpC,kEAAwC;AACxC,iEAAuC;AACvC,mEAAyC;AACzC,kEAAwC;AACxC,8DAAoC;AACpC,4DAAkC;AAClC,wEAA8C;AAC9C,6DAAmC;AACnC,+DAAqC;AACrC,+DAAqC;AACrC,6DAAmC;AACnC,6DAAmC;AACnC,iEAAuC;AACvC,sEAA4C;AAC5C,6DAAmC;AACnC,0EAAgD;AAChD,mEAAyC;AACzC,4DAAkC;AAClC,iEAAuC;AACvC,gEAAsC;AACtC,kEAAwC;AACxC,uEAA6C;AAC7C,yEAA+C;AAC/C,8EAAoD;AACpD,gEAAsC;AACtC,uEAA6C;AAC7C,kEAAwC;AACxC,4EAAkD;AAClD,0EAAgD;AAChD,0EAAgD;AAChD,qEAA2C;AAC3C,iEAAuC;AACvC,8DAAoC;AACpC,oEAA0C;AAC1C,wEAA8C;AAC9C,6EAAmD;AACnD,qEAA2C;AAC3C,kEAAwC;AACxC,uEAA6C;AAC7C,wEAA8C;AAC9C,qEAA2C;AAC3C,8DAAoC;AACpC,4DAAkC;AAClC,qEAA2C;AAC3C,yDAA+B;AAC/B,kEAAwC;AACxC,mEAAyC;AACzC,qEAA2C;AAC3C,+DAAqC;AACrC,yEAA+C;AAC/C,kEAAwC;AACxC,iEAAuC","sourcesContent":["/**\n * @file Automatically generated by barrelsby.\n */\n\nexport * from \"./constants/constants\";\nexport * from \"./decorators/configuration\";\nexport * from \"./decorators/constant\";\nexport * from \"./decorators/controller\";\nexport * from \"./decorators/inject\";\nexport * from \"./decorators/injectable\";\nexport * from \"./decorators/intercept\";\nexport * from \"./decorators/interceptor\";\nexport * from \"./decorators/lazyInject\";\nexport * from \"./decorators/module\";\nexport * from \"./decorators/opts\";\nexport * from \"./decorators/overrideProvider\";\nexport * from \"./decorators/scope\";\nexport * from \"./decorators/service\";\nexport * from \"./decorators/useOpts\";\nexport * from \"./decorators/value\";\nexport * from \"./domain/Container\";\nexport * from \"./domain/ContextLogger\";\nexport * from \"./domain/ControllerProvider\";\nexport * from \"./domain/DIContext\";\nexport * from \"./domain/InjectablePropertyType\";\nexport * from \"./domain/LocalsContainer\";\nexport * from \"./domain/Provider\";\nexport * from \"./domain/ProviderScope\";\nexport * from \"./domain/ProviderType\";\nexport * from \"./errors/InjectionError\";\nexport * from \"./errors/UndefinedTokenError\";\nexport * from \"./interfaces/AlterRunInContext\";\nexport * from \"./interfaces/DIConfigurationOptions\";\nexport * from \"./interfaces/DILogger\";\nexport * from \"./interfaces/DILoggerOptions\";\nexport * from \"./interfaces/DIResolver\";\nexport * from \"./interfaces/InjectableProperties\";\nexport * from \"./interfaces/InterceptorContext\";\nexport * from \"./interfaces/InterceptorMethods\";\nexport * from \"./interfaces/InvokeOptions\";\nexport * from \"./interfaces/OnDestroy\";\nexport * from \"./interfaces/OnInit\";\nexport * from \"./interfaces/ProviderOpts\";\nexport * from \"./interfaces/RegistrySettings\";\nexport * from \"./interfaces/ResolvedInvokeOptions\";\nexport * from \"./interfaces/TokenProvider\";\nexport * from \"./interfaces/TokenRoute\";\nexport * from \"./registries/GlobalProviders\";\nexport * from \"./registries/ProviderRegistry\";\nexport * from \"./services/DIConfiguration\";\nexport * from \"./services/DILogger\";\nexport * from \"./services/DITest\";\nexport * from \"./services/InjectorService\";\nexport * from \"./utils/colors\";\nexport * from \"./utils/createContainer\";\nexport * from \"./utils/getConfiguration\";\nexport * from \"./utils/resolveControllers\";\nexport * from \"./utils/runInContext\";\nexport * from \"./utils/setLoggerConfiguration\";\nexport * from \"./utils/setLoggerFormat\";\nexport * from \"./utils/setLoggerLevel\";\n"]}
|
|
@@ -16,7 +16,17 @@ function runInContext(ctx, cb) {
|
|
|
16
16
|
}
|
|
17
17
|
exports.runInContext = runInContext;
|
|
18
18
|
function bindContext(cb) {
|
|
19
|
-
|
|
19
|
+
if (getContext()) {
|
|
20
|
+
let localArgs;
|
|
21
|
+
const newCB = async_hooks_1.AsyncResource.bind(() => cb(...localArgs));
|
|
22
|
+
// FIXME: remove this hack when the support of v14 will be removed
|
|
23
|
+
// see issue: https://github.com/nodejs/node/issues/36051
|
|
24
|
+
return (...args) => {
|
|
25
|
+
localArgs = args;
|
|
26
|
+
return newCB(...args);
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
return cb;
|
|
20
30
|
}
|
|
21
31
|
exports.bindContext = bindContext;
|
|
22
32
|
//# sourceMappingURL=runInContext.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runInContext.js","sourceRoot":"","sources":["../../../src/utils/runInContext.ts"],"names":[],"mappings":";;;AAAA,6CAA6D;AAG7D,MAAM,OAAO,GAAiC,IAAI,+BAAiB,EAAE,CAAC;AAEtE,SAAgB,aAAa;IAC3B,OAAO,OAAO,CAAC;AACjB,CAAC;AAFD,sCAEC;AAED,SAAgB,UAAU;IACxB,OAAO,aAAa,EAAE,CAAC,QAAQ,EAAS,CAAC;AAC3C,CAAC;AAFD,gCAEC;AAED,SAAgB,YAAY,CAAC,GAAc,EAAE,EAAO;IAClD,OAAO,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;AAC9B,CAAC;AAFD,oCAEC;AAED,SAAgB,WAAW,CAAC,EAAO;IACjC,
|
|
1
|
+
{"version":3,"file":"runInContext.js","sourceRoot":"","sources":["../../../src/utils/runInContext.ts"],"names":[],"mappings":";;;AAAA,6CAA6D;AAG7D,MAAM,OAAO,GAAiC,IAAI,+BAAiB,EAAE,CAAC;AAEtE,SAAgB,aAAa;IAC3B,OAAO,OAAO,CAAC;AACjB,CAAC;AAFD,sCAEC;AAED,SAAgB,UAAU;IACxB,OAAO,aAAa,EAAE,CAAC,QAAQ,EAAS,CAAC;AAC3C,CAAC;AAFD,gCAEC;AAED,SAAgB,YAAY,CAAC,GAAc,EAAE,EAAO;IAClD,OAAO,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;AAC9B,CAAC;AAFD,oCAEC;AAED,SAAgB,WAAW,CAAC,EAAO;IACjC,IAAI,UAAU,EAAE,EAAE;QAChB,IAAI,SAAc,CAAC;QACnB,MAAM,KAAK,GAAQ,2BAAa,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC;QAE9D,kEAAkE;QAClE,yDAAyD;QACzD,OAAO,CAAC,GAAG,IAAS,EAAE,EAAE;YACtB,SAAS,GAAG,IAAI,CAAC;YACjB,OAAO,KAAK,CAAC,GAAG,IAAI,CAAC,CAAC;QACxB,CAAC,CAAC;KACH;IAED,OAAO,EAAE,CAAC;AACZ,CAAC;AAdD,kCAcC","sourcesContent":["import {AsyncLocalStorage, AsyncResource} from \"async_hooks\";\nimport {DIContext} from \"../domain/DIContext\";\n\nconst storage: AsyncLocalStorage<DIContext> = new AsyncLocalStorage();\n\nexport function getAsyncStore() {\n return storage;\n}\n\nexport function getContext<Context = DIContext>(): Context | undefined {\n return getAsyncStore().getStore() as any;\n}\n\nexport function runInContext(ctx: DIContext, cb: any) {\n return storage.run(ctx, cb);\n}\n\nexport function bindContext(cb: any) {\n if (getContext()) {\n let localArgs: any;\n const newCB: any = AsyncResource.bind(() => cb(...localArgs));\n\n // FIXME: remove this hack when the support of v14 will be removed\n // see issue: https://github.com/nodejs/node/issues/36051\n return (...args: any) => {\n localArgs = args;\n return newCB(...args);\n };\n }\n\n return cb;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"controller.js","sourceRoot":"","sources":["../../../src/decorators/controller.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,mBAAmB,EAAQ,aAAa,EAAC,MAAM,YAAY,CAAC;AACpE,OAAO,EAAC,QAAQ,EAAE,IAAI,EAAC,MAAM,cAAc,CAAC;AAE5C,OAAO,EAAC,kBAAkB,EAAC,MAAM,gCAAgC,CAAC;
|
|
1
|
+
{"version":3,"file":"controller.js","sourceRoot":"","sources":["../../../src/decorators/controller.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,mBAAmB,EAAQ,aAAa,EAAC,MAAM,YAAY,CAAC;AACpE,OAAO,EAAC,QAAQ,EAAE,IAAI,EAAC,MAAM,cAAc,CAAC;AAE5C,OAAO,EAAC,kBAAkB,EAAC,MAAM,gCAAgC,CAAC;AAgBlE,SAAS,UAAU,CAAC,OAAY;IAC9B,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,YAAY,MAAM,IAAI,mBAAmB,CAAC,OAAO,CAAC,EAAE;QAC5F,OAAO;YACL,IAAI,EAAE,OAAO;SACd,CAAC;KACH;IAED,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAM,UAAU,UAAU,CAAC,OAAqC;IAC9D,MAAM,EAAC,QAAQ,GAAG,EAAE,EAAE,IAAI,EAAE,GAAG,IAAI,EAAC,GAAG,UAAU,CAAC,OAAO,CAAC,CAAC;IAE3D,OAAO,aAAa,CAClB,CAAC,MAAY,EAAE,EAAE;QACf,kBAAkB,CAAC;YACjB,OAAO,EAAE,MAAM;YACf,GAAG,IAAI;SACR,CAAC,CAAC;IACL,CAAC,EACD,IAAI,IAAI,IAAI,CAAC,IAAW,CAAC,EACzB,QAAQ,CAAC,GAAG,QAAQ,CAAC,CACtB,CAAC;AACJ,CAAC","sourcesContent":["import {isArrayOrArrayClass, Type, useDecorators} from \"@tsed/core\";\nimport {Children, Path} from \"@tsed/schema\";\nimport {ProviderOpts} from \"../interfaces/ProviderOpts\";\nimport {registerController} from \"../registries/ProviderRegistry\";\n\nexport type PathType = string | RegExp | (string | RegExp)[];\n\nexport interface ControllerMiddlewares {\n useBefore: any[];\n use: any[];\n useAfter: any[];\n}\n\nexport interface ControllerOptions extends Partial<ProviderOpts<any>> {\n path?: PathType;\n children?: Type<any>[];\n middlewares?: Partial<ControllerMiddlewares>;\n}\n\nfunction mapOptions(options: any): ControllerOptions {\n if (typeof options === \"string\" || options instanceof RegExp || isArrayOrArrayClass(options)) {\n return {\n path: options\n };\n }\n\n return options;\n}\n\n/**\n * Declare a new controller with his Rest path. His methods annotated will be collected to build the routing list.\n * This routing listing will be built with the `express.Router` object.\n *\n * ::: tip\n * See [Controllers](/docs/controllers.md) section for more details\n * :::\n *\n * ```typescript\n * @Controller(\"/calendars\")\n * export provide CalendarCtrl {\n *\n * @Get(\"/:id\")\n * public get(\n * @Req() request: Req,\n * @Res() response: Res,\n * @Next() next: Next\n * ): void {\n *\n * }\n * }\n * ```\n *\n * @param options\n * @controller\n * @decorator\n * @classDecorator\n */\nexport function Controller(options: PathType | ControllerOptions): ClassDecorator {\n const {children = [], path, ...opts} = mapOptions(options);\n\n return useDecorators(\n (target: Type) => {\n registerController({\n provide: target,\n ...opts\n });\n },\n path && Path(path as any),\n Children(...children)\n );\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContextLogger.js","sourceRoot":"","sources":["../../../src/domain/ContextLogger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,EAAC,MAAM,YAAY,CAAC;AACjC,OAAO,EAAC,MAAM,EAAW,MAAM,cAAc,CAAC;AAY9C,MAAM,MAAM,GAA6B,MAAM,EAAE,CAAC;AAElD,MAAM,OAAO,aAAa;
|
|
1
|
+
{"version":3,"file":"ContextLogger.js","sourceRoot":"","sources":["../../../src/domain/ContextLogger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,EAAC,MAAM,YAAY,CAAC;AACjC,OAAO,EAAC,MAAM,EAAW,MAAM,cAAc,CAAC;AAY9C,MAAM,MAAM,GAA6B,MAAM,EAAE,CAAC;AAElD,MAAM,OAAO,aAAa;IAUO;IATtB,SAAS,CAAO;IAChB,gBAAgB,CAA2B;IAEpD,MAAM,CAAS;IACf,aAAa,CAAS;IACtB,MAAM,CAAS;IACf,MAAM,CAAW;IACjB,OAAO,CAAM;IAEb,YAA+B,IAAe;QA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port {DILogger} from \"../interfaces/DILogger\";\nimport type {DIContext} from \"./DIContext\";\n\nexport interface ContextLoggerOptions extends Record<string, any> {\n id: string;\n logger?: DILogger;\n level?: \"debug\" | \"info\" | \"warn\" | \"error\" | \"off\" | \"all\";\n maxStackSize?: number;\n additionalProps?: Record<any, any>;\n}\n\nconst LEVELS: Record<string, LogLevel> = levels();\n\nexport class ContextLogger {\n readonly dateStart: Date;\n readonly #additionalProps?: Record<string, unknown>;\n\n #hooks?: Hooks;\n #maxStackSize: number;\n #stack?: any[];\n #level: LogLevel;\n #logger: any;\n\n constructor(protected readonly $ctx: DIContext) {\n const {logger, dateStart = new Date(), level = \"all\", maxStackSize = 30, additionalProps} = $ctx.opts;\n this.dateStart = dateStart;\n this.#logger = logger;\n this.#additionalProps = additionalProps;\n this.#level = (LEVELS[level.toUpperCase()] || LEVELS.ALL) as LogLevel;\n this.#maxStackSize = maxStackSize;\n }\n\n get id() {\n return this.$ctx.id;\n }\n\n set maxStackSize(maxStackSize: number) {\n this.#maxStackSize = maxStackSize;\n }\n\n get hooks() {\n return (this.#hooks = this.#hooks || new Hooks());\n }\n\n private get stack() {\n return (this.#stack = this.#stack || []);\n }\n\n alterLog(cb: (data: any, level: \"debug\" | \"info\" | \"warn\" | \"error\" | \"off\" | \"all\", withRequest: boolean) => any) {\n return this.hooks.on(\"log\", cb);\n }\n\n alterIgnoreLog(cb: (ignore: boolean, data: any) => boolean) {\n return this.hooks.on(\"ignore\", cb);\n }\n\n info(obj: any) {\n this.run(levels().INFO, obj);\n return this;\n }\n\n debug(obj: any, withRequest: boolean = true) {\n this.run(levels().DEBUG, obj, withRequest);\n return this;\n }\n\n warn(obj: any) {\n this.run(levels().WARN, obj);\n return this;\n }\n\n error(obj: any) {\n this.run(levels().ERROR, obj);\n return this;\n }\n\n trace(obj: any) {\n this.run(levels().TRACE, obj);\n return this;\n }\n\n public flush() {\n if (this.stack.length) {\n this.stack.forEach(({level, data}: any) => {\n this.#logger[level](data);\n });\n\n this.#stack = [];\n }\n }\n\n public isLevelEnabled(otherLevel: string | LogLevel) {\n return this.#level.isLessThanOrEqualTo(otherLevel);\n }\n\n destroy() {\n this.flush();\n this.#maxStackSize = 0;\n this.#stack = [];\n this.#logger = null;\n }\n\n /**\n * Return the duration between the time when LogIncomingRequest has handle the request and now.\n * @returns {number}\n */\n protected getDuration(): number {\n return new Date().getTime() - this.dateStart.getTime();\n }\n\n protected getData(obj: any) {\n if (typeof obj === \"string\") {\n obj = {message: obj};\n }\n\n return {...this.#additionalProps, reqId: this.id, time: new Date(), duration: this.getDuration(), ...obj};\n }\n\n protected run(level: LogLevel, obj: any, withRequest?: boolean) {\n if (!this.isLevelEnabled(level)) {\n return;\n }\n\n const ignore = this.#hooks?.alter(\"ignore\", false, [obj]);\n\n if (!ignore) {\n const levelStr = level.levelStr.toLowerCase();\n\n obj = this.hooks.alter(\"log\", this.getData(obj), [levelStr, withRequest]);\n\n this.stack.push({level: levelStr, data: obj});\n }\n\n if (this.#maxStackSize < this.stack.length) {\n this.flush();\n }\n }\n}\n"]}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Provider } from "./Provider.js";
|
|
2
|
+
import { ProviderType } from "./ProviderType.js";
|
|
3
|
+
export class ControllerProvider extends Provider {
|
|
4
|
+
tokenRouter;
|
|
5
|
+
constructor(provide, options = {}) {
|
|
6
|
+
super(provide, options);
|
|
7
|
+
this.type = ProviderType.CONTROLLER;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
*
|
|
11
|
+
* @returns {any[]}
|
|
12
|
+
*/
|
|
13
|
+
get middlewares() {
|
|
14
|
+
return Object.assign({
|
|
15
|
+
use: [],
|
|
16
|
+
useAfter: [],
|
|
17
|
+
useBefore: []
|
|
18
|
+
}, this.store.get("middlewares", {}));
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
*
|
|
22
|
+
* @param middlewares
|
|
23
|
+
*/
|
|
24
|
+
set middlewares(middlewares) {
|
|
25
|
+
const mdlwrs = this.middlewares;
|
|
26
|
+
const concat = (key, a, b) => (a[key] = a[key].concat(b[key]));
|
|
27
|
+
Object.keys(middlewares).forEach((key) => {
|
|
28
|
+
concat(key, mdlwrs, middlewares);
|
|
29
|
+
});
|
|
30
|
+
this.store.set("middlewares", mdlwrs);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=ControllerProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ControllerProvider.js","sourceRoot":"","sources":["../../../src/domain/ControllerProvider.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,QAAQ,EAAC,MAAM,YAAY,CAAC;AACpC,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAC;AAE5C,MAAM,OAAO,kBAA4B,SAAQ,QAAW;IACnD,WAAW,CAAS;IAE3B,YAAY,OAAsB,EAAE,UAA6B,EAAE;QACjE,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACxB,IAAI,CAAC,IAAI,GAAG,YAAY,CAAC,UAAU,CAAC;IACtC,CAAC;IAED;;;OAGG;IACH,IAAI,WAAW;QACb,OAAO,MAAM,CAAC,MAAM,CAClB;YACE,GAAG,EAAE,EAAE;YACP,QAAQ,EAAE,EAAE;YACZ,SAAS,EAAE,EAAE;SACd,EACD,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,aAAa,EAAE,EAAE,CAAC,CAClC,CAAC;IACJ,CAAC;IAED;;;OAGG;IACH,IAAI,WAAW,CAAC,WAAkC;QAChD,MAAM,MAAM,GAAG,IAAI,CAAC,WAAW,CAAC;QAChC,MAAM,MAAM,GAAG,CAAC,GAAW,EAAE,CAAM,EAAE,CAAM,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QAEjF,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,OAAO,CAAC,CAAC,GAAW,EAAE,EAAE;YAC/C,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC;QACnC,CAAC,CAAC,CAAC;QAEH,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,aAAa,EAAE,MAAM,CAAC,CAAC;IACxC,CAAC;CACF","sourcesContent":["import {ControllerMiddlewares} from \"../decorators/controller\";\nimport {TokenProvider} from \"../interfaces/TokenProvider\";\nimport {Provider} from \"./Provider\";\nimport {ProviderType} from \"./ProviderType\";\n\nexport class ControllerProvider<T = any> extends Provider<T> {\n public tokenRouter: string;\n\n constructor(provide: TokenProvider, options: Partial<Provider> = {}) {\n super(provide, options);\n this.type = ProviderType.CONTROLLER;\n }\n\n /**\n *\n * @returns {any[]}\n */\n get middlewares(): ControllerMiddlewares {\n return Object.assign(\n {\n use: [],\n useAfter: [],\n useBefore: []\n },\n this.store.get(\"middlewares\", {})\n );\n }\n\n /**\n *\n * @param middlewares\n */\n set middlewares(middlewares: ControllerMiddlewares) {\n const mdlwrs = this.middlewares;\n const concat = (key: string, a: any, b: any) => (a[key] = a[key].concat(b[key]));\n\n Object.keys(middlewares).forEach((key: string) => {\n concat(key, mdlwrs, middlewares);\n });\n\n this.store.set(\"middlewares\", mdlwrs);\n }\n}\n"]}
|
|
@@ -3,6 +3,7 @@ import { ContextLogger } from "./ContextLogger.js";
|
|
|
3
3
|
import { LocalsContainer } from "./LocalsContainer.js";
|
|
4
4
|
export class DIContext extends Map {
|
|
5
5
|
options;
|
|
6
|
+
opts;
|
|
6
7
|
/**
|
|
7
8
|
* The request container used by the Ts.ED DI. It contain all services annotated with `@Scope(ProviderScope.REQUEST)`
|
|
8
9
|
*/
|
|
@@ -56,7 +57,9 @@ export class DIContext extends Map {
|
|
|
56
57
|
async destroy() {
|
|
57
58
|
await this.container.destroy();
|
|
58
59
|
this.logger.destroy();
|
|
59
|
-
this.opts =
|
|
60
|
+
this.opts = {
|
|
61
|
+
id: this.opts.id
|
|
62
|
+
};
|
|
60
63
|
this.container = null;
|
|
61
64
|
}
|
|
62
65
|
async emit(eventName, ...args) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DIContext.js","sourceRoot":"","sources":["../../../src/domain/DIContext.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,YAAY,EAAC,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAC,aAAa,EAAuB,MAAM,iBAAiB,CAAC;AACpE,OAAO,EAAC,eAAe,EAAC,MAAM,mBAAmB,CAAC;AAkBlD,MAAM,OAAO,SAAU,SAAQ,GAAa;
|
|
1
|
+
{"version":3,"file":"DIContext.js","sourceRoot":"","sources":["../../../src/domain/DIContext.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,YAAY,EAAC,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAC,aAAa,EAAuB,MAAM,iBAAiB,CAAC;AACpE,OAAO,EAAC,eAAe,EAAC,MAAM,mBAAmB,CAAC;AAkBlD,MAAM,OAAO,SAAU,SAAQ,GAAa;IAcrB;IAXrB,IAAI,CAAmB;IAEvB;;OAEG;IACI,SAAS,GAAG,IAAI,eAAe,EAAO,CAAC;IAC9C;;OAEG;IACM,MAAM,CAAgB;IAE/B,YAAqB,OAAyB;QAC5C,KAAK,EAAE,CAAC;QADW,YAAO,GAAP,OAAO,CAAkB;QAE5C,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC;QACpB,IAAI,CAAC,MAAM,GAAG,IAAI,aAAa,CAAC,IAAI,CAAC,CAAC;IACxC,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACH,IAAI,EAAE;QACJ,OAAO,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;IACtB,CAAC;IAED,IAAI,SAAS;QACX,OAAO,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC;IAC/B,CAAC;IAED,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,IAAI,CAAC,QAAS,CAAC;IAC7B,CAAC;IAED,IAAI,GAAG;QACL,OAAO,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IAC3C,CAAC;IAED,KAAK,CAAC,OAAO;QACX,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC;QAC/B,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QACtB,IAAI,CAAC,IAAI,GAAG;YACV,EAAE,EAAE,IAAI,CAAC,IAAI,CAAC,EAAE;SACV,CAAC;QACT,IAAI,CAAC,SAAS,GAAG,IAAW,CAAC;IAC/B,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,SAAiB,EAAE,GAAG,IAAW;QAC1C,OAAO,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,SAAS,EAAE,GAAG,IAAI,CAAC,CAAC;IACjD,CAAC;IAED,KAAK,CAAC,YAAY,CAAC,IAAc;QAC/B,IAAI,GAAG,CAAC,MAAM,IAAI,CAAC,QAAQ,EAAE,UAAU,CAAC,oBAAoB,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC;QAEnF,OAAO,YAAY,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAClC,CAAC;CACF","sourcesContent":["import type {Env} from \"@tsed/core\";\nimport {InjectorService} from \"../services/InjectorService\";\nimport {runInContext} from \"../utils/runInContext\";\nimport {ContextLogger, ContextLoggerOptions} from \"./ContextLogger\";\nimport {LocalsContainer} from \"./LocalsContainer\";\n\nexport interface ContextMethods extends Map<any, any> {\n readonly id: string;\n readonly logger: ContextLogger;\n readonly injector: InjectorService;\n readonly container: LocalsContainer;\n readonly env: Env;\n\n destroy(): any;\n}\n\nexport interface DIContextOptions extends Omit<ContextLoggerOptions, \"dateStart\"> {\n id: string;\n injector: InjectorService;\n logger: any;\n}\n\nexport class DIContext extends Map<any, any> implements ContextMethods {\n [x: string]: any;\n\n opts: DIContextOptions;\n\n /**\n * The request container used by the Ts.ED DI. It contain all services annotated with `@Scope(ProviderScope.REQUEST)`\n */\n public container = new LocalsContainer<any>();\n /**\n * Logger attached to the context request.\n */\n readonly logger: ContextLogger;\n\n constructor(readonly options: DIContextOptions) {\n super();\n this.opts = options;\n this.logger = new ContextLogger(this);\n }\n\n /**\n * Request id generated by @@contextMiddleware@@.\n *\n * ::: tip\n * By default Ts.ED generate uuid like that `uuidv4().replace(/-/gi, \"\"))`.\n * Dash are removed to simplify tracking logs in Kibana\n * :::\n *\n * ::: tip\n * Request id can by customized by changing the server configuration.\n *\n * ```typescript\n * @Configuration({\n * logger: {\n * reqIdBuilder: createUniqId // give your own id generator function\n * }\n * })\n * class Server {\n *\n * }\n * ```\n * :::\n *\n */\n get id() {\n return this.opts.id;\n }\n\n get dateStart() {\n return this.logger.dateStart;\n }\n\n get injector(): InjectorService {\n return this.opts.injector!;\n }\n\n get env() {\n return this.injector.settings.get(\"env\");\n }\n\n async destroy() {\n await this.container.destroy();\n this.logger.destroy();\n this.opts = {\n id: this.opts.id\n } as any;\n this.container = null as any;\n }\n\n async emit(eventName: string, ...args: any[]) {\n return this.injector?.emit(eventName, ...args);\n }\n\n async runInContext(next: Function) {\n next = (await this.injector?.alterAsync(\"$alterRunInContext\", next, this)) || next;\n\n return runInContext(this, next);\n }\n}\n\nexport type BaseContext = DIContext & TsED.Context;\n"]}
|
package/lib/esm/index.js
CHANGED
|
@@ -19,6 +19,7 @@ export * from "./decorators/useOpts.js";
|
|
|
19
19
|
export * from "./decorators/value.js";
|
|
20
20
|
export * from "./domain/Container.js";
|
|
21
21
|
export * from "./domain/ContextLogger.js";
|
|
22
|
+
export * from "./domain/ControllerProvider.js";
|
|
22
23
|
export * from "./domain/DIContext.js";
|
|
23
24
|
export * from "./domain/InjectablePropertyType.js";
|
|
24
25
|
export * from "./domain/LocalsContainer.js";
|
package/lib/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","s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4BAA4B,CAAC;AAC3C,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,gBAAgB,CAAC;AAC/B,cAAc,yBAAyB,CAAC;AACxC,cAAc,0BAA0B,CAAC;AACzC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,sBAAsB,CAAC;AACrC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,yBAAyB,CAAC;AACxC,cAAc,wBAAwB,CAAC","sourcesContent":["/**\n * @file Automatically generated by barrelsby.\n */\n\nexport * from \"./constants/constants\";\nexport * from \"./decorators/configuration\";\nexport * from \"./decorators/constant\";\nexport * from \"./decorators/controller\";\nexport * from \"./decorators/inject\";\nexport * from \"./decorators/injectable\";\nexport * from \"./decorators/intercept\";\nexport * from \"./decorators/interceptor\";\nexport * from \"./decorators/lazyInject\";\nexport * from \"./decorators/module\";\nexport * from \"./decorators/opts\";\nexport * from \"./decorators/overrideProvider\";\nexport * from \"./decorators/scope\";\nexport * from \"./decorators/service\";\nexport * from \"./decorators/useOpts\";\nexport * from \"./decorators/value\";\nexport * from \"./domain/Container\";\nexport * from \"./domain/ContextLogger\";\nexport * from \"./domain/DIContext\";\nexport * from \"./domain/InjectablePropertyType\";\nexport * from \"./domain/LocalsContainer\";\nexport * from \"./domain/Provider\";\nexport * from \"./domain/ProviderScope\";\nexport * from \"./domain/ProviderType\";\nexport * from \"./errors/InjectionError\";\nexport * from \"./errors/UndefinedTokenError\";\nexport * from \"./interfaces/AlterRunInContext\";\nexport * from \"./interfaces/DIConfigurationOptions\";\nexport * from \"./interfaces/DILogger\";\nexport * from \"./interfaces/DILoggerOptions\";\nexport * from \"./interfaces/DIResolver\";\nexport * from \"./interfaces/InjectableProperties\";\nexport * from \"./interfaces/InterceptorContext\";\nexport * from \"./interfaces/InterceptorMethods\";\nexport * from \"./interfaces/InvokeOptions\";\nexport * from \"./interfaces/OnDestroy\";\nexport * from \"./interfaces/OnInit\";\nexport * from \"./interfaces/ProviderOpts\";\nexport * from \"./interfaces/RegistrySettings\";\nexport * from \"./interfaces/ResolvedInvokeOptions\";\nexport * from \"./interfaces/TokenProvider\";\nexport * from \"./interfaces/TokenRoute\";\nexport * from \"./registries/GlobalProviders\";\nexport * from \"./registries/ProviderRegistry\";\nexport * from \"./services/DIConfiguration\";\nexport * from \"./services/DILogger\";\nexport * from \"./services/DITest\";\nexport * from \"./services/InjectorService\";\nexport * from \"./utils/colors\";\nexport * from \"./utils/createContainer\";\nexport * from \"./utils/getConfiguration\";\nexport * from \"./utils/resolveControllers\";\nexport * from \"./utils/runInContext\";\nexport * from \"./utils/setLoggerConfiguration\";\nexport * from \"./utils/setLoggerFormat\";\nexport * from \"./utils/setLoggerLevel\";\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,uBAAuB,CAAC;AACtC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,qBAAqB,CAAC;AACpC,cAAc,yBAAyB,CAAC;AACxC,cAAc,wBAAwB,CAAC;AACvC,cAAc,0BAA0B,CAAC;AACzC,cAAc,yBAAyB,CAAC;AACxC,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,wBAAwB,CAAC;AACvC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,oBAAoB,CAAC;AACnC,cAAc,iCAAiC,CAAC;AAChD,cAAc,0BAA0B,CAAC;AACzC,cAAc,mBAAmB,CAAC;AAClC,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,qCAAqC,CAAC;AACpD,cAAc,uBAAuB,CAAC;AACtC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,yBAAyB,CAAC;AACxC,cAAc,mCAAmC,CAAC;AAClD,cAAc,iCAAiC,CAAC;AAChD,cAAc,iCAAiC,CAAC;AAChD,cAAc,4BAA4B,CAAC;AAC3C,cAAc,wBAAwB,CAAC;AACvC,cAAc,qBAAqB,CAAC;AACpC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,oCAAoC,CAAC;AACnD,cAAc,4BAA4B,CAAC;AAC3C,cAAc,yBAAyB,CAAC;AACxC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,gBAAgB,CAAC;AAC/B,cAAc,yBAAyB,CAAC;AACxC,cAAc,0BAA0B,CAAC;AACzC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,sBAAsB,CAAC;AACrC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,yBAAyB,CAAC;AACxC,cAAc,wBAAwB,CAAC","sourcesContent":["/**\n * @file Automatically generated by barrelsby.\n */\n\nexport * from \"./constants/constants\";\nexport * from \"./decorators/configuration\";\nexport * from \"./decorators/constant\";\nexport * from \"./decorators/controller\";\nexport * from \"./decorators/inject\";\nexport * from \"./decorators/injectable\";\nexport * from \"./decorators/intercept\";\nexport * from \"./decorators/interceptor\";\nexport * from \"./decorators/lazyInject\";\nexport * from \"./decorators/module\";\nexport * from \"./decorators/opts\";\nexport * from \"./decorators/overrideProvider\";\nexport * from \"./decorators/scope\";\nexport * from \"./decorators/service\";\nexport * from \"./decorators/useOpts\";\nexport * from \"./decorators/value\";\nexport * from \"./domain/Container\";\nexport * from \"./domain/ContextLogger\";\nexport * from \"./domain/ControllerProvider\";\nexport * from \"./domain/DIContext\";\nexport * from \"./domain/InjectablePropertyType\";\nexport * from \"./domain/LocalsContainer\";\nexport * from \"./domain/Provider\";\nexport * from \"./domain/ProviderScope\";\nexport * from \"./domain/ProviderType\";\nexport * from \"./errors/InjectionError\";\nexport * from \"./errors/UndefinedTokenError\";\nexport * from \"./interfaces/AlterRunInContext\";\nexport * from \"./interfaces/DIConfigurationOptions\";\nexport * from \"./interfaces/DILogger\";\nexport * from \"./interfaces/DILoggerOptions\";\nexport * from \"./interfaces/DIResolver\";\nexport * from \"./interfaces/InjectableProperties\";\nexport * from \"./interfaces/InterceptorContext\";\nexport * from \"./interfaces/InterceptorMethods\";\nexport * from \"./interfaces/InvokeOptions\";\nexport * from \"./interfaces/OnDestroy\";\nexport * from \"./interfaces/OnInit\";\nexport * from \"./interfaces/ProviderOpts\";\nexport * from \"./interfaces/RegistrySettings\";\nexport * from \"./interfaces/ResolvedInvokeOptions\";\nexport * from \"./interfaces/TokenProvider\";\nexport * from \"./interfaces/TokenRoute\";\nexport * from \"./registries/GlobalProviders\";\nexport * from \"./registries/ProviderRegistry\";\nexport * from \"./services/DIConfiguration\";\nexport * from \"./services/DILogger\";\nexport * from \"./services/DITest\";\nexport * from \"./services/InjectorService\";\nexport * from \"./utils/colors\";\nexport * from \"./utils/createContainer\";\nexport * from \"./utils/getConfiguration\";\nexport * from \"./utils/resolveControllers\";\nexport * from \"./utils/runInContext\";\nexport * from \"./utils/setLoggerConfiguration\";\nexport * from \"./utils/setLoggerFormat\";\nexport * from \"./utils/setLoggerLevel\";\n"]}
|
|
@@ -10,6 +10,16 @@ export function runInContext(ctx, cb) {
|
|
|
10
10
|
return storage.run(ctx, cb);
|
|
11
11
|
}
|
|
12
12
|
export function bindContext(cb) {
|
|
13
|
-
|
|
13
|
+
if (getContext()) {
|
|
14
|
+
let localArgs;
|
|
15
|
+
const newCB = AsyncResource.bind(() => cb(...localArgs));
|
|
16
|
+
// FIXME: remove this hack when the support of v14 will be removed
|
|
17
|
+
// see issue: https://github.com/nodejs/node/issues/36051
|
|
18
|
+
return (...args) => {
|
|
19
|
+
localArgs = args;
|
|
20
|
+
return newCB(...args);
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
return cb;
|
|
14
24
|
}
|
|
15
25
|
//# sourceMappingURL=runInContext.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runInContext.js","sourceRoot":"","sources":["../../../src/utils/runInContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,iBAAiB,EAAE,aAAa,EAAC,MAAM,aAAa,CAAC;AAG7D,MAAM,OAAO,GAAiC,IAAI,iBAAiB,EAAE,CAAC;AAEtE,MAAM,UAAU,aAAa;IAC3B,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,MAAM,UAAU,UAAU;IACxB,OAAO,aAAa,EAAE,CAAC,QAAQ,EAAS,CAAC;AAC3C,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,GAAc,EAAE,EAAO;IAClD,OAAO,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;AAC9B,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,EAAO;IACjC,
|
|
1
|
+
{"version":3,"file":"runInContext.js","sourceRoot":"","sources":["../../../src/utils/runInContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,iBAAiB,EAAE,aAAa,EAAC,MAAM,aAAa,CAAC;AAG7D,MAAM,OAAO,GAAiC,IAAI,iBAAiB,EAAE,CAAC;AAEtE,MAAM,UAAU,aAAa;IAC3B,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,MAAM,UAAU,UAAU;IACxB,OAAO,aAAa,EAAE,CAAC,QAAQ,EAAS,CAAC;AAC3C,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,GAAc,EAAE,EAAO;IAClD,OAAO,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;AAC9B,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,EAAO;IACjC,IAAI,UAAU,EAAE,EAAE;QAChB,IAAI,SAAc,CAAC;QACnB,MAAM,KAAK,GAAQ,aAAa,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC;QAE9D,kEAAkE;QAClE,yDAAyD;QACzD,OAAO,CAAC,GAAG,IAAS,EAAE,EAAE;YACtB,SAAS,GAAG,IAAI,CAAC;YACjB,OAAO,KAAK,CAAC,GAAG,IAAI,CAAC,CAAC;QACxB,CAAC,CAAC;KACH;IAED,OAAO,EAAE,CAAC;AACZ,CAAC","sourcesContent":["import {AsyncLocalStorage, AsyncResource} from \"async_hooks\";\nimport {DIContext} from \"../domain/DIContext\";\n\nconst storage: AsyncLocalStorage<DIContext> = new AsyncLocalStorage();\n\nexport function getAsyncStore() {\n return storage;\n}\n\nexport function getContext<Context = DIContext>(): Context | undefined {\n return getAsyncStore().getStore() as any;\n}\n\nexport function runInContext(ctx: DIContext, cb: any) {\n return storage.run(ctx, cb);\n}\n\nexport function bindContext(cb: any) {\n if (getContext()) {\n let localArgs: any;\n const newCB: any = AsyncResource.bind(() => cb(...localArgs));\n\n // FIXME: remove this hack when the support of v14 will be removed\n // see issue: https://github.com/nodejs/node/issues/36051\n return (...args: any) => {\n localArgs = args;\n return newCB(...args);\n };\n }\n\n return cb;\n}\n"]}
|
|
@@ -11,10 +11,10 @@ export interface ContextLoggerOptions extends Record<string, any> {
|
|
|
11
11
|
}
|
|
12
12
|
export declare class ContextLogger {
|
|
13
13
|
#private;
|
|
14
|
-
readonly $ctx: DIContext;
|
|
14
|
+
protected readonly $ctx: DIContext;
|
|
15
15
|
readonly dateStart: Date;
|
|
16
16
|
constructor($ctx: DIContext);
|
|
17
|
-
get id():
|
|
17
|
+
get id(): string;
|
|
18
18
|
set maxStackSize(maxStackSize: number);
|
|
19
19
|
get hooks(): Hooks;
|
|
20
20
|
private get stack();
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ControllerMiddlewares } from "../decorators/controller";
|
|
2
|
+
import { TokenProvider } from "../interfaces/TokenProvider";
|
|
3
|
+
import { Provider } from "./Provider";
|
|
4
|
+
export declare class ControllerProvider<T = any> extends Provider<T> {
|
|
5
|
+
tokenRouter: string;
|
|
6
|
+
constructor(provide: TokenProvider, options?: Partial<Provider>);
|
|
7
|
+
/**
|
|
8
|
+
*
|
|
9
|
+
* @returns {any[]}
|
|
10
|
+
*/
|
|
11
|
+
get middlewares(): ControllerMiddlewares;
|
|
12
|
+
/**
|
|
13
|
+
*
|
|
14
|
+
* @param middlewares
|
|
15
|
+
*/
|
|
16
|
+
set middlewares(middlewares: ControllerMiddlewares);
|
|
17
|
+
}
|
|
@@ -18,6 +18,7 @@ export interface DIContextOptions extends Omit<ContextLoggerOptions, "dateStart"
|
|
|
18
18
|
export declare class DIContext extends Map<any, any> implements ContextMethods {
|
|
19
19
|
readonly options: DIContextOptions;
|
|
20
20
|
[x: string]: any;
|
|
21
|
+
opts: DIContextOptions;
|
|
21
22
|
/**
|
|
22
23
|
* The request container used by the Ts.ED DI. It contain all services annotated with `@Scope(ProviderScope.REQUEST)`
|
|
23
24
|
*/
|
|
@@ -51,7 +52,7 @@ export declare class DIContext extends Map<any, any> implements ContextMethods {
|
|
|
51
52
|
* :::
|
|
52
53
|
*
|
|
53
54
|
*/
|
|
54
|
-
get id():
|
|
55
|
+
get id(): string;
|
|
55
56
|
get dateStart(): Date;
|
|
56
57
|
get injector(): InjectorService;
|
|
57
58
|
get env(): any;
|
package/lib/types/index.d.ts
CHANGED
|
@@ -19,6 +19,7 @@ export * from "./decorators/useOpts";
|
|
|
19
19
|
export * from "./decorators/value";
|
|
20
20
|
export * from "./domain/Container";
|
|
21
21
|
export * from "./domain/ContextLogger";
|
|
22
|
+
export * from "./domain/ControllerProvider";
|
|
22
23
|
export * from "./domain/DIContext";
|
|
23
24
|
export * from "./domain/InjectablePropertyType";
|
|
24
25
|
export * from "./domain/LocalsContainer";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsed/di",
|
|
3
|
-
"version": "7.0.0-beta.
|
|
3
|
+
"version": "7.0.0-beta.16",
|
|
4
4
|
"description": "DI module for Ts.ED Framework",
|
|
5
5
|
"private": false,
|
|
6
6
|
"source": "./src/index.ts",
|
|
@@ -24,14 +24,14 @@
|
|
|
24
24
|
"tslib": "2.4.0"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"@tsed/core": "7.0.0-beta.
|
|
27
|
+
"@tsed/core": "7.0.0-beta.16",
|
|
28
28
|
"@tsed/logger": ">=6.2.0",
|
|
29
|
-
"@tsed/schema": "7.0.0-beta.
|
|
29
|
+
"@tsed/schema": "7.0.0-beta.16"
|
|
30
30
|
},
|
|
31
31
|
"peerDependencies": {
|
|
32
|
-
"@tsed/core": "^7.0.0-beta.
|
|
32
|
+
"@tsed/core": "^7.0.0-beta.16",
|
|
33
33
|
"@tsed/logger": ">=6.2.0",
|
|
34
|
-
"@tsed/schema": "^7.0.0-beta.
|
|
34
|
+
"@tsed/schema": "^7.0.0-beta.16"
|
|
35
35
|
},
|
|
36
36
|
"peerDependenciesMeta": {
|
|
37
37
|
"@tsed/core": {
|
package/readme.md
CHANGED
|
@@ -169,7 +169,7 @@ Support this project by becoming a sponsor. Your logo will show up here with a l
|
|
|
169
169
|
|
|
170
170
|
The MIT License (MIT)
|
|
171
171
|
|
|
172
|
-
Copyright (c) 2016 -
|
|
172
|
+
Copyright (c) 2016 - 2022 Romain Lenzotti
|
|
173
173
|
|
|
174
174
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
175
175
|
|