plac-micro-common 1.0.21 → 1.0.22
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/dist/http/common/exceptions.filter.js +54 -97
- package/dist/http/common/request_context.interceptor.js +37 -76
- package/dist/http/common/response.interceptor.js +33 -77
- package/dist/http/modules/request_context.module.js +19 -63
- package/dist/http/services/request_context.service.js +19 -63
- package/package.json +1 -1
|
@@ -1,107 +1,64 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
var _, done = false;
|
|
8
|
-
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
9
|
-
var context = {};
|
|
10
|
-
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
|
11
|
-
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
|
12
|
-
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
|
13
|
-
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
|
14
|
-
if (kind === "accessor") {
|
|
15
|
-
if (result === void 0) continue;
|
|
16
|
-
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
|
17
|
-
if (_ = accept(result.get)) descriptor.get = _;
|
|
18
|
-
if (_ = accept(result.set)) descriptor.set = _;
|
|
19
|
-
if (_ = accept(result.init)) initializers.unshift(_);
|
|
20
|
-
}
|
|
21
|
-
else if (_ = accept(result)) {
|
|
22
|
-
if (kind === "field") initializers.unshift(_);
|
|
23
|
-
else descriptor[key] = _;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
27
|
-
done = true;
|
|
28
|
-
};
|
|
29
|
-
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
|
30
|
-
var useValue = arguments.length > 2;
|
|
31
|
-
for (var i = 0; i < initializers.length; i++) {
|
|
32
|
-
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
33
|
-
}
|
|
34
|
-
return useValue ? value : void 0;
|
|
35
|
-
};
|
|
36
|
-
var __setFunctionName = (this && this.__setFunctionName) || function (f, name, prefix) {
|
|
37
|
-
if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
|
|
38
|
-
return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
|
|
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;
|
|
39
7
|
};
|
|
8
|
+
var AllExceptionsFilter_1;
|
|
40
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
10
|
exports.AllExceptionsFilter = void 0;
|
|
42
11
|
const common_1 = require("@nestjs/common");
|
|
43
12
|
const utils_1 = require("../../utils");
|
|
44
|
-
let AllExceptionsFilter =
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
if (exception instanceof common_1.HttpException) {
|
|
64
|
-
status = exception.getStatus();
|
|
65
|
-
const response = exception.getResponse();
|
|
66
|
-
if (typeof response === "string") {
|
|
67
|
-
message = response;
|
|
68
|
-
}
|
|
69
|
-
else if (response && typeof response === "object") {
|
|
70
|
-
const r = response;
|
|
71
|
-
message = r.message ?? message;
|
|
72
|
-
code = r.code ?? undefined;
|
|
73
|
-
details = r.details ?? r.errors ?? null;
|
|
74
|
-
}
|
|
13
|
+
let AllExceptionsFilter = AllExceptionsFilter_1 = class AllExceptionsFilter {
|
|
14
|
+
constructor() {
|
|
15
|
+
this.logger = new common_1.Logger(AllExceptionsFilter_1.name);
|
|
16
|
+
}
|
|
17
|
+
catch(exception, host) {
|
|
18
|
+
const ctx = host.switchToHttp();
|
|
19
|
+
const res = ctx.getResponse();
|
|
20
|
+
const req = ctx.getRequest();
|
|
21
|
+
const traceId = (0, utils_1.getOrCreateTraceId)(req);
|
|
22
|
+
res.setHeader(utils_1.TRACE_HEADER, traceId);
|
|
23
|
+
let status = common_1.HttpStatus.INTERNAL_SERVER_ERROR;
|
|
24
|
+
let code = "INTERNAL_SERVER_ERROR";
|
|
25
|
+
let message = "Internal server error";
|
|
26
|
+
let details = null;
|
|
27
|
+
if (exception instanceof common_1.HttpException) {
|
|
28
|
+
status = exception.getStatus();
|
|
29
|
+
const response = exception.getResponse();
|
|
30
|
+
if (typeof response === "string") {
|
|
31
|
+
message = response;
|
|
75
32
|
}
|
|
76
|
-
else if (
|
|
77
|
-
|
|
78
|
-
|
|
33
|
+
else if (response && typeof response === "object") {
|
|
34
|
+
const r = response;
|
|
35
|
+
message = r.message ?? message;
|
|
36
|
+
code = r.code ?? undefined;
|
|
37
|
+
details = r.details ?? r.errors ?? null;
|
|
79
38
|
}
|
|
80
|
-
const body = {
|
|
81
|
-
success: false,
|
|
82
|
-
statusCode: status,
|
|
83
|
-
message,
|
|
84
|
-
error: code || details
|
|
85
|
-
? {
|
|
86
|
-
code,
|
|
87
|
-
message,
|
|
88
|
-
details,
|
|
89
|
-
}
|
|
90
|
-
: undefined,
|
|
91
|
-
trace_id: traceId,
|
|
92
|
-
timestamp: new Date().toISOString(),
|
|
93
|
-
};
|
|
94
|
-
res.status(status).json(body);
|
|
95
39
|
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
40
|
+
else if (exception instanceof Error) {
|
|
41
|
+
message = exception.message || message;
|
|
42
|
+
details = { name: exception.name };
|
|
43
|
+
}
|
|
44
|
+
const body = {
|
|
45
|
+
success: false,
|
|
46
|
+
statusCode: status,
|
|
47
|
+
message,
|
|
48
|
+
error: code || details
|
|
49
|
+
? {
|
|
50
|
+
code,
|
|
51
|
+
message,
|
|
52
|
+
details,
|
|
53
|
+
}
|
|
54
|
+
: undefined,
|
|
55
|
+
trace_id: traceId,
|
|
56
|
+
timestamp: new Date().toISOString(),
|
|
57
|
+
};
|
|
58
|
+
res.status(status).json(body);
|
|
59
|
+
}
|
|
60
|
+
};
|
|
107
61
|
exports.AllExceptionsFilter = AllExceptionsFilter;
|
|
62
|
+
exports.AllExceptionsFilter = AllExceptionsFilter = AllExceptionsFilter_1 = __decorate([
|
|
63
|
+
(0, common_1.Catch)()
|
|
64
|
+
], AllExceptionsFilter);
|
|
@@ -1,83 +1,44 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
var _, done = false;
|
|
8
|
-
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
9
|
-
var context = {};
|
|
10
|
-
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
|
11
|
-
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
|
12
|
-
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
|
13
|
-
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
|
14
|
-
if (kind === "accessor") {
|
|
15
|
-
if (result === void 0) continue;
|
|
16
|
-
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
|
17
|
-
if (_ = accept(result.get)) descriptor.get = _;
|
|
18
|
-
if (_ = accept(result.set)) descriptor.set = _;
|
|
19
|
-
if (_ = accept(result.init)) initializers.unshift(_);
|
|
20
|
-
}
|
|
21
|
-
else if (_ = accept(result)) {
|
|
22
|
-
if (kind === "field") initializers.unshift(_);
|
|
23
|
-
else descriptor[key] = _;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
27
|
-
done = true;
|
|
28
|
-
};
|
|
29
|
-
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
|
30
|
-
var useValue = arguments.length > 2;
|
|
31
|
-
for (var i = 0; i < initializers.length; i++) {
|
|
32
|
-
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
33
|
-
}
|
|
34
|
-
return useValue ? value : void 0;
|
|
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;
|
|
35
7
|
};
|
|
36
|
-
var
|
|
37
|
-
if (typeof
|
|
38
|
-
return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
39
10
|
};
|
|
40
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
12
|
exports.RequestContextInterceptor = void 0;
|
|
42
13
|
const common_1 = require("@nestjs/common");
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
});
|
|
70
|
-
return next.handle();
|
|
71
|
-
}
|
|
72
|
-
};
|
|
73
|
-
__setFunctionName(_classThis, "RequestContextInterceptor");
|
|
74
|
-
(() => {
|
|
75
|
-
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
|
|
76
|
-
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
77
|
-
RequestContextInterceptor = _classThis = _classDescriptor.value;
|
|
78
|
-
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
79
|
-
__runInitializers(_classThis, _classExtraInitializers);
|
|
80
|
-
})();
|
|
81
|
-
return RequestContextInterceptor = _classThis;
|
|
82
|
-
})();
|
|
14
|
+
const services_1 = require("../services");
|
|
15
|
+
let RequestContextInterceptor = class RequestContextInterceptor {
|
|
16
|
+
constructor(rctx) {
|
|
17
|
+
this.rctx = rctx;
|
|
18
|
+
}
|
|
19
|
+
intercept(context, next) {
|
|
20
|
+
const req = context.switchToHttp().getRequest();
|
|
21
|
+
const xff = req.headers["x-forwarded-for"];
|
|
22
|
+
const ipAddress = (Array.isArray(xff) ? xff[0] : xff?.split(",")[0]) ||
|
|
23
|
+
req.socket?.remoteAddress ||
|
|
24
|
+
req.ip;
|
|
25
|
+
const clientContext = {
|
|
26
|
+
ip_address: ipAddress,
|
|
27
|
+
user_agent: req.headers["user-agent"],
|
|
28
|
+
request_id: req.headers["x-request-id"],
|
|
29
|
+
origin: req.headers["origin"],
|
|
30
|
+
referer: req.headers["referer"],
|
|
31
|
+
};
|
|
32
|
+
this.rctx.set({
|
|
33
|
+
app: req.current_app,
|
|
34
|
+
app_client: req.current_app_client,
|
|
35
|
+
client_context: clientContext,
|
|
36
|
+
});
|
|
37
|
+
return next.handle();
|
|
38
|
+
}
|
|
39
|
+
};
|
|
83
40
|
exports.RequestContextInterceptor = RequestContextInterceptor;
|
|
41
|
+
exports.RequestContextInterceptor = RequestContextInterceptor = __decorate([
|
|
42
|
+
(0, common_1.Injectable)(),
|
|
43
|
+
__metadata("design:paramtypes", [services_1.RequestContextService])
|
|
44
|
+
], RequestContextInterceptor);
|
|
@@ -1,85 +1,41 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
var _, done = false;
|
|
8
|
-
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
9
|
-
var context = {};
|
|
10
|
-
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
|
11
|
-
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
|
12
|
-
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
|
13
|
-
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
|
14
|
-
if (kind === "accessor") {
|
|
15
|
-
if (result === void 0) continue;
|
|
16
|
-
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
|
17
|
-
if (_ = accept(result.get)) descriptor.get = _;
|
|
18
|
-
if (_ = accept(result.set)) descriptor.set = _;
|
|
19
|
-
if (_ = accept(result.init)) initializers.unshift(_);
|
|
20
|
-
}
|
|
21
|
-
else if (_ = accept(result)) {
|
|
22
|
-
if (kind === "field") initializers.unshift(_);
|
|
23
|
-
else descriptor[key] = _;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
27
|
-
done = true;
|
|
28
|
-
};
|
|
29
|
-
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
|
30
|
-
var useValue = arguments.length > 2;
|
|
31
|
-
for (var i = 0; i < initializers.length; i++) {
|
|
32
|
-
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
33
|
-
}
|
|
34
|
-
return useValue ? value : void 0;
|
|
35
|
-
};
|
|
36
|
-
var __setFunctionName = (this && this.__setFunctionName) || function (f, name, prefix) {
|
|
37
|
-
if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
|
|
38
|
-
return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
|
|
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;
|
|
39
7
|
};
|
|
40
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
9
|
exports.ResponseTransformInterceptor = void 0;
|
|
42
10
|
const common_1 = require("@nestjs/common");
|
|
43
11
|
const operators_1 = require("rxjs/operators");
|
|
44
12
|
const utils_1 = require("../../utils");
|
|
45
|
-
let ResponseTransformInterceptor =
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
};
|
|
71
|
-
return response;
|
|
72
|
-
}));
|
|
73
|
-
}
|
|
74
|
-
};
|
|
75
|
-
__setFunctionName(_classThis, "ResponseTransformInterceptor");
|
|
76
|
-
(() => {
|
|
77
|
-
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
|
|
78
|
-
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
79
|
-
ResponseTransformInterceptor = _classThis = _classDescriptor.value;
|
|
80
|
-
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
81
|
-
__runInitializers(_classThis, _classExtraInitializers);
|
|
82
|
-
})();
|
|
83
|
-
return ResponseTransformInterceptor = _classThis;
|
|
84
|
-
})();
|
|
13
|
+
let ResponseTransformInterceptor = class ResponseTransformInterceptor {
|
|
14
|
+
intercept(context, next) {
|
|
15
|
+
const httpCtx = context.switchToHttp();
|
|
16
|
+
const req = httpCtx.getRequest();
|
|
17
|
+
const res = httpCtx.getResponse();
|
|
18
|
+
const traceId = (0, utils_1.getOrCreateTraceId)(req);
|
|
19
|
+
res.setHeader(utils_1.TRACE_HEADER, traceId);
|
|
20
|
+
return next.handle().pipe((0, operators_1.map)((data) => {
|
|
21
|
+
if (data && data.success !== undefined) {
|
|
22
|
+
if (!data.trace_id)
|
|
23
|
+
data.trace_id = traceId;
|
|
24
|
+
return data;
|
|
25
|
+
}
|
|
26
|
+
const statusCode = res.statusCode ?? 200;
|
|
27
|
+
const response = {
|
|
28
|
+
success: true,
|
|
29
|
+
statusCode,
|
|
30
|
+
data,
|
|
31
|
+
trace_id: traceId,
|
|
32
|
+
timestamp: new Date().toISOString(),
|
|
33
|
+
};
|
|
34
|
+
return response;
|
|
35
|
+
}));
|
|
36
|
+
}
|
|
37
|
+
};
|
|
85
38
|
exports.ResponseTransformInterceptor = ResponseTransformInterceptor;
|
|
39
|
+
exports.ResponseTransformInterceptor = ResponseTransformInterceptor = __decorate([
|
|
40
|
+
(0, common_1.Injectable)()
|
|
41
|
+
], ResponseTransformInterceptor);
|
|
@@ -1,70 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
var _, done = false;
|
|
8
|
-
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
9
|
-
var context = {};
|
|
10
|
-
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
|
11
|
-
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
|
12
|
-
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
|
13
|
-
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
|
14
|
-
if (kind === "accessor") {
|
|
15
|
-
if (result === void 0) continue;
|
|
16
|
-
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
|
17
|
-
if (_ = accept(result.get)) descriptor.get = _;
|
|
18
|
-
if (_ = accept(result.set)) descriptor.set = _;
|
|
19
|
-
if (_ = accept(result.init)) initializers.unshift(_);
|
|
20
|
-
}
|
|
21
|
-
else if (_ = accept(result)) {
|
|
22
|
-
if (kind === "field") initializers.unshift(_);
|
|
23
|
-
else descriptor[key] = _;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
27
|
-
done = true;
|
|
28
|
-
};
|
|
29
|
-
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
|
30
|
-
var useValue = arguments.length > 2;
|
|
31
|
-
for (var i = 0; i < initializers.length; i++) {
|
|
32
|
-
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
33
|
-
}
|
|
34
|
-
return useValue ? value : void 0;
|
|
35
|
-
};
|
|
36
|
-
var __setFunctionName = (this && this.__setFunctionName) || function (f, name, prefix) {
|
|
37
|
-
if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
|
|
38
|
-
return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
|
|
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;
|
|
39
7
|
};
|
|
40
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
9
|
exports.RequestContextModule = void 0;
|
|
42
10
|
const common_1 = require("@nestjs/common");
|
|
43
11
|
const services_1 = require("../services");
|
|
44
|
-
let RequestContextModule =
|
|
45
|
-
|
|
46
|
-
providers: [
|
|
47
|
-
{
|
|
48
|
-
provide: services_1.RequestContextService,
|
|
49
|
-
useClass: services_1.RequestContextService,
|
|
50
|
-
scope: common_1.Scope.REQUEST,
|
|
51
|
-
},
|
|
52
|
-
],
|
|
53
|
-
exports: [services_1.RequestContextService],
|
|
54
|
-
})];
|
|
55
|
-
let _classDescriptor;
|
|
56
|
-
let _classExtraInitializers = [];
|
|
57
|
-
let _classThis;
|
|
58
|
-
var RequestContextModule = _classThis = class {
|
|
59
|
-
};
|
|
60
|
-
__setFunctionName(_classThis, "RequestContextModule");
|
|
61
|
-
(() => {
|
|
62
|
-
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
|
|
63
|
-
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
64
|
-
RequestContextModule = _classThis = _classDescriptor.value;
|
|
65
|
-
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
66
|
-
__runInitializers(_classThis, _classExtraInitializers);
|
|
67
|
-
})();
|
|
68
|
-
return RequestContextModule = _classThis;
|
|
69
|
-
})();
|
|
12
|
+
let RequestContextModule = class RequestContextModule {
|
|
13
|
+
};
|
|
70
14
|
exports.RequestContextModule = RequestContextModule;
|
|
15
|
+
exports.RequestContextModule = RequestContextModule = __decorate([
|
|
16
|
+
(0, common_1.Module)({
|
|
17
|
+
providers: [
|
|
18
|
+
{
|
|
19
|
+
provide: services_1.RequestContextService,
|
|
20
|
+
useClass: services_1.RequestContextService,
|
|
21
|
+
scope: common_1.Scope.REQUEST,
|
|
22
|
+
},
|
|
23
|
+
],
|
|
24
|
+
exports: [services_1.RequestContextService],
|
|
25
|
+
})
|
|
26
|
+
], RequestContextModule);
|
|
@@ -1,69 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
var _, done = false;
|
|
8
|
-
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
9
|
-
var context = {};
|
|
10
|
-
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
|
11
|
-
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
|
12
|
-
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
|
13
|
-
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
|
14
|
-
if (kind === "accessor") {
|
|
15
|
-
if (result === void 0) continue;
|
|
16
|
-
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
|
17
|
-
if (_ = accept(result.get)) descriptor.get = _;
|
|
18
|
-
if (_ = accept(result.set)) descriptor.set = _;
|
|
19
|
-
if (_ = accept(result.init)) initializers.unshift(_);
|
|
20
|
-
}
|
|
21
|
-
else if (_ = accept(result)) {
|
|
22
|
-
if (kind === "field") initializers.unshift(_);
|
|
23
|
-
else descriptor[key] = _;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
27
|
-
done = true;
|
|
28
|
-
};
|
|
29
|
-
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
|
30
|
-
var useValue = arguments.length > 2;
|
|
31
|
-
for (var i = 0; i < initializers.length; i++) {
|
|
32
|
-
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
33
|
-
}
|
|
34
|
-
return useValue ? value : void 0;
|
|
35
|
-
};
|
|
36
|
-
var __setFunctionName = (this && this.__setFunctionName) || function (f, name, prefix) {
|
|
37
|
-
if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
|
|
38
|
-
return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
|
|
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;
|
|
39
7
|
};
|
|
40
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
9
|
exports.RequestContextService = void 0;
|
|
42
10
|
const common_1 = require("@nestjs/common");
|
|
43
|
-
let RequestContextService =
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
55
|
-
get() {
|
|
56
|
-
return this.data;
|
|
57
|
-
}
|
|
58
|
-
};
|
|
59
|
-
__setFunctionName(_classThis, "RequestContextService");
|
|
60
|
-
(() => {
|
|
61
|
-
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
|
|
62
|
-
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
63
|
-
RequestContextService = _classThis = _classDescriptor.value;
|
|
64
|
-
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
65
|
-
__runInitializers(_classThis, _classExtraInitializers);
|
|
66
|
-
})();
|
|
67
|
-
return RequestContextService = _classThis;
|
|
68
|
-
})();
|
|
11
|
+
let RequestContextService = class RequestContextService {
|
|
12
|
+
constructor() {
|
|
13
|
+
this.data = {};
|
|
14
|
+
}
|
|
15
|
+
set(partial) {
|
|
16
|
+
this.data = { ...this.data, ...partial };
|
|
17
|
+
}
|
|
18
|
+
get() {
|
|
19
|
+
return this.data;
|
|
20
|
+
}
|
|
21
|
+
};
|
|
69
22
|
exports.RequestContextService = RequestContextService;
|
|
23
|
+
exports.RequestContextService = RequestContextService = __decorate([
|
|
24
|
+
(0, common_1.Injectable)({ scope: common_1.Scope.REQUEST })
|
|
25
|
+
], RequestContextService);
|