heimdall-api-platform 1.0.4 → 1.0.6

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.
Files changed (95) hide show
  1. package/dist/clients/http-client.js +1 -0
  2. package/dist/commons-cache.js +1 -0
  3. package/dist/commons-const.js +1 -0
  4. package/dist/commons-elasticsearch.js +1 -0
  5. package/dist/commons-errors.js +1 -0
  6. package/dist/commons-opensearch.js +1 -0
  7. package/dist/commons-splunk.js +1 -0
  8. package/dist/commons-util.js +1 -0
  9. package/dist/default-routes-docs.js +1 -0
  10. package/dist/default-routes-pos.js +1 -0
  11. package/dist/default-routes-pre.js +1 -0
  12. package/dist/environment.js +1 -0
  13. package/dist/factory/api-gateway.js +1 -0
  14. package/dist/factory/client-factory.js +1 -0
  15. package/dist/factory/function-factory.js +1 -0
  16. package/dist/factory/operation-flow-factory.js +1 -0
  17. package/dist/factory/server-factory.js +1 -0
  18. package/dist/factory/transformation-function-factory.js +1 -0
  19. package/dist/handle-route.js +1 -0
  20. package/dist/index.js +2 -0
  21. package/dist/jwt-util.js +1 -0
  22. package/dist/license/license-service.js +1 -0
  23. package/dist/models/base-context.js +1 -0
  24. package/dist/models/elastic-index-data.js +1 -0
  25. package/dist/models/flow-context.js +1 -0
  26. package/dist/models/flow-indexed.js +1 -0
  27. package/dist/models/operation-function-indexed.js +1 -0
  28. package/dist/models/operation-function-transformation-indexed.js +1 -0
  29. package/dist/models/operation-http-indexed.js +1 -0
  30. package/dist/models/operation-mock-indexed.js +1 -0
  31. package/dist/models/route-context.js +1 -0
  32. package/dist/models/security-route.js +1 -0
  33. package/dist/models/service-context.js +1 -0
  34. package/dist/models/service-group.js +1 -0
  35. package/dist/models/service-route.js +1 -0
  36. package/dist/models/splunk-data.js +1 -0
  37. package/dist/operations/abstract-operation.js +1 -0
  38. package/dist/operations/function.js +1 -0
  39. package/dist/operations/http.js +1 -0
  40. package/dist/operations/mock.js +1 -0
  41. package/dist/operations/monitor-check.js +1 -0
  42. package/dist/orchestration-flow.js +1 -0
  43. package/dist/router.js +1 -0
  44. package/dist/security-validation.js +1 -0
  45. package/dist/services/server.js +1 -0
  46. package/dist/services/template-monitorcheck-route.js +1 -0
  47. package/package.json +5 -5
  48. package/lib/clients/http-client.js +0 -296
  49. package/lib/commons-cache.js +0 -185
  50. package/lib/commons-const.js +0 -203
  51. package/lib/commons-elasticsearch.js +0 -49
  52. package/lib/commons-errors.js +0 -278
  53. package/lib/commons-opensearch.js +0 -37
  54. package/lib/commons-splunk.js +0 -105
  55. package/lib/commons-util.js +0 -669
  56. package/lib/default-routes-docs.js +0 -141
  57. package/lib/default-routes-pos.js +0 -111
  58. package/lib/default-routes-pre.js +0 -151
  59. package/lib/environment.js +0 -81
  60. package/lib/factory/api-gateway.js +0 -12
  61. package/lib/factory/client-factory.js +0 -41
  62. package/lib/factory/function-factory.js +0 -40
  63. package/lib/factory/operation-flow-factory.js +0 -64
  64. package/lib/factory/server-factory.js +0 -15
  65. package/lib/factory/transformation-function-factory.js +0 -47
  66. package/lib/handle-route.js +0 -472
  67. package/lib/index.js +0 -50
  68. package/lib/jwt-util.js +0 -38
  69. package/lib/license/license-service.js +0 -27
  70. package/lib/models/base-context.js +0 -77
  71. package/lib/models/elastic-index-data.js +0 -76
  72. package/lib/models/flow-context.js +0 -58
  73. package/lib/models/flow-indexed.js +0 -62
  74. package/lib/models/operation-function-indexed.js +0 -22
  75. package/lib/models/operation-function-transformation-indexed.js +0 -23
  76. package/lib/models/operation-http-indexed.js +0 -38
  77. package/lib/models/operation-mock-indexed.js +0 -22
  78. package/lib/models/route-context.js +0 -69
  79. package/lib/models/security-route.js +0 -41
  80. package/lib/models/service-context.js +0 -65
  81. package/lib/models/service-group.js +0 -15
  82. package/lib/models/service-route.js +0 -23
  83. package/lib/models/splunk-data.js +0 -70
  84. package/lib/operations/abstract-operation.js +0 -73
  85. package/lib/operations/function.js +0 -143
  86. package/lib/operations/http.js +0 -286
  87. package/lib/operations/mock.js +0 -34
  88. package/lib/operations/monitor-check.js +0 -151
  89. package/lib/orchestration-flow.js +0 -323
  90. package/lib/public/redoc.html +0 -152
  91. package/lib/public/swagger.html +0 -143
  92. package/lib/router.js +0 -29
  93. package/lib/security-validation.js +0 -46
  94. package/lib/services/server.js +0 -211
  95. package/lib/services/template-monitorcheck-route.js +0 -61
