@nest-yalc-2/app 1.3.3 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/__tests__/base-app.controller.spec.ts +77 -59
- package/src/app-bootstrap-base.helper.js +4 -4
- package/src/app-bootstrap-base.helper.js.map +1 -1
- package/src/app-bootstrap-base.helper.ts +9 -2
- package/src/app-bootstrap-standalone.helper.js +6 -8
- package/src/app-bootstrap-standalone.helper.js.map +1 -1
- package/src/app-bootstrap-standalone.helper.ts +9 -2
- package/src/app-bootstrap.helper.js +8 -10
- package/src/app-bootstrap.helper.js.map +1 -1
- package/src/app-bootstrap.helper.ts +19 -3
- package/src/app-context.module.js +2 -7
- package/src/app-context.module.js.map +1 -1
- package/src/app-context.service.js +2 -7
- package/src/app-context.service.js.map +1 -1
- package/src/app-imports.factory.d.ts +1 -1
- package/src/app-imports.factory.js +4 -36
- package/src/app-imports.factory.js.map +1 -1
- package/src/app-imports.factory.ts +4 -3
- package/src/app.helper.d.ts +1 -1
- package/src/app.helper.ts +1 -1
- package/src/base-app-module.helper.d.ts +2 -2
- package/src/base-app-module.helper.js +6 -47
- package/src/base-app-module.helper.js.map +1 -1
- package/src/base-app-module.helper.ts +8 -2
- package/src/base-app.controller.js +11 -19
- package/src/base-app.controller.js.map +1 -1
- package/src/base-app.controller.ts +8 -0
- package/src/base-app.interface.d.ts +1 -1
- package/src/base-app.interface.ts +1 -1
- package/src/base-app.service.js +9 -53
- package/src/base-app.service.js.map +1 -1
- package/src/base-app.service.ts +4 -0
- package/src/cls.module.js +5 -8
- package/src/cls.module.js.map +1 -1
- package/src/cls.module.ts +9 -2
- package/src/conf.type.d.ts +1 -1
- package/src/conf.type.ts +1 -1
- package/src/life-cycle-handler.service.d.ts +1 -1
- package/src/life-cycle-handler.service.js +7 -18
- package/src/life-cycle-handler.service.js.map +1 -1
- package/src/life-cycle-handler.service.ts +9 -1
- package/src/unwrap-result.interceptor.js +2 -7
- package/src/unwrap-result.interceptor.js.map +1 -1
package/src/cls.module.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/* istanbul ignore file */
|
|
1
2
|
import { Module } from '@nestjs/common';
|
|
2
3
|
import { FastifyRequest } from 'fastify/types/request.js';
|
|
3
4
|
import { ClsModule, ClsService } from 'nestjs-cls';
|
|
@@ -27,6 +28,7 @@ export class YalcAlsService<
|
|
|
27
28
|
TStorage extends IYalcAsyncLocalStorageAls = IYalcAsyncLocalStorageAls,
|
|
28
29
|
> extends AsyncLocalStorage<TStorage> {}
|
|
29
30
|
|
|
31
|
+
/* istanbul ignore next */
|
|
30
32
|
@Module({
|
|
31
33
|
imports: [
|
|
32
34
|
ClsModule.forRoot({
|
|
@@ -37,7 +39,9 @@ export class YalcAlsService<
|
|
|
37
39
|
mount: true,
|
|
38
40
|
// and use the setup method to
|
|
39
41
|
// provide default store values.
|
|
42
|
+
/* istanbul ignore next */
|
|
40
43
|
setup: (cls, req) => {
|
|
44
|
+
/* istanbul ignore next */
|
|
41
45
|
cls.set('headers', req.headers);
|
|
42
46
|
},
|
|
43
47
|
/**
|
|
@@ -45,8 +49,11 @@ export class YalcAlsService<
|
|
|
45
49
|
* So it won't be overwritten if it's already set (e.g. http local strategy case)
|
|
46
50
|
*/
|
|
47
51
|
generateId: true,
|
|
48
|
-
|
|
49
|
-
|
|
52
|
+
/* istanbul ignore next */
|
|
53
|
+
idGenerator: async (req: FastifyRequest) => {
|
|
54
|
+
/* istanbul ignore next */
|
|
55
|
+
return req.headers['X-Request-Id']?.toString() ?? randomUUID();
|
|
56
|
+
},
|
|
50
57
|
},
|
|
51
58
|
}),
|
|
52
59
|
],
|
package/src/conf.type.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { LogLevel } from '@nestjs/common';
|
|
2
|
-
import type { LoggerTypeEnum } from '@
|
|
2
|
+
import type { LoggerTypeEnum } from '@node-yalc/logger/logger.enum';
|
|
3
3
|
export interface IServiceConf {
|
|
4
4
|
appName: string;
|
|
5
5
|
loggerType: LoggerTypeEnum | string;
|
package/src/conf.type.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type ImprovedLoggerService } from '@
|
|
1
|
+
import { type ImprovedLoggerService } from '@node-yalc/logger/logger-abstract.service';
|
|
2
2
|
import { OnModuleInit, OnModuleDestroy } from '@nestjs/common';
|
|
3
3
|
import { type IYalcBaseAppOptions } from './base-app.interface.js';
|
|
4
4
|
import { AppContextService } from './app-context.service.js';
|
|
@@ -1,18 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
-
};
|
|
11
|
-
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
-
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
-
};
|
|
14
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
3
|
exports.LifeCycleHandler = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
16
5
|
const common_1 = require("@nestjs/common");
|
|
17
6
|
const def_const_js_1 = require("./def.const.js");
|
|
18
7
|
const app_context_service_js_1 = require("./app-context.service.js");
|
|
@@ -36,12 +25,12 @@ let LifeCycleHandler = class LifeCycleHandler {
|
|
|
36
25
|
}
|
|
37
26
|
};
|
|
38
27
|
exports.LifeCycleHandler = LifeCycleHandler;
|
|
39
|
-
exports.LifeCycleHandler = LifeCycleHandler = __decorate([
|
|
28
|
+
exports.LifeCycleHandler = LifeCycleHandler = tslib_1.__decorate([
|
|
40
29
|
(0, common_1.Injectable)(),
|
|
41
|
-
__param(0, (0, common_1.Inject)(def_const_js_1.APP_LOGGER_SERVICE)),
|
|
42
|
-
__param(1, (0, common_1.Inject)(def_const_js_1.MODULE_ALIAS_TOKEN)),
|
|
43
|
-
__param(2, (0, common_1.Inject)(app_context_service_js_1.AppContextService)),
|
|
44
|
-
__param(3, (0, common_1.Inject)(def_const_js_1.MODULE_OPTION_TOKEN)),
|
|
45
|
-
__metadata("design:paramtypes", [Object, String, app_context_service_js_1.AppContextService, Object])
|
|
30
|
+
tslib_1.__param(0, (0, common_1.Inject)(def_const_js_1.APP_LOGGER_SERVICE)),
|
|
31
|
+
tslib_1.__param(1, (0, common_1.Inject)(def_const_js_1.MODULE_ALIAS_TOKEN)),
|
|
32
|
+
tslib_1.__param(2, (0, common_1.Inject)(app_context_service_js_1.AppContextService)),
|
|
33
|
+
tslib_1.__param(3, (0, common_1.Inject)(def_const_js_1.MODULE_OPTION_TOKEN)),
|
|
34
|
+
tslib_1.__metadata("design:paramtypes", [Object, String, app_context_service_js_1.AppContextService, Object])
|
|
46
35
|
], LifeCycleHandler);
|
|
47
36
|
//# sourceMappingURL=life-cycle-handler.service.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"life-cycle-handler.service.js","sourceRoot":"","sources":["life-cycle-handler.service.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"life-cycle-handler.service.js","sourceRoot":"","sources":["life-cycle-handler.service.ts"],"names":[],"mappings":";;;;AACA,2CAKwB;AAExB,iDAIwB;AAExB,qEAA6D;AAQtD,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;IAO3B,YAE+C,MAA6B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
+
import { type ImprovedLoggerService } from '@node-yalc/logger/logger-abstract.service';
|
|
2
2
|
import {
|
|
3
3
|
Injectable,
|
|
4
4
|
Inject,
|
|
@@ -11,12 +11,14 @@ import {
|
|
|
11
11
|
MODULE_ALIAS_TOKEN,
|
|
12
12
|
MODULE_OPTION_TOKEN,
|
|
13
13
|
} from './def.const.js';
|
|
14
|
+
/* istanbul ignore file */
|
|
14
15
|
import { AppContextService } from './app-context.service.js';
|
|
15
16
|
|
|
16
17
|
/**
|
|
17
18
|
* This class is used to handle the lifecycle of the app
|
|
18
19
|
* and apply some common logic and checks to all apps
|
|
19
20
|
*/
|
|
21
|
+
/* istanbul ignore next */
|
|
20
22
|
@Injectable()
|
|
21
23
|
export class LifeCycleHandler implements OnModuleDestroy, OnModuleInit {
|
|
22
24
|
/**
|
|
@@ -26,11 +28,17 @@ export class LifeCycleHandler implements OnModuleDestroy, OnModuleInit {
|
|
|
26
28
|
*
|
|
27
29
|
*/
|
|
28
30
|
constructor(
|
|
31
|
+
/* istanbul ignore next */
|
|
29
32
|
@Inject(APP_LOGGER_SERVICE) private readonly logger: ImprovedLoggerService,
|
|
33
|
+
/* istanbul ignore next */
|
|
30
34
|
@Inject(MODULE_ALIAS_TOKEN) private readonly moduleAlias: string,
|
|
35
|
+
/* istanbul ignore next */
|
|
31
36
|
@Inject(AppContextService)
|
|
37
|
+
/* istanbul ignore next */
|
|
32
38
|
private readonly appContextService: AppContextService,
|
|
39
|
+
/* istanbul ignore next */
|
|
33
40
|
@Inject(MODULE_OPTION_TOKEN)
|
|
41
|
+
/* istanbul ignore next */
|
|
34
42
|
private readonly options?: IYalcBaseAppOptions,
|
|
35
43
|
) {
|
|
36
44
|
this.logger.debug?.(
|
|
@@ -1,12 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
3
|
exports.UnwrapResultInterceptor = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
10
5
|
const common_1 = require("@nestjs/common");
|
|
11
6
|
const neverthrow_1 = require("neverthrow");
|
|
12
7
|
const rxjs_1 = require("rxjs");
|
|
@@ -30,7 +25,7 @@ let UnwrapResultInterceptor = class UnwrapResultInterceptor {
|
|
|
30
25
|
}
|
|
31
26
|
};
|
|
32
27
|
exports.UnwrapResultInterceptor = UnwrapResultInterceptor;
|
|
33
|
-
exports.UnwrapResultInterceptor = UnwrapResultInterceptor = __decorate([
|
|
28
|
+
exports.UnwrapResultInterceptor = UnwrapResultInterceptor = tslib_1.__decorate([
|
|
34
29
|
(0, common_1.Injectable)()
|
|
35
30
|
], UnwrapResultInterceptor);
|
|
36
31
|
//# sourceMappingURL=unwrap-result.interceptor.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unwrap-result.interceptor.js","sourceRoot":"","sources":["unwrap-result.interceptor.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"unwrap-result.interceptor.js","sourceRoot":"","sources":["unwrap-result.interceptor.ts"],"names":[],"mappings":";;;;AAAA,2CAKwB;AACxB,2CAAyC;AACzC,+BAAuC;AAGhC,IAAM,uBAAuB,GAA7B,MAAM,uBAAuB;IAClC,SAAS,CAAC,CAAmB,EAAE,IAAiB;QAC9C,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC,IAAI,CACvB,IAAA,UAAG,EAAC,CAAC,MAAM,EAAE,EAAE;YACb,IACE,MAAM,YAAY,wBAAW;gBAC7B,CAAC,CAAC,CAAC,MAAM;oBACP,OAAO,MAAM,KAAK,QAAQ;oBAC1B,OAAO,MAAM,CAAC,IAAI,KAAK,UAAU;oBACjC,OAAO,MAAM,CAAC,KAAK,KAAK,UAAU,CAAC,EACrC,CAAC;gBACD,IAAI,MAAM,CAAC,IAAI,EAAE,EAAE,CAAC;oBAClB,OAAO,MAAM,CAAC,KAAK,CAAC;gBACtB,CAAC;qBAAM,CAAC;oBACN,MAAM,MAAM,CAAC,KAAK,CAAC;gBACrB,CAAC;YACH,CAAC;YACD,OAAO,MAAM,CAAC;QAChB,CAAC,CAAC,CACH,CAAC;IACJ,CAAC;CACF,CAAA;AArBY,0DAAuB;kCAAvB,uBAAuB;IADnC,IAAA,mBAAU,GAAE;GACA,uBAAuB,CAqBnC"}
|