skyeye-svc-common-utils 1.0.61 → 1.0.63
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/index.d.ts +1 -1
- package/dist/index.js +1 -6
- package/dist/index.js.map +1 -1
- package/dist/interfaces/index.d.ts +2 -0
- package/dist/interfaces/index.js +16 -0
- package/dist/interfaces/index.js.map +1 -1
- package/dist/interfaces/internalHttp/request/index.d.ts +1 -0
- package/dist/interfaces/internalHttp/request/index.js +18 -0
- package/dist/interfaces/internalHttp/request/index.js.map +1 -0
- package/dist/interfaces/internalHttp/request/search.d.ts +9 -0
- package/dist/interfaces/internalHttp/request/search.js +3 -0
- package/dist/interfaces/internalHttp/request/search.js.map +1 -0
- package/dist/interfaces/internalHttp/response/index.d.ts +1 -0
- package/dist/interfaces/internalHttp/response/index.js +18 -0
- package/dist/interfaces/internalHttp/response/index.js.map +1 -0
- package/dist/interfaces/internalHttp/response/search.d.ts +10 -0
- package/dist/interfaces/internalHttp/response/search.js +3 -0
- package/dist/interfaces/internalHttp/response/search.js.map +1 -0
- package/dist/lib/httpClient.d.ts +1 -0
- package/dist/lib/httpClient.js +18 -14
- package/dist/lib/httpClient.js.map +1 -1
- package/dist/models/search/grpcCompanyListReq.d.ts +10 -0
- package/dist/models/search/grpcCompanyListReq.js +10 -0
- package/dist/models/search/grpcCompanyListReq.js.map +1 -1
- package/dist/utils/authentication/auth.js +6 -8
- package/dist/utils/authentication/auth.js.map +1 -1
- package/dist/utils/commonUtils/appUtils.d.ts +28 -0
- package/dist/utils/commonUtils/appUtils.js +60 -1
- package/dist/utils/commonUtils/appUtils.js.map +1 -1
- package/dist/utils/commonUtils/responseUtils.js +3 -3
- package/dist/utils/commonUtils/responseUtils.js.map +1 -1
- package/dist/utils/documentation/swagger.js +8 -1
- package/dist/utils/documentation/swagger.js.map +1 -1
- package/dist/utils/logger/logger.js +45 -16
- package/dist/utils/logger/logger.js.map +1 -1
- package/dist/utils/logger/morganLogger.d.ts +2 -2
- package/dist/utils/logger/morganLogger.js +15 -1
- package/dist/utils/logger/morganLogger.js.map +1 -1
- package/package.json +1 -2
- package/src/lib/httpClient.ts +27 -26
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ export * from './utils/appConst';
|
|
|
3
3
|
export * from './utils/commonUtils';
|
|
4
4
|
export * from './utils/authentication/auth';
|
|
5
5
|
export * from './utils/logger/logger';
|
|
6
|
-
export
|
|
6
|
+
export * from './utils/logger/morganLogger';
|
|
7
7
|
export * from './utils/middleware/handleError';
|
|
8
8
|
export * from './utils/middleware/isPublicUser';
|
|
9
9
|
export * from './utils/middleware/overwriteConst';
|
package/dist/index.js
CHANGED
|
@@ -13,18 +13,13 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
|
13
13
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
17
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
|
-
};
|
|
19
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
-
exports.morganLogger = void 0;
|
|
21
17
|
__exportStar(require("./utils/appConfig"), exports);
|
|
22
18
|
__exportStar(require("./utils/appConst"), exports);
|
|
23
19
|
__exportStar(require("./utils/commonUtils"), exports);
|
|
24
20
|
__exportStar(require("./utils/authentication/auth"), exports);
|
|
25
21
|
__exportStar(require("./utils/logger/logger"), exports);
|
|
26
|
-
|
|
27
|
-
Object.defineProperty(exports, "morganLogger", { enumerable: true, get: function () { return __importDefault(morganLogger_1).default; } });
|
|
22
|
+
__exportStar(require("./utils/logger/morganLogger"), exports);
|
|
28
23
|
__exportStar(require("./utils/middleware/handleError"), exports);
|
|
29
24
|
__exportStar(require("./utils/middleware/isPublicUser"), exports);
|
|
30
25
|
__exportStar(require("./utils/middleware/overwriteConst"), exports);
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,oDAAkC;AAClC,mDAAiC;AACjC,sDAAoC;AACpC,8DAA4C;AAC5C,wDAAsC;AACtC,8DAA4C;AAC5C,iEAA+C;AAC/C,kEAAgD;AAChD,oEAAkD;AAClD,uEAAqD;AACrD,mEAAiD;AACjD,gEAA8C;AAC9C,qDAAmC;AACnC,4DAA0C;AAC1C,oEAAkD;AAClD,gEAA8C;AAC9C,mEAAiD;AACjD,gEAA8C;AAC9C,+DAA6C;AAC7C,gEAA8C;AAC9C,mDAAiC;AACjC,yDAAuC;AACvC,mEAAiD;AACjD,2CAAyB;AACzB,oDAAkC;AAClC,uDAAqC;AACrC,mEAAiD;AACjD,+DAA6C;AAC7C,4EAA0D"}
|
|
@@ -6,3 +6,5 @@ import { SubcriptionFeaturePermissionModel } from './subcriptionFeaturePermissio
|
|
|
6
6
|
import { GrpcListRequest } from './grpcListRequest';
|
|
7
7
|
import { GrpcServiceResponse } from './grpcServiceResponse';
|
|
8
8
|
export { ApiResponse, ServiceResponse, UserInfo, Pagination, SubcriptionFeaturePermissionModel, GrpcListRequest, GrpcServiceResponse };
|
|
9
|
+
export * from './internalHttp/request';
|
|
10
|
+
export * from './internalHttp/response';
|
package/dist/interfaces/index.js
CHANGED
|
@@ -1,4 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
2
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
17
|
exports.SubcriptionFeaturePermissionModel = exports.Pagination = exports.UserInfo = void 0;
|
|
4
18
|
const userInfo_1 = require("./userInfo");
|
|
@@ -7,4 +21,6 @@ const pagination_1 = require("./pagination");
|
|
|
7
21
|
Object.defineProperty(exports, "Pagination", { enumerable: true, get: function () { return pagination_1.Pagination; } });
|
|
8
22
|
const subcriptionFeaturePermissionModel_1 = require("./subcriptionFeaturePermissionModel");
|
|
9
23
|
Object.defineProperty(exports, "SubcriptionFeaturePermissionModel", { enumerable: true, get: function () { return subcriptionFeaturePermissionModel_1.SubcriptionFeaturePermissionModel; } });
|
|
24
|
+
__exportStar(require("./internalHttp/request"), exports);
|
|
25
|
+
__exportStar(require("./internalHttp/response"), exports);
|
|
10
26
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/interfaces/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/interfaces/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAEA,yCAAsC;AAQlC,yFARK,mBAAQ,OAQL;AAPZ,6CAA0C;AAQtC,2FARK,uBAAU,OAQL;AAPd,2FAAwF;AAQpF,kHARK,qEAAiC,OAQL;AAIrC,yDAAuC;AACvC,0DAAwC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './search';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./search"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/interfaces/internalHttp/request/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAyB"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { GrpcContentListReq } from "../../../models";
|
|
2
|
+
export interface IContentAggregateByMentionedCompanyWithFiltersFilter {
|
|
3
|
+
identifier: string;
|
|
4
|
+
filter: Partial<GrpcContentListReq>;
|
|
5
|
+
}
|
|
6
|
+
export interface IContentAggregateByMentionedCompanyWithFiltersRequest {
|
|
7
|
+
isOverallMentionCountRequired: boolean;
|
|
8
|
+
filters: Array<IContentAggregateByMentionedCompanyWithFiltersFilter>;
|
|
9
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search.js","sourceRoot":"","sources":["../../../../src/interfaces/internalHttp/request/search.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './search';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./search"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/interfaces/internalHttp/response/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAyB"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export interface IMentionedCompany {
|
|
2
|
+
companyGuid: string;
|
|
3
|
+
companyName: string;
|
|
4
|
+
mentionCount: number;
|
|
5
|
+
}
|
|
6
|
+
export interface IContentAggregateByMentionedCompanyWithFiltersResponseItem {
|
|
7
|
+
identifier: string;
|
|
8
|
+
totalMentionedCompany: number;
|
|
9
|
+
mentionedCompanies: IMentionedCompany[];
|
|
10
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search.js","sourceRoot":"","sources":["../../../../src/interfaces/internalHttp/response/search.ts"],"names":[],"mappings":""}
|
package/dist/lib/httpClient.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Response } from 'node-fetch';
|
|
1
2
|
import { UserInfo } from '../interfaces';
|
|
2
3
|
export declare function httpRequest(method: string, url: string, data?: any, headers?: any): Promise<Response>;
|
|
3
4
|
export declare function sendInternalHttpRequest(userInfo: UserInfo, client: string, endpoint: string, data?: any, method?: string, select?: string[]): Promise<any>;
|
package/dist/lib/httpClient.js
CHANGED
|
@@ -8,26 +8,24 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
11
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
15
|
exports.sendInternalHttpRequest = exports.httpRequest = void 0;
|
|
16
|
+
const node_fetch_1 = __importDefault(require("node-fetch"));
|
|
13
17
|
const commonUtils_1 = require("../utils/commonUtils");
|
|
14
18
|
const commonUtils_2 = require("../utils/commonUtils");
|
|
15
19
|
const appConst_1 = require("../utils/appConst");
|
|
16
|
-
const
|
|
20
|
+
const logger_1 = require("../utils/logger/logger");
|
|
17
21
|
function httpRequest(method, url, data = null, headers = (0, appConst_1.jsonContentTypeHeaders)()) {
|
|
18
22
|
return __awaiter(this, void 0, void 0, function* () {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
headers: headers
|
|
24
|
-
} : {
|
|
25
|
-
method: method,
|
|
26
|
-
cache: "no-cache",
|
|
27
|
-
headers: headers,
|
|
28
|
-
body: JSON.stringify(data)
|
|
23
|
+
const init = {
|
|
24
|
+
method,
|
|
25
|
+
headers,
|
|
26
|
+
body: data === null ? undefined : JSON.stringify(data)
|
|
29
27
|
};
|
|
30
|
-
return
|
|
28
|
+
return (0, node_fetch_1.default)(url, init);
|
|
31
29
|
});
|
|
32
30
|
}
|
|
33
31
|
exports.httpRequest = httpRequest;
|
|
@@ -42,9 +40,15 @@ function sendInternalHttpRequest(userInfo, client, endpoint, data = null, method
|
|
|
42
40
|
let token = `${appConst_1.commonAppConst.httpHeader.BEARER} ${yield (0, commonUtils_2.generateJWT)(userInfo)}`;
|
|
43
41
|
headers[appConst_1.commonAppConst.httpHeader.AUTHORIZATION] = token;
|
|
44
42
|
}
|
|
45
|
-
|
|
43
|
+
let response;
|
|
44
|
+
try {
|
|
45
|
+
response = yield httpRequest(method, url, data, headers);
|
|
46
46
|
return response.json();
|
|
47
|
-
}
|
|
47
|
+
}
|
|
48
|
+
catch (err) {
|
|
49
|
+
logger_1.logger.error(`Error while sending internal http request, receiving response: ${response}`);
|
|
50
|
+
throw new Error(`${err}`);
|
|
51
|
+
}
|
|
48
52
|
});
|
|
49
53
|
}
|
|
50
54
|
exports.sendInternalHttpRequest = sendInternalHttpRequest;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"httpClient.js","sourceRoot":"","sources":["../../src/lib/httpClient.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"httpClient.js","sourceRoot":"","sources":["../../src/lib/httpClient.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,4DAA0D;AAE1D,sDAA6E;AAC7E,sDAAmD;AACnD,gDAA0E;AAC1E,mDAAgD;AAEhD,SAAsB,WAAW,CAAC,MAAc,EAAE,GAAY,EAAG,OAAY,IAAI,EAAE,UAAgB,IAAA,iCAAsB,GAAE;;QACvH,MAAM,IAAI,GAAgB;YACtB,MAAM;YACN,OAAO;YACP,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,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axFrom: number;
|
|
23
23
|
pLBeforeTaxTo: number;
|
|
24
24
|
isPrimary: boolean;
|
|
25
|
+
enableUniverse: boolean;
|
|
26
|
+
source: string[];
|
|
27
|
+
searchFields: string[];
|
|
28
|
+
secondarySearchFields: string[];
|
|
29
|
+
scoringProfile: string;
|
|
30
|
+
highlightFields: string;
|
|
31
|
+
highlightPreTag: string;
|
|
32
|
+
highlightPostTag: string;
|
|
33
|
+
relationship: string;
|
|
34
|
+
relationshipCountries: string[];
|
|
25
35
|
constructor();
|
|
26
36
|
}
|
|
@@ -26,6 +26,16 @@ class GrpcCompanyListReq {
|
|
|
26
26
|
this.pLBeforeTaxFrom = null;
|
|
27
27
|
this.pLBeforeTaxTo = null;
|
|
28
28
|
this.isPrimary = null;
|
|
29
|
+
this.enableUniverse = null;
|
|
30
|
+
this.source = null;
|
|
31
|
+
this.searchFields = null;
|
|
32
|
+
this.secondarySearchFields = null;
|
|
33
|
+
this.scoringProfile = null;
|
|
34
|
+
this.highlightFields = null;
|
|
35
|
+
this.highlightPreTag = null;
|
|
36
|
+
this.highlightPostTag = null;
|
|
37
|
+
this.relationship = null;
|
|
38
|
+
this.relationshipCountries = null;
|
|
29
39
|
}
|
|
30
40
|
}
|
|
31
41
|
exports.GrpcCompanyListReq = GrpcCompanyListReq;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grpcCompanyListReq.js","sourceRoot":"","sources":["../../../src/models/search/grpcCompanyListReq.ts"],"names":[],"mappings":";;;AAAA,MAAa,kBAAkB;
|
|
1
|
+
{"version":3,"file":"grpcCompanyListReq.js","sourceRoot":"","sources":["../../../src/models/search/grpcCompanyListReq.ts"],"names":[],"mappings":";;;AAAA,MAAa,kBAAkB;IAmC3B;QACI,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;QACnB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,OAAO,GAAG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QACzB,IAAI,CAAC,qBAAqB,GAAG,IAAI,CAAC;IACtC,CAAC;CACJ;AAtED,gDAsEC"}
|
|
@@ -17,15 +17,15 @@ const appConfig_1 = require("../appConfig");
|
|
|
17
17
|
const appConst_1 = require("../appConst");
|
|
18
18
|
const interfaces_1 = require("../../interfaces");
|
|
19
19
|
const jwtUtils_1 = require("../commonUtils/jwtUtils");
|
|
20
|
-
|
|
20
|
+
// import { apmStartTransaction, apmEndTransaction, apmSetUserContext } from '../monitoring/apm';
|
|
21
21
|
const appUtils_1 = require("../commonUtils/appUtils");
|
|
22
22
|
const appConfigKeyRetriever_1 = require("../commonUtils/appConfigKeyRetriever");
|
|
23
23
|
function auth(req, res, next) {
|
|
24
24
|
var _a, _b, _c;
|
|
25
25
|
return __awaiter(this, void 0, void 0, function* () {
|
|
26
|
-
if (req.url !== '/') {
|
|
27
|
-
|
|
28
|
-
}
|
|
26
|
+
// if (req.url !== '/') {
|
|
27
|
+
// await apmStartTransaction(req, res);
|
|
28
|
+
// }
|
|
29
29
|
if (req.url.indexOf('?') !== -1) {
|
|
30
30
|
req.url = req.url.split('?')[0];
|
|
31
31
|
}
|
|
@@ -137,7 +137,7 @@ function auth(req, res, next) {
|
|
|
137
137
|
userInfo.exp = Math.floor(Date.now() / 1000 + 3600);
|
|
138
138
|
userInfo.internalUsage = true;
|
|
139
139
|
res.locals.userInfo = userInfo;
|
|
140
|
-
|
|
140
|
+
// await apmSetUserContext(userInfo);
|
|
141
141
|
}
|
|
142
142
|
}
|
|
143
143
|
}
|
|
@@ -149,9 +149,7 @@ function auth(req, res, next) {
|
|
|
149
149
|
return next();
|
|
150
150
|
}
|
|
151
151
|
else {
|
|
152
|
-
if (req.url !== '/') {
|
|
153
|
-
yield (0, apm_1.apmEndTransaction)(res);
|
|
154
|
-
}
|
|
152
|
+
// if (req.url !== '/') { await apmEndTransaction(res); }
|
|
155
153
|
if (errorMessage) {
|
|
156
154
|
return res.status(statusCode).send(errorMessage);
|
|
157
155
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../../src/utils/authentication/auth.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,iCAA+B;AAC/B,6CAA0C;AAC1C,6DAA6E;AAC7E,4CAA+C;AAC/C,0CAA6C;AAC7C,iDAA+E;AAC/E,sDAAoD;AACpD,
|
|
1
|
+
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../../src/utils/authentication/auth.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,iCAA+B;AAC/B,6CAA0C;AAC1C,6DAA6E;AAC7E,4CAA+C;AAC/C,0CAA6C;AAC7C,iDAA+E;AAC/E,sDAAoD;AACpD,iGAAiG;AACjG,sDAA0D;AAC1D,gFAA6E;AAE7E,SAAsB,IAAI,CAAC,GAAY,EAAE,GAAa,EAAE,IAAkB;;;QAEtE,yBAAyB;QACzB,2CAA2C;QAC3C,KAAK;QACL,IAAI,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE;YAC7B,GAAG,CAAC,GAAG,GAAG,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;SACnC;QAED,IAAI,UAAU,GAAG,GAAG,CAAC;QACrB,IAAI,YAAY,GAAG,IAAI,CAAC;QAExB,MAAM,GAAG,GAAG,GAAG,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC;QAClC,IAAI,kBAAkB,GAAG,IAAA,uCAAiB,EAAC,2BAAe,CAAC,OAAO,CAAC;aAC9D,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,aAAa,CAAC,WAAW,EAAE,KAAK,GAAG,IAAI,CAAC,CAAC,gBAAgB,KAAK,GAAG,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,CAAC;QACzG,IAAI,kBAAkB,EAAE;YACpB,IAAI,CAAC,kBAAkB,CAAC,cAAc,EAAE;gBAC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C,qCAAqC,GAAG,EAAE,CAAC,CAAC;4BACzD,UAAU,GAAG,GAAG,CAAC;yBACpB;qBACJ;oBACD,QAAQ,CAAC,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,GAAG,IAAI,CAAC,CAAC;oBACpD,QAAQ,CAAC,aAAa,GAAG,IAAI,CAAC;oBAC9B,GAAG,CAAC,MAAM,CAAC,QAAQ,GAAG,QAAQ,CAAC;oBAC/B,qCAAqC;iBACxC;aACJ;SACJ;aAAM;YACH,eAAM,CAAC,KAAK,CAAC,eAAe,GAAG,YAAY,CAAC,CAAC;YAC7C,UAAU,GAAG,GAAG,CAAC;SACpB;QAED,IAAI,UAAU,KAAK,GAAG,EAAE;YACpB,OAAO,IAAI,EAAE,CAAC;SACjB;aAAM;YACH,yDAAyD;YACzD,IAAI,YAAY,EAAE;gBACd,OAAO,GAAG,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;aACpD;iBAAM;gBACH,OAAO,GAAG,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;aACrC;SACJ;;CACJ;AAjID,oBAiIC"}
|
|
@@ -11,3 +11,31 @@ export declare function userInfoToFeatureListByName(userInfo: UserInfo, featureN
|
|
|
11
11
|
export declare function userInfoSimplifier(userInfo: UserInfo, select?: string[]): Promise<any>;
|
|
12
12
|
export declare function userInfoFetcher(mode: string, userInfo?: UserInfo, authorizationHeader?: string, subKey?: string, userGuid?: string): Promise<UserInfo>;
|
|
13
13
|
export declare function getInternalClient(client: string): Promise<string>;
|
|
14
|
+
/**
|
|
15
|
+
* The function `getValidUserSubscriptionFeature` takes in a list of user subscription features,
|
|
16
|
+
* optional feature names, and a boolean flag indicating whether to include postfixes, and
|
|
17
|
+
* returns a list of valid features based on the user subscription.
|
|
18
|
+
* @param {string[]} userSubscriptionFeatures - An array of strings representing the features that the
|
|
19
|
+
* user has subscribed to.
|
|
20
|
+
* @param {string[]} [targetFeatureNames] - An optional array of feature list names. If provided, only
|
|
21
|
+
* the features from these feature lists will be considered. If not provided, all features will be
|
|
22
|
+
* considered.
|
|
23
|
+
* @param {boolean} [isPostfixNeeded=false] - A boolean flag indicating whether or not to include the
|
|
24
|
+
* postfix "|" in the returned valid features. If set to true, the valid features will include the
|
|
25
|
+
* postfix. If set to false, the valid features will not include the postfix.
|
|
26
|
+
* @returns an array of valid features from the user's subscription.
|
|
27
|
+
*/
|
|
28
|
+
export declare function getValidUserSubscriptionFeature(userSubscriptionFeatures: string[], targetFeatureNames?: string[], isPostfixNeeded?: boolean): string[];
|
|
29
|
+
/**
|
|
30
|
+
* The function `getValidFeaturesFromInputFeatures` returns a list of valid features based on the
|
|
31
|
+
* intersection of userFeatures and inputFeatures, with an option to return all userFeatures if no
|
|
32
|
+
* intersection is found and isdefaultAll is true.
|
|
33
|
+
* @param {string[]} userFeatures - An array of features that the user has.
|
|
34
|
+
* @param {string[]} inputFeatures - An array of features that are requested.
|
|
35
|
+
* @param {boolean} [isdefaultAll=true] - A boolean flag indicating whether all user features should be
|
|
36
|
+
* returned if there are no valid features found in the intersection of userFeatures and inputFeatures.
|
|
37
|
+
* If isdefaultAll is set to true and there are no valid features found, the function will return all
|
|
38
|
+
* userFeatures. If isdefaultAll is set to false
|
|
39
|
+
* @returns an array of valid features.
|
|
40
|
+
*/
|
|
41
|
+
export declare function getValidFeaturesFromInputFeatures(userFeatures: string[], inputFeatures: string[], isdefaultAll?: boolean): string[];
|
|
@@ -9,7 +9,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.getInternalClient = exports.userInfoFetcher = exports.userInfoSimplifier = exports.userInfoToFeatureListByName = exports.getUnlockedCode = exports.getLockedCode = exports.buildPaginationModel = exports.mappingToServiceResponse = exports.mappingToStringList = exports.mappingToModelList = exports.mappingToModel = void 0;
|
|
12
|
+
exports.getValidFeaturesFromInputFeatures = exports.getValidUserSubscriptionFeature = exports.getInternalClient = exports.userInfoFetcher = exports.userInfoSimplifier = exports.userInfoToFeatureListByName = exports.getUnlockedCode = exports.getLockedCode = exports.buildPaginationModel = exports.mappingToServiceResponse = exports.mappingToStringList = exports.mappingToModelList = exports.mappingToModel = void 0;
|
|
13
|
+
const lodash_1 = require("lodash");
|
|
13
14
|
const logger_1 = require("../logger/logger");
|
|
14
15
|
const interfaces_1 = require("../../interfaces");
|
|
15
16
|
const appConst_1 = require("../../utils/appConst");
|
|
@@ -174,4 +175,62 @@ function getInternalClient(client) {
|
|
|
174
175
|
});
|
|
175
176
|
}
|
|
176
177
|
exports.getInternalClient = getInternalClient;
|
|
178
|
+
/**
|
|
179
|
+
* The function `getValidUserSubscriptionFeature` takes in a list of user subscription features,
|
|
180
|
+
* optional feature names, and a boolean flag indicating whether to include postfixes, and
|
|
181
|
+
* returns a list of valid features based on the user subscription.
|
|
182
|
+
* @param {string[]} userSubscriptionFeatures - An array of strings representing the features that the
|
|
183
|
+
* user has subscribed to.
|
|
184
|
+
* @param {string[]} [targetFeatureNames] - An optional array of feature list names. If provided, only
|
|
185
|
+
* the features from these feature lists will be considered. If not provided, all features will be
|
|
186
|
+
* considered.
|
|
187
|
+
* @param {boolean} [isPostfixNeeded=false] - A boolean flag indicating whether or not to include the
|
|
188
|
+
* postfix "|" in the returned valid features. If set to true, the valid features will include the
|
|
189
|
+
* postfix. If set to false, the valid features will not include the postfix.
|
|
190
|
+
* @returns an array of valid features from the user's subscription.
|
|
191
|
+
*/
|
|
192
|
+
function getValidUserSubscriptionFeature(userSubscriptionFeatures, targetFeatureNames, isPostfixNeeded = false) {
|
|
193
|
+
if (userSubscriptionFeatures.length === 0)
|
|
194
|
+
return [];
|
|
195
|
+
// Get list of feature list with feature list name(s) if provided, else include all feature list
|
|
196
|
+
const availableFeatureList = targetFeatureNames ? skyeye_common_const_1.allApplicationFeatures.filter(o => targetFeatureNames.includes(o.featureName)) : skyeye_common_const_1.allApplicationFeatures;
|
|
197
|
+
// Flatten list of feature list to get featureCode only, and push to a set for easy read
|
|
198
|
+
const availableFeatures = new Set((0, lodash_1.flatten)(availableFeatureList.map(o => o.features)).map(o => o.featureCode));
|
|
199
|
+
// User feature is valid only if it can be found in the available features
|
|
200
|
+
const userValidFeatures = [];
|
|
201
|
+
for (const userFeature of userSubscriptionFeatures) {
|
|
202
|
+
const [featureCode, postfix] = userFeature.split("|");
|
|
203
|
+
/**
|
|
204
|
+
* for feature with locked postfix e.g. "AntaraNews|LOCKED",
|
|
205
|
+
* take both feature code and postfix for comparison;
|
|
206
|
+
*
|
|
207
|
+
* for features without postfix e.g. "AntaraNews"
|
|
208
|
+
* OR, feature with number postfix e.g. "RADAR_COUNT|3",
|
|
209
|
+
* only take feature code for comparison
|
|
210
|
+
*/
|
|
211
|
+
let isValid = skyeye_common_const_1.commonAppConst.lockedFeature.endsWith(postfix) ? availableFeatures.has(userFeature) : availableFeatures.has(featureCode);
|
|
212
|
+
if (isValid)
|
|
213
|
+
userValidFeatures.push(isPostfixNeeded ? userFeature : featureCode);
|
|
214
|
+
}
|
|
215
|
+
return userValidFeatures;
|
|
216
|
+
}
|
|
217
|
+
exports.getValidUserSubscriptionFeature = getValidUserSubscriptionFeature;
|
|
218
|
+
/**
|
|
219
|
+
* The function `getValidFeaturesFromInputFeatures` returns a list of valid features based on the
|
|
220
|
+
* intersection of userFeatures and inputFeatures, with an option to return all userFeatures if no
|
|
221
|
+
* intersection is found and isdefaultAll is true.
|
|
222
|
+
* @param {string[]} userFeatures - An array of features that the user has.
|
|
223
|
+
* @param {string[]} inputFeatures - An array of features that are requested.
|
|
224
|
+
* @param {boolean} [isdefaultAll=true] - A boolean flag indicating whether all user features should be
|
|
225
|
+
* returned if there are no valid features found in the intersection of userFeatures and inputFeatures.
|
|
226
|
+
* If isdefaultAll is set to true and there are no valid features found, the function will return all
|
|
227
|
+
* userFeatures. If isdefaultAll is set to false
|
|
228
|
+
* @returns an array of valid features.
|
|
229
|
+
*/
|
|
230
|
+
function getValidFeaturesFromInputFeatures(userFeatures, inputFeatures, isdefaultAll = true) {
|
|
231
|
+
// Get the intersection of userFeature and inputFeatures
|
|
232
|
+
const targetFeatures = inputFeatures.filter(o => userFeatures.includes(o));
|
|
233
|
+
return (targetFeatures.length == 0) && isdefaultAll ? userFeatures : targetFeatures;
|
|
234
|
+
}
|
|
235
|
+
exports.getValidFeaturesFromInputFeatures = getValidFeaturesFromInputFeatures;
|
|
177
236
|
//# sourceMappingURL=appUtils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"appUtils.js","sourceRoot":"","sources":["../../../src/utils/commonUtils/appUtils.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6CAA0C;AAC1C,iDAAyE;AACzE,mDAAsD;AACtD,6DAA+I;AAC/I,4CAA+C;AAC/C,qDAAmD;AACnD,iEAAuD;AAEvD,SAAsB,cAAc,CAAC,KAAU,EAAE,MAAW;;QACxD,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,EAAE;YACvC,KAAK,IAAI,GAAG,IAAI,MAAM,EAAE;gBACpB,IAAI,KAAK,CAAC,cAAc,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,IAAI,IAAI,KAAK,CAAC,GAAG,CAAC,KAAK,SAAS,CAAC,EAAE;oBAChF,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC;iBAC5B;aACJ;SACJ;QACD,OAAO,MAAM,CAAC;IAClB,CAAC;CAAA;AATD,wCASC;AAED,SAAsB,kBAAkB,CAAI,MAAa,EAAE,IAAiB;;QACxE,IAAI,OAAO,GAAa,IAAI,KAAK,EAAK,CAAC;QACvC,IAAI,MAAM,KAAK,SAAS,IAAI,MAAM,KAAK,IAAI,EAAE;YACzC,OAAO,GAAG,MAAM,OAAO,CAAC,G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,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;IAC1E,OAAO,CAAC,cAAc,CAAC,MAAM,IAAI,CAAC,CAAC,IAAI,YAAY,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,cAAc,CAAC;AACxF,CAAC;AAJD,8EAIC"}
|
|
@@ -33,7 +33,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
33
33
|
};
|
|
34
34
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
35
|
exports.getUserInfo = exports.sendResponse = exports.messageParser = exports.failResponse = exports.successResponse = void 0;
|
|
36
|
-
|
|
36
|
+
// import { apmEndTransaction } from '../monitoring/apm';
|
|
37
37
|
const logger_1 = require("../logger/logger");
|
|
38
38
|
const appConst_1 = require("../appConst");
|
|
39
39
|
const _ = __importStar(require("lodash"));
|
|
@@ -50,7 +50,7 @@ function successResponse(res, next, result) {
|
|
|
50
50
|
totalCount: result.totalCount,
|
|
51
51
|
aggregation: result.aggregation
|
|
52
52
|
};
|
|
53
|
-
|
|
53
|
+
// await apmEndTransaction(res);
|
|
54
54
|
res.send(response);
|
|
55
55
|
});
|
|
56
56
|
}
|
|
@@ -95,7 +95,7 @@ function filterHandler(data, fields) {
|
|
|
95
95
|
function failResponse(res, message = "", statusCode = 200) {
|
|
96
96
|
return __awaiter(this, void 0, void 0, function* () {
|
|
97
97
|
let response = { isSuccess: false, message: message };
|
|
98
|
-
|
|
98
|
+
// await apmEndTransaction(res);
|
|
99
99
|
res.status(statusCode).send(response);
|
|
100
100
|
if (messageParser(message)) {
|
|
101
101
|
logger_1.logger.error(`shut down by process.exit`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"responseUtils.js","sourceRoot":"","sources":["../../../src/utils/commonUtils/responseUtils.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,
|
|
1
|
+
{"version":3,"file":"responseUtils.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
+
scheme: "bearer",
|
|
25
|
+
in: "header"
|
|
20
26
|
}
|
|
21
27
|
}
|
|
22
28
|
},
|
|
23
29
|
security: [
|
|
24
30
|
{
|
|
25
|
-
"xApiKey": ['read', 'write']
|
|
31
|
+
"xApiKey": ['read', 'write'],
|
|
32
|
+
"bearerAuth": ['read', 'write']
|
|
26
33
|
}
|
|
27
34
|
],
|
|
28
35
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"swagger.js","sourceRoot":"","sources":["../../../src/utils/documentation/swagger.ts"],"names":[],"mappings":";;;;;;AAAA,kEAAyC;AACzC,4CAA+C;AAE/C,qBAAqB;AACrB,IAAI,iBAAiB,GAAG;IACpB,OAAO,EAAE,OAAO;IAChB,IAAI,EAAE,2BAAe,CAAC,OAAO;IAC7B,OAAO,EAAE,CAAC,EAAE,GAAG,EAAE,2BAAe,CAAC,gBAAgB,EAAE,CAAC;IACpD,UAAU,EAAE;QACR,eAAe,EAAE;YACb,SAAS,EAAE;gBACP,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,WAAW;gBACjB,EAAE,EAAE,QAAQ;aACf;SACJ;KACJ;IACD,QAAQ,EAAE;QACN;YACI,SAAS,EAAE,CAAC,MAAM,EAAE,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"swagger.js","sourceRoot":"","sources":["../../../src/utils/documentation/swagger.ts"],"names":[],"mappings":";;;;;;AAAA,kEAAyC;AACzC,4CAA+C;AAE/C,qBAAqB;AACrB,IAAI,iBAAiB,GAAG;IACpB,OAAO,EAAE,OAAO;IAChB,IAAI,EAAE,2BAAe,CAAC,OAAO;IAC7B,OAAO,EAAE,CAAC,EAAE,GAAG,EAAE,2BAAe,CAAC,gBAAgB,EAAE,CAAC;IACpD,UAAU,EAAE;QACR,eAAe,EAAE;YACb,SAAS,EAAE;gBACP,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,WAAW;gBACjB,EAAE,EAAE,QAAQ;aACf;YACD,YAAY,EAAE;gBACV,IAAI,EAAE,MAAM;gBACZ,IAAI,EAAE,WAAW;gBACjB,MAAM,EAAE,QAAQ;gBAChB,EAAE,EAAE,QAAQ;aACf;SACJ;KACJ;IACD,QAAQ,EAAE;QACN;YACI,SAAS,EAAE,CAAC,MAAM,EAAE,OAAO,CAAC;YAC5B,YAAY,EAAE,CAAC,MAAM,EAAE,OAAO,CAAC;SAClC;KACJ;CACJ,CAAC;AAEF,+BAA+B;AAC/B,IAAI,OAAO,GAAG;IACV,4BAA4B;IAC5B,iBAAiB,EAAE,iBAAiB;IACpC,uBAAuB;IACvB,IAAI,EAAE,CAAC,SAAS,GAAG,yCAAyC,EAAE,SAAS,GAAG,iCAAiC,EAAE,SAAS,GAAG,iCAAiC,CAAC;CAC9J,CAAC;AAEW,QAAA,WAAW,GAAG,IAAA,uBAAY,EAAC,OAAO,CAAC,CAAC"}
|
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
2
13
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
14
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
15
|
};
|
|
@@ -8,22 +19,40 @@ const winston_1 = require("winston");
|
|
|
8
19
|
const winston_daily_rotate_file_1 = __importDefault(require("winston-daily-rotate-file"));
|
|
9
20
|
const appConfig_1 = require("../appConfig");
|
|
10
21
|
exports.logger = (0, winston_1.createLogger)({
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
return `${info.timestamp} - ${info.level}: ${info.message}`;
|
|
16
|
-
})),
|
|
22
|
+
defaultMeta: {
|
|
23
|
+
service: appConfig_1.commonAppConfig.AppName
|
|
24
|
+
},
|
|
25
|
+
exitOnError: false,
|
|
17
26
|
transports: [
|
|
18
|
-
new winston_daily_rotate_file_1.default({
|
|
19
|
-
|
|
20
|
-
|
|
27
|
+
new winston_daily_rotate_file_1.default({
|
|
28
|
+
filename: appConfig_1.commonAppConfig.LogPath + 'backend-combined-%DATE%.log',
|
|
29
|
+
datePattern: 'YYYY-MM-DD',
|
|
30
|
+
format: winston_1.format.combine(winston_1.format.json(), winston_1.format.timestamp(), winston_1.format.printf((_a) => {
|
|
31
|
+
var { timestamp, level, message } = _a, metadata = __rest(_a, ["timestamp", "level", "message"]);
|
|
32
|
+
return JSON.stringify(Object.assign({ timestamp,
|
|
33
|
+
level,
|
|
34
|
+
message }, (metadata || {})));
|
|
35
|
+
}))
|
|
36
|
+
}),
|
|
37
|
+
new winston_daily_rotate_file_1.default({
|
|
38
|
+
filename: appConfig_1.commonAppConfig.LogPath + 'backend-error-%DATE%.log',
|
|
39
|
+
level: 'error',
|
|
40
|
+
datePattern: 'YYYY-MM-DD',
|
|
41
|
+
format: winston_1.format.combine(winston_1.format.json(), winston_1.format.timestamp(), winston_1.format.printf((_a) => {
|
|
42
|
+
var { timestamp, level, message } = _a, metadata = __rest(_a, ["timestamp", "level", "message"]);
|
|
43
|
+
return JSON.stringify(Object.assign({ timestamp,
|
|
44
|
+
level,
|
|
45
|
+
message }, (metadata || {})));
|
|
46
|
+
}))
|
|
47
|
+
})
|
|
48
|
+
],
|
|
49
|
+
format: winston_1.format.combine(winston_1.format.timestamp())
|
|
21
50
|
});
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}))
|
|
28
|
-
}
|
|
51
|
+
exports.logger.add(new winston_1.transports.Console({
|
|
52
|
+
format: winston_1.format.combine(winston_1.format.json(), winston_1.format.metadata(), winston_1.format.timestamp(), winston_1.format.printf(({ timestamp, level, message, metadata }) => {
|
|
53
|
+
return JSON.stringify(Object.assign({ timestamp,
|
|
54
|
+
level,
|
|
55
|
+
message }, (metadata || {})));
|
|
56
|
+
}))
|
|
57
|
+
}));
|
|
29
58
|
//# sourceMappingURL=logger.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../../src/utils/logger/logger.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../../src/utils/logger/logger.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,qCAAyD;AACzD,0FAAwD;AACxD,4CAA6C;AAEhC,QAAA,MAAM,GAAG,IAAA,sBAAY,EAAC;IACjC,WAAW,EAAE;QACT,OAAO,EAAE,2BAAe,CAAC,OAAO;KACnC;IACD,WAAW,EAAE,KAAK;IAClB,UAAU,EAAE;QACR,IAAI,mCAAe,CAAC;YAChB,QAAQ,EAAE,2BAAe,CAAC,OAAO,GAAG,6BAA6B;YACjE,WAAW,EAAE,YAAY;YACzB,MAAM,EAAE,gBAAM,CAAC,OAAO,CAClB,gBAAM,CAAC,IAAI,EAAE,EACb,gBAAM,CAAC,SAAS,EAAE,EAClB,gBAAM,CAAC,MAAM,CAAC,CAAC,EAA0C,EAAE,EAAE;oBAA9C,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,OAAe,EAAV,QAAQ,cAAxC,iCAA0C,CAAF;gBACnD,OAAO,IAAI,CAAC,SAAS,iBACjB,SAAS;oBACT,KAAK;oBACL,OAAO,IACJ,CAAC,QAAQ,IAAI,EAAE,CAAC,EACrB,CAAC;YACP,CAAC,CAAC,CACL;SACJ,CAAC;QACF,IAAI,mCAAe,CAAC;YAClB,QAAQ,EAAE,2BAAe,CAAC,OAAO,GAAG,0BAA0B;YAC9D,KAAK,EAAE,OAAO;YACd,WAAW,EAAE,YAAY;YACzB,MAAM,EAAE,gBAAM,CAAC,OAAO,CAClB,gBAAM,CAAC,IAAI,EAAE,EACb,gBAAM,CAAC,SAAS,EAAE,EAClB,gBAAM,CAAC,MAAM,CAAC,CAAC,EAA0C,EAAE,EAAE;oBAA9C,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,OAAe,EAAV,QAAQ,cAAxC,iCAA0C,CAAF;gBACnD,OAAO,IAAI,CAAC,SAAS,iBACjB,SAAS;oBACT,KAAK;oBACL,OAAO,IACJ,CAAC,QAAQ,IAAI,EAAE,CAAC,EACrB,CAAC;YACP,CAAC,CAAC,CACL;SACJ,CAAC;KACH;IACD,MAAM,EAAE,gBAAM,CAAC,OAAO,CAAC,gBAAM,CAAC,SAAS,EAAE,CAAC;CAC3C,CAAC,CAAC;AAGH,cAAM,CAAC,GAAG,CACN,IAAI,oBAAU,CAAC,OAAO,CAAC;IACnB,MAAM,EAAE,gBAAM,CAAC,OAAO,CAClB,gBAAM,CAAC,IAAI,EAAE,EACb,gBAAM,CAAC,QAAQ,EAAE,EACjB,gBAAM,CAAC,SAAS,EAAE,EAClB,gBAAM,CAAC,MAAM,CAAC,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE;QACtD,OAAO,IAAI,CAAC,SAAS,iBACjB,SAAS;YACT,KAAK;YACL,OAAO,IACJ,CAAC,QAAQ,IAAI,EAAE,CAAC,EACrB,CAAC;IACP,CAAC,CAAC,CACL;CACJ,CAAC,CACL,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/// <reference types="qs" />
|
|
2
2
|
/// <reference types="express" />
|
|
3
|
-
declare const
|
|
4
|
-
export
|
|
3
|
+
export declare const morganFile: import("express").RequestHandler<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>>;
|
|
4
|
+
export declare const morganConsole: import("express").RequestHandler<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>>;
|
|
@@ -3,6 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.morganConsole = exports.morganFile = void 0;
|
|
6
7
|
const fs_1 = __importDefault(require("fs"));
|
|
7
8
|
const morgan_1 = __importDefault(require("morgan"));
|
|
8
9
|
const rotating_file_stream_1 = __importDefault(require("rotating-file-stream"));
|
|
@@ -22,6 +23,19 @@ var accessLogStream = (0, rotating_file_stream_1.default)(FileNameGenerator, {
|
|
|
22
23
|
interval: '1d',
|
|
23
24
|
path: appConfig_1.commonAppConfig.LogPath
|
|
24
25
|
});
|
|
26
|
+
const jsonFormat = function (tokens, req, res) {
|
|
27
|
+
return JSON.stringify({
|
|
28
|
+
"method": tokens.method(req, res),
|
|
29
|
+
"url": tokens.url(req, res),
|
|
30
|
+
"status": tokens.status(req, res),
|
|
31
|
+
"contentLength": tokens.res(req, res, 'content-length'),
|
|
32
|
+
"responseTime": tokens['response-time'](req, res) + 'ms',
|
|
33
|
+
"totalTime": tokens['total-time'](req, res) + 'ms',
|
|
34
|
+
"httpVersion": tokens['http-version'](req, res),
|
|
35
|
+
"service": appConfig_1.commonAppConfig.AppName
|
|
36
|
+
});
|
|
37
|
+
};
|
|
25
38
|
// setup the logger
|
|
26
|
-
exports.
|
|
39
|
+
exports.morganFile = (0, morgan_1.default)(jsonFormat, { stream: accessLogStream, });
|
|
40
|
+
exports.morganConsole = (0, morgan_1.default)(jsonFormat);
|
|
27
41
|
//# sourceMappingURL=morganLogger.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"morganLogger.js","sourceRoot":"","sources":["../../../src/utils/logger/morganLogger.ts"],"names":[],"mappings":"
|
|
1
|
+
{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AC,GAAG,EAAE,GAAG,CAAC,GAAG,IAAI;QACxD,WAAW,EAAE,MAAM,CAAC,YAAY,CAAC,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG,IAAI;QAClD,aAAa,EAAE,MAAM,CAAC,cAAc,CAAC,CAAC,GAAG,EAAE,GAAG,CAAC;QAC/C,SAAS,EAAE,2BAAe,CAAC,OAAO;KACnC,CAAC,CAAA;AACJ,CAAC,CAAA;AAED,mBAAmB;AACN,QAAA,UAAU,GAAG,IAAA,gBAAM,EAAC,UAAU,EAAE,EAAE,MAAM,EAAE,eAAe,GAAG,CAAC,CAAA;AAE7D,QAAA,aAAa,GAAI,IAAA,gBAAM,EAAC,UAAU,CAAC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "skyeye-svc-common-utils",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.63",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -20,7 +20,6 @@
|
|
|
20
20
|
},
|
|
21
21
|
"homepage": "https://github.com/HandshakesByDC/SkyEye-SVC-Common-Utils#readme",
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@azure/core-rest-pipeline": "1.12.2",
|
|
24
23
|
"@azure/data-tables": "^13.2.2",
|
|
25
24
|
"@azure/identity": "latest",
|
|
26
25
|
"@azure/keyvault-secrets": "latest",
|
package/src/lib/httpClient.ts
CHANGED
|
@@ -1,36 +1,37 @@
|
|
|
1
|
+
import fetch, { Response, RequestInit } from 'node-fetch';
|
|
1
2
|
import { UserInfo } from '../interfaces';
|
|
2
3
|
import { getInternalClient, userInfoSimplifier } from '../utils/commonUtils';
|
|
3
4
|
import { generateJWT } from '../utils/commonUtils';
|
|
4
5
|
import {commonAppConst, jsonContentTypeHeaders } from '../utils/appConst';
|
|
5
|
-
|
|
6
|
+
import { logger } from '../utils/logger/logger';
|
|
6
7
|
|
|
7
8
|
export async function httpRequest(method: string, url : string, data: any = null, headers : any = jsonContentTypeHeaders()): Promise<Response> {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
method: method,
|
|
15
|
-
cache: "no-cache",
|
|
16
|
-
headers: headers,
|
|
17
|
-
body: JSON.stringify(data)
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
return fetch(url, init);
|
|
9
|
+
const init: RequestInit = {
|
|
10
|
+
method,
|
|
11
|
+
headers,
|
|
12
|
+
body: data === null ? undefined : JSON.stringify(data)
|
|
13
|
+
}
|
|
14
|
+
return fetch(url, init);
|
|
21
15
|
}
|
|
22
16
|
|
|
23
17
|
export async function sendInternalHttpRequest(userInfo:UserInfo, client: string, endpoint: string, data: any = null, method?: string, select?:string[]) {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
18
|
+
method = method ?? commonAppConst.httpMethod.POST;
|
|
19
|
+
const internalClient = await getInternalClient(client)
|
|
20
|
+
const url = internalClient + endpoint;
|
|
21
|
+
let headers:any = jsonContentTypeHeaders();
|
|
22
|
+
if(userInfo){
|
|
23
|
+
userInfo = await userInfoSimplifier(userInfo, select)
|
|
24
|
+
let token: string = `${commonAppConst.httpHeader.BEARER} ${await generateJWT(userInfo)}`;
|
|
25
|
+
headers[commonAppConst.httpHeader.AUTHORIZATION] = token;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
let response: Response;
|
|
29
|
+
try {
|
|
30
|
+
response = await httpRequest(method, url, data, headers);
|
|
31
|
+
return response.json();
|
|
32
|
+
}
|
|
33
|
+
catch (err) {
|
|
34
|
+
logger.error(`Error while sending internal http request, receiving response: ${response}`);
|
|
35
|
+
throw new Error(`${err}`);
|
|
36
|
+
}
|
|
36
37
|
}
|