@@ -1,77 +0,0 @@
1
- 'use strict';
2
-
3
- const Const = require('../commons-const');
4
- const { performance } = require('perf_hooks');
5
- const Util = require('../commons-util');
6
- const _ = require('underscore')
7
-
8
- class BaseContext {
9
-
10
- constructor(uuid, context) {
11
- this.uuid = uuid;
12
- this.context = context || {};
13
- this.statusCode = Const.HTTP_STATUS.OK;
14
- //InfoTime
15
- this.timers = {
16
- created: {
17
- at: new Date().toISOString(),
18
- ms: performance.now()
19
- },
20
- started: {
21
- at: Util.defaultDateISOString(),
22
- ms: 0
23
- },
24
- finished: {
25
- at: Util.defaultDateISOString(),
26
- ms: 0
27
- },
28
- duration: 0
29
- };
30
- this.error = false;
31
- this.executed = false;
32
- //Result (Error|Success)
33
- this.inputData = {};
34
- this.responseHeaders = {};
35
- this.result = {};
36
- };
37
-
38
- setContext(context) {
39
- this.context = context;
40
- };
41
-
42
- init() {
43
- this.timers.started.ms = performance.now();
44
- this.timers.started.at = new Date().toISOString();
45
- };
46
-
47
- end() {
48
- this.executed = true;
49
- this.timers.finished.ms = performance.now();
50
- this.timers.finished.at = new Date().toISOString();
51
- this.timers.duration = parseFloat((this.timers.finished.ms - this.timers.started.ms).toFixed(4));
52
- };
53
-
54
- getResult() {
55
- return this.result;
56
- };
57
-
58
- //Return JSON to Client
59
- getResultJSON() {
60
- return Util.stringifyInfo(this.result);
61
- }
62
-
63
- setResult(result) {
64
- this.result = result || {};
65
- };
66
-
67
- addResult(result) {
68
- this.result = _.extend(this.result, result);
69
- };
70
-
71
- hasResult() {
72
- return !(Object.keys(this.result).length === 0 && this.result.constructor === Object);
73
- };
74
-
75
- }
76
-
77
- module.exports = BaseContext;
@@ -1,76 +0,0 @@
1
- 'use strict';
2
-
3
- const Util = require('../commons-util');
4
- const FlowIndexed = require('./flow-indexed');
5
-
6
- class ElasticIndexData {
7
-
8
- constructor(context) {
9
- this.uuid = context.uuid;
10
- this.request = {
11
- url: {
12
- protocol: context.request.secure ? "https:" : "http:",
13
- hostname: context.request.hostname,
14
- port: context.request.connection.localPort,
15
- path: context.request.path,
16
- full: `${context.request.secure ? "https:" : "http:"}//${context.request.hostname}${context.request.path}`
17
- },
18
- socket: {
19
- remoteAddress: context.request.socket.remoteAddress,
20
- encrypted: context.request.secure
21
- },
22
- httpVersion: context.request.httpVersion,
23
- method: context.request.method,
24
- body: Util.stringifyInfo(context.request.body || {}),
25
- query: Util.stringifyInfo(context.query || {}),
26
- params: Util.stringifyInfo(context.params || {}),
27
- headers: context.headers || {}
28
- };
29
- this.service = {
30
- name: context.service.name,
31
- description: context.service.description,
32
- method: context.service.method,
33
- security: context.service.security,
34
- indexedResult: context.service.indexedResult,
35
- authorizationToken: context.security.authorizationToken || {},
36
- responseHeaders: Util.stringifyInfo(context.service.responseHeaders),
37
- totalFlows: context.service.flow.length,
38
- };
39
-
40
- if (context.service.indexedResult == true ||
41
- context.error == true) {
42
- this.service.flows = this.generateFlow(context.service.flow, context.service.indexedResult);
43
- };
44
-
45
- let result = '';
46
-
47
- if (context.service.indexedResult == true ||
48
- context.error == true) {
49
- if (context.hasResult())
50
- result = Util.stringifyInfo(context.result);
51
- };
52
-
53
- this.response = {
54
- statusCode: context.response.statusCode,
55
- headers: Util.stringifyInfo(context.response.getHeaders()),
56
- result: result
57
- };
58
-
59
- this.timers = context.timers;
60
- };
61
-
62
- generateFlow(flows, indexedResult) {
63
-
64
- let objectFlow = {};
65
-
66
- flows.map((flow, index) => {
67
- objectFlow[index + 1] = new FlowIndexed(flow, indexedResult);
68
- });
69
-
70
- return objectFlow;
71
-
72
- }
73
-
74
- };
75
-
76
- module.exports = ElasticIndexData;
@@ -1,58 +0,0 @@
1
- 'use strict';
2
-
3
- const OperationFlowFactory = require('../factory/operation-flow-factory');
4
- const BaseContext = require('./base-context');
5
- const { v4: uuidv4 } = require('uuid');
6
- const Const = require('../commons-const');
7
- class FlowContext extends BaseContext {
8
-
9
- constructor(options, context) {
10
-
11
- super(uuidv4(), context);
12
- this.resultVariable = options.resultVariable || '.';
13
- this.skipErrors = options.skipErrors || false;
14
- this.propagateResult = options.propagateResult || false;
15
- this.cacheEnable = options.cacheEnable || false;
16
- this.condition = this.generateCondition(options);
17
- this.validation = options.validation || "true";
18
- this.cacheTtl = options.cacheTtl || 0;
19
- this.cacheTtlExpression = options.cacheTtlExpression || '';
20
- this.cacheName = options.cacheName || '';
21
- this.cacheKey = options.cacheKey || '';
22
- this.operation = OperationFlowFactory.createOperationByType(options.operation, this);
23
- };
24
-
25
- generateCondition(options) {
26
-
27
- let condition = (options.condition || '');
28
-
29
- if (condition.constructor.name == Const.OBJECT_TYPE.OBJECT) {
30
-
31
- condition.whenFail = condition.whenFail || {};
32
-
33
- return {
34
- compileExpression: options.condition.compileExpression || "true",
35
- whenFail: {
36
- responseHeaders: options.condition.whenFail.responseHeaders || {},
37
- error: options.condition.whenFail.error || false,
38
- result: options.condition.whenFail.result || {},
39
- statusCode: options.condition.whenFail.statusCode || 200
40
- }
41
- };
42
- };
43
-
44
- return {
45
- compileExpression: condition || "true",
46
- whenFail: {
47
- responseHeaders: {},
48
- error: false,
49
- result: {},
50
- statusCode: 200
51
- }
52
- };
53
-
54
- }
55
-
56
- };
57
-
58
- module.exports = FlowContext;
@@ -1,62 +0,0 @@
1
- 'use strict';
2
-
3
- const Util = require('../commons-util');
4
- const Const = require('../commons-const');
5
- const OperationHttpIndexed = require('./operation-http-indexed');
6
- const OperationFunctionIndexed = require('./operation-function-indexed');
7
- const OperationMockIndexed = require('./operation-mock-indexed');
8
-
9
- class FlowIndexed {
10
-
11
- constructor(flow, indexedResult) {
12
- //DADOS GERAIS
13
- this.uuid = flow.uuid;
14
- this.hasError = flow.error;
15
- this.executed = flow.executed;
16
- this.statusCode = flow.statusCode;
17
- //COMPORTAMENTO
18
- this.behavior = {
19
- propagateResultToBody: flow.propagateResult,
20
- skipErrors: flow.skipErrors,
21
- resultVariable: flow.resultVariable,
22
- executeConditions: {
23
- condition: flow.condition,
24
- validation: flow.validation
25
- }
26
- };
27
- //CACHE
28
- this.configCache = {
29
- enable: flow.cacheEnable,
30
- key: flow.cacheKey || '',
31
- name: flow.cacheName || '',
32
- ttl: flow.cacheTtl
33
- };
34
- //OPERACAO DO FLOW
35
- this.generateType(flow.operation, indexedResult);
36
- //RESULTADO
37
- this.result = indexedResult ? Util.stringifyInfo(flow.result) : '';
38
- //TIMERS
39
- this.duration = flow.timers.duration
40
- };
41
-
42
- generateType(operation, indexedResult) {
43
-
44
- switch (operation.type) {
45
- case Const.FLOW_OPERATION_TYPE.HTTP:
46
- this.operationHttp = new OperationHttpIndexed(operation, indexedResult);
47
- break
48
- case Const.FLOW_OPERATION_TYPE.FUNCTION:
49
- this.operationFunction = new OperationFunctionIndexed(operation, indexedResult);
50
- break
51
- case Const.FLOW_OPERATION_TYPE.MOCK:
52
- this.operationMock = new OperationMockIndexed(operation, indexedResult);
53
- break
54
- default:
55
- break;
56
- };
57
-
58
- };
59
-
60
- };
61
-
62
- module.exports = FlowIndexed;
@@ -1,22 +0,0 @@
1
- 'use strict';
2
-
3
- const Util = require('../commons-util');
4
-
5
- class OperationFunctionIndexed {
6
-
7
- constructor(operation, indexedResult) {
8
- //DADOS GERAIS
9
- this.uuid = operation.uuid;
10
- this.name = operation.name;
11
- this.type = operation.type;
12
- this.sourceCode = operation.sourceCode;
13
- this.hasError = operation.error;
14
- this.executed = operation.executed;
15
- this.statusCode = operation.statusCode;
16
- this.result = (indexedResult || operation.error) ? Util.stringifyInfo(operation.result) : '';
17
- this.duration = operation.timers.duration
18
- };
19
-
20
- };
21
-
22
- module.exports = OperationFunctionIndexed;
@@ -1,23 +0,0 @@
1
- 'use strict';
2
-
3
- const Util = require('../commons-util');
4
-
5
- class OperationFunctionTransformationIndexed {
6
-
7
- constructor(operation, indexedResult) {
8
- //DADOS GERAIS
9
- this.uuid = operation.uuid;
10
- this.name = operation.name;
11
- this.type = operation.type;
12
- this.sourceCode = operation.sourceCode;
13
- this.hasError = operation.error;
14
- this.executed = operation.executed;
15
- this.statusCode = operation.statusCode;
16
- this.inputData = indexedResult ? Util.stringifyInfo(operation.inputData) : '';
17
- this.result = (indexedResult || operation.error) ? Util.stringifyInfo(operation.result) : '';
18
- this.duration = operation.timers.duration
19
- };
20
-
21
- };
22
-
23
- module.exports = OperationFunctionTransformationIndexed;
@@ -1,38 +0,0 @@
1
- 'use strict';
2
-
3
- const Util = require('../commons-util');
4
- const Const = require('../commons-const');
5
- const OperationFuncTransIndexed = require('./operation-function-transformation-indexed');
6
-
7
- class OperationHttpIndexed {
8
-
9
- constructor(operation, indexedResult) {
10
- //DADOS GERAIS
11
- this.uuid = operation.uuid;
12
- this.name = operation.name;
13
- this.type = operation.type;
14
- this.method = operation.method;
15
- this.path = operation.path;
16
- this.hasError = operation.error;
17
- this.executed = operation.executed;
18
- this.statusCode = operation.statusCode;
19
- this.headers = operation.headers
20
- this.mergedHeaders = operation.mergedHeaders;
21
- this.httpConfigClient = Util.stringifyInfo(operation.httpClient);
22
-
23
- this.functions = {
24
- headersTransformation: new OperationFuncTransIndexed(operation.headersTransformation, indexedResult),
25
- requestTransformation: new OperationFuncTransIndexed(operation.requestTransformation, indexedResult),
26
- responseTransformation: new OperationFuncTransIndexed(operation.responseTransformation, indexedResult),
27
- onError: new OperationFuncTransIndexed(operation.onError, indexedResult),
28
- onSuccess: new OperationFuncTransIndexed(operation.onSuccess, indexedResult),
29
- };
30
-
31
- this.result = (indexedResult || operation.error) ? Util.stringifyInfo(operation.result) : '';
32
- this.duration = operation.timers.duration
33
-
34
- };
35
-
36
- };
37
-
38
- module.exports = OperationHttpIndexed;
@@ -1,22 +0,0 @@
1
- 'use strict';
2
-
3
- const Util = require('../commons-util');
4
-
5
- class OperationMockIndexed {
6
-
7
- constructor(operation, indexedResult) {
8
- //DADOS GERAIS
9
- this.uuid = operation.uuid;
10
- this.description = operation.description || '';
11
- this.type = operation.type;
12
- this.file = operation.file;
13
- this.hasError = operation.error;
14
- this.executed = operation.executed;
15
- this.statusCode = operation.statusCode;
16
- this.result = (indexedResult || operation.error) ? Util.stringifyInfo(operation.result) : '';
17
- this.duration = operation.timers.duration
18
- };
19
-
20
- };
21
-
22
- module.exports = OperationMockIndexed;
@@ -1,69 +0,0 @@
1
- 'use strict';
2
-
3
- const { v4: uuidv4 } = require('uuid');
4
- const _ = require('underscore');
5
- const SecurityRoute = require('./security-route');
6
- const Const = require('../commons-const');
7
- const BaseContext = require('./base-context');
8
- const ServiceContext = require('./service-context');
9
- const Util = require('../commons-util');
10
-
11
- class RouteContext extends BaseContext {
12
-
13
- //Request e response devem manter a referencia
14
- constructor(request, response, next, serviceOptions, orchestrator) {
15
- super(uuidv4(), {});
16
- this.next = next;
17
- this.orchestrator = orchestrator;
18
- this.service = new ServiceContext(serviceOptions, this);
19
- this.statusCode = this.service.statusCode || Const.HTTP_STATUS.OK;
20
- this.security = new SecurityRoute();
21
- this.request = request;
22
- this.response = response;
23
- this.body = Util.underscore().clone(request.body) || {};
24
- this.query = Util.underscore().clone(request.query) || {};
25
- this.params = _.omit(request.params, Object.keys(request.query)) || {};
26
- this.headers = Util.underscore().clone(request.headers) || {};
27
- this.attemptsIndex = 0;
28
- this.statusCode = Const.HTTP_STATUS.OK
29
- };
30
-
31
- setBody(body) {
32
- this.body = body;
33
- };
34
-
35
- getBody() {
36
- return this.body;
37
- };
38
-
39
- getHeaders() {
40
- this.headers;
41
- };
42
-
43
- setHeaders(headers) {
44
- _.extend(this.headers, headers);
45
- };
46
-
47
- getResponseHeaders() {
48
- this.responseHeaders;
49
- };
50
-
51
- setResponseHeaders(headers) {
52
- _.extend(this.responseHeaders, headers);
53
- };
54
-
55
- setParams(params) {
56
- _.extend(this.params, params);
57
- };
58
-
59
- setQuery(query) {
60
- _.extend(this.query, query);
61
- };
62
-
63
- getQuery() {
64
- return this.query;
65
- };
66
-
67
- }
68
-
69
- module.exports = RouteContext;
@@ -1,41 +0,0 @@
1
- 'use strict';
2
-
3
- class SecurityRoute {
4
- constructor() {
5
- this.encryptionKey = null;
6
- this.publicKey = null;
7
- this.customerUUID = null;
8
- this.devicePublicKeyDisgest = null;
9
- this.accessToken = null;
10
- this.deviceDNA = null;
11
-
12
- }
13
-
14
- setCustomerUUID(customerUUID) {
15
- this.customerUUID = customerUUID;
16
- };
17
-
18
- setEncryptionKey(encryptionKey) {
19
- this.encryptionKey = encryptionKey;
20
- };
21
-
22
- setPublicKey(publicKey) {
23
- this.publicKey = publicKey;
24
- };
25
-
26
- setDevicePublicKeyDisgest(devicePublicKeyDisgest) {
27
- this.devicePublicKeyDisgest = devicePublicKeyDisgest;
28
- };
29
-
30
- setAccessToken(accessToken) {
31
- this.accessToken = accessToken;
32
- };
33
-
34
- setDeviceDNA(deviceDNA) {
35
- this.deviceDNA = deviceDNA;
36
- };
37
-
38
- }
39
-
40
-
41
- module.exports = SecurityRoute;
@@ -1,65 +0,0 @@
1
- 'use strict';
2
-
3
- const FlowContext = require('./flow-context');
4
- const BaseContext = require('./base-context');
5
- const { v4: uuidv4 } = require('uuid');
6
- const _ = require('underscore');
7
-
8
- class ServiceContext extends BaseContext {
9
-
10
- constructor(options, context) {
11
- super(uuidv4(), context);
12
- this.name = options.name || '';
13
- this.description = options.description || '';
14
- this.route = options.route || '';
15
- this.scope = options.scope;
16
- this.method = options.method.toLowerCase() || 'get';
17
- this.security = options.security || false;
18
- this.responseHeaders = options.responseHeaders || {};
19
- this.flow = createFlows(options.flow, this);
20
- this.previousFlow = {};
21
- this.currentFlow = {
22
- getResult: function () { return null }
23
- };
24
- this.indexedResult = options.indexedResult || false;
25
- this.headers = {};
26
- this.responseHeaders = options.responseHeaders || {};
27
- this.rawOptions = options;
28
- this.authScheme = options.authScheme || {};
29
- this.parameters = options.parameters || {};
30
- this.requestBody = options.requestBody || {};
31
- this.responses = options.responses || {};
32
- };
33
-
34
- setCurrentFlow(currentFlow) {
35
- this.previousFlow = this.currentFlow;
36
- this.currentFlow = currentFlow;
37
- }
38
-
39
- getCurrentFlow() {
40
- return this.currentFlow;
41
- };
42
-
43
- getPreviousFlow() {
44
- return this.previousFlow;
45
- };
46
-
47
- getTotalFlow() {
48
- return this.flow.length;
49
- };
50
-
51
- addHeaders(headers) {
52
- this.headers = _.extend(this.headers, headers);
53
- };
54
-
55
- };
56
-
57
- function createFlows(flows, context) {
58
-
59
- return flows.map(flow => {
60
- return new FlowContext(flow, context);
61
- });
62
-
63
- };
64
-
65
- module.exports = ServiceContext;
@@ -1,15 +0,0 @@
1
- 'use strict';
2
-
3
- class ServiceGroup {
4
-
5
- constructor(options) {
6
- this.description = options.description;
7
- this.basePath = options.basePath;
8
- this.validatePath = options.validatePath === undefined ? true : false;
9
- this.services = options.services;
10
- this.version = options.version;
11
- };
12
-
13
- }
14
-
15
- module.exports = ServiceGroup;
@@ -1,23 +0,0 @@
1
- 'use strict';
2
-
3
- class ServiceRoute {
4
-
5
- constructor(options) {
6
- //Validate path windows
7
- this.path = process.platform === "win32" ? options.path.replace(/\\/g, "/") : options.path;
8
- this.security = options.security || false;
9
- this.method = options.method.toLowerCase();
10
- this.enableUploader = options.enableUploader || false;
11
- this.uploadFieldName = options.uploadFieldName || 'file';
12
- }
13
-
14
- getPath() {
15
- return this.path;
16
- };
17
-
18
- getMethod() {
19
- return this.method;
20
- };
21
- }
22
-
23
- module.exports = ServiceRoute;
@@ -1,70 +0,0 @@
1
- 'use strict';
2
-
3
- const Util = require('../commons-util');
4
- const X_AUTHORIZATION = 'x-authorization';
5
-
6
- class SplunkData {
7
-
8
- constructor(context) {
9
- this.uuid = context.uuid;
10
- this.request = {
11
- url: {
12
- protocol: context.request.isSecure() ? "https:" : "http:",
13
- hostname: context.request.headers.host,
14
- port: context.request.connection.localPort,
15
- path: context.request.getPath(),
16
- full: `${context.request.isSecure() ? "https:" : "http:"}//${context.request.headers.host}${context.request.getPath()}`
17
- },
18
- socket: {
19
- remoteAddress: context.request.socket.remoteAddress,
20
- encrypted: context.request.isSecure()
21
- },
22
- httpVersion: context.request.httpVersion,
23
- method: context.request.method,
24
- body: Util.stringifyInfo(context.request.body || {}),
25
- query: Util.stringifyInfo(context.query || {}),
26
- params: Util.stringifyInfo(context.params || {}),
27
- headers: this.hideSensitiveHeaders(context.headers) || {}
28
- };
29
- this.service = {
30
- name: context.service.name,
31
- description: context.service.description,
32
- authorizationToken: context.security.authorizationToken || {}
33
- };
34
-
35
- let result = '';
36
- if (context.error == true) {
37
-
38
- if (context.hasResult()) {
39
- result = Util.stringifyInfo(context.result);
40
- }
41
-
42
- };
43
-
44
- this.response = {
45
- statusCode: context.response.statusCode,
46
- headers: Util.stringifyInfo(context.response.getHeaders()),
47
- result: result
48
- };
49
-
50
- this.timers = context.timers;
51
- };
52
-
53
- hideSensitiveHeaders(headers) {
54
- try {
55
-
56
- if (headers.hasOwnProperty(X_AUTHORIZATION)) {
57
- let splited_authorization = headers[X_AUTHORIZATION].split(" ");
58
- headers[X_AUTHORIZATION] = splited_authorization[0] + " " + Util.replaceCharsForAsterisks(splited_authorization[1]);
59
- }
60
-
61
- } catch (error) {
62
- Util.error(`Error on hode sensitive headers: ${JSON.stringify(error)}`)
63
- }
64
-
65
- return headers;
66
-
67
- }
68
- };
69
-
70
- module.exports = SplunkData;