skyeye-svc-common-utils 2.0.0-dev0.36 → 2.0.0-dev0.38
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.
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
import { Request, Response, NextFunction } from 'express';
|
|
2
2
|
import { BaseControllerParameter } from '../../models';
|
|
3
3
|
import { QueryRunner } from 'typeorm';
|
|
4
|
-
import { Mutex } from 'async-mutex';
|
|
5
4
|
export declare abstract class BaseController {
|
|
6
5
|
protected abstract executeImpl(params: any, baseControllerParameter: BaseControllerParameter): Promise<any>;
|
|
7
|
-
static mutex: Mutex;
|
|
8
6
|
startTransaction(): Promise<QueryRunner>;
|
|
9
7
|
endTransaction(baseControllerParameter: BaseControllerParameter): Promise<any>;
|
|
10
8
|
executeRest(req: Request, res: Response, next: NextFunction): Promise<void>;
|
|
11
|
-
executeGrpc(call: any, callback: any): Promise<any>;
|
|
12
9
|
}
|
|
@@ -13,9 +13,7 @@ exports.BaseController = void 0;
|
|
|
13
13
|
const commonUtils_1 = require("../commonUtils");
|
|
14
14
|
const logger_1 = require("../logger/logger");
|
|
15
15
|
const models_1 = require("../../models");
|
|
16
|
-
const appConst_1 = require("../appConst");
|
|
17
16
|
const appConfig_1 = require("../appConfig");
|
|
18
|
-
const async_mutex_1 = require("async-mutex");
|
|
19
17
|
const appDataSource_1 = require("./appDataSource");
|
|
20
18
|
class BaseController {
|
|
21
19
|
startTransaction() {
|
|
@@ -25,7 +23,7 @@ class BaseController {
|
|
|
25
23
|
// Use queryRunner if transaction is needed
|
|
26
24
|
queryRunner = appDataSource_1.AppDataSource.getInstance().createQueryRunner();
|
|
27
25
|
yield queryRunner.startTransaction();
|
|
28
|
-
return
|
|
26
|
+
return queryRunner;
|
|
29
27
|
}
|
|
30
28
|
catch (error) {
|
|
31
29
|
if (queryRunner && !queryRunner.isReleased) {
|
|
@@ -36,7 +34,7 @@ class BaseController {
|
|
|
36
34
|
logger_1.logger.error(`BaseController/startTransaction Release Error: ${err}`);
|
|
37
35
|
}
|
|
38
36
|
}
|
|
39
|
-
|
|
37
|
+
throw new Error(`Connect DB Fail!`);
|
|
40
38
|
}
|
|
41
39
|
});
|
|
42
40
|
}
|
|
@@ -85,92 +83,36 @@ class BaseController {
|
|
|
85
83
|
try {
|
|
86
84
|
baseControllerParameter.userInfo = (0, commonUtils_1.getUserInfo)(res);
|
|
87
85
|
if (appConfig_1.commonAppConfig.SqlEnable) {
|
|
88
|
-
|
|
89
|
-
this.startTransaction()
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
return (0, commonUtils_1.sendResponse)(res, next, baseControllerParameter.serviceResponse);
|
|
96
|
-
}).catch((err) => {
|
|
97
|
-
baseControllerParameter.serviceResponse.isSuccess = false;
|
|
98
|
-
this.endTransaction(baseControllerParameter).then(() => {
|
|
99
|
-
next(err);
|
|
100
|
-
});
|
|
101
|
-
});
|
|
102
|
-
;
|
|
103
|
-
}));
|
|
104
|
-
}
|
|
105
|
-
else {
|
|
106
|
-
this.executeImpl(req.body, baseControllerParameter).then(() => {
|
|
107
|
-
return (0, commonUtils_1.sendResponse)(res, next, baseControllerParameter.serviceResponse);
|
|
108
|
-
}).catch((err) => {
|
|
86
|
+
try {
|
|
87
|
+
baseControllerParameter.queryRunner = yield this.startTransaction();
|
|
88
|
+
yield this.executeImpl(req.body, baseControllerParameter);
|
|
89
|
+
yield this.endTransaction(baseControllerParameter);
|
|
90
|
+
yield (0, commonUtils_1.sendResponse)(res, next, baseControllerParameter.serviceResponse);
|
|
91
|
+
}
|
|
92
|
+
catch (err) {
|
|
109
93
|
baseControllerParameter.serviceResponse.isSuccess = false;
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
catch (err) {
|
|
115
|
-
next(err);
|
|
116
|
-
}
|
|
117
|
-
logger_1.logger.profile(`${req.originalUrl}`);
|
|
118
|
-
});
|
|
119
|
-
}
|
|
120
|
-
executeGrpc(call, callback) {
|
|
121
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
122
|
-
let baseControllerParameter = new models_1.BaseControllerParameter();
|
|
123
|
-
baseControllerParameter.serviceResponse = { isSuccess: false, message: undefined, data: undefined, totalCount: undefined };
|
|
124
|
-
try {
|
|
125
|
-
baseControllerParameter.userInfo = undefined;
|
|
126
|
-
const authorization = call.metadata.get(appConst_1.commonAppConst.httpHeader.AUTHORIZATION);
|
|
127
|
-
if (!!authorization && authorization.length) {
|
|
128
|
-
const headerInfo = authorization[0].split(' ');
|
|
129
|
-
if (headerInfo.length === 2 && headerInfo[0] === appConst_1.commonAppConst.httpHeader.BEARER) {
|
|
130
|
-
baseControllerParameter.userInfo = yield (0, commonUtils_1.verifyJWT)(headerInfo[1]);
|
|
94
|
+
yield this.endTransaction(baseControllerParameter);
|
|
95
|
+
throw err;
|
|
131
96
|
}
|
|
132
97
|
}
|
|
133
|
-
if (appConfig_1.commonAppConfig.SqlEnable) {
|
|
134
|
-
BaseController.mutex.runExclusive(() => __awaiter(this, void 0, void 0, function* () {
|
|
135
|
-
this.startTransaction().then((queryRunner) => {
|
|
136
|
-
baseControllerParameter.queryRunner = queryRunner;
|
|
137
|
-
return this.executeImpl(call.request, baseControllerParameter);
|
|
138
|
-
}).then(() => {
|
|
139
|
-
return this.endTransaction(baseControllerParameter);
|
|
140
|
-
}).then(() => {
|
|
141
|
-
return callback(null, baseControllerParameter.serviceResponse);
|
|
142
|
-
}).catch((err) => {
|
|
143
|
-
baseControllerParameter.serviceResponse.isSuccess = false;
|
|
144
|
-
baseControllerParameter.serviceResponse.error = true;
|
|
145
|
-
baseControllerParameter.serviceResponse.message = err.message;
|
|
146
|
-
this.endTransaction(baseControllerParameter).then(() => {
|
|
147
|
-
throw err;
|
|
148
|
-
});
|
|
149
|
-
});
|
|
150
|
-
;
|
|
151
|
-
}));
|
|
152
|
-
}
|
|
153
98
|
else {
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
99
|
+
try {
|
|
100
|
+
yield this.executeImpl(req.body, baseControllerParameter);
|
|
101
|
+
yield (0, commonUtils_1.sendResponse)(res, next, baseControllerParameter.serviceResponse);
|
|
102
|
+
}
|
|
103
|
+
catch (err) {
|
|
157
104
|
baseControllerParameter.serviceResponse.isSuccess = false;
|
|
158
|
-
baseControllerParameter.serviceResponse.error = true;
|
|
159
|
-
baseControllerParameter.serviceResponse.message = err.message;
|
|
160
105
|
throw err;
|
|
161
|
-
}
|
|
106
|
+
}
|
|
162
107
|
}
|
|
163
108
|
}
|
|
164
109
|
catch (err) {
|
|
165
|
-
|
|
166
|
-
baseControllerParameter.serviceResponse.isSuccess = false;
|
|
167
|
-
baseControllerParameter.serviceResponse.error = true;
|
|
168
|
-
return callback(null, baseControllerParameter.serviceResponse);
|
|
110
|
+
next(err);
|
|
169
111
|
}
|
|
112
|
+
logger_1.logger.profile(`${req.originalUrl}`);
|
|
170
113
|
});
|
|
171
114
|
}
|
|
172
115
|
}
|
|
173
116
|
exports.BaseController = BaseController;
|
|
174
|
-
BaseController.mutex = new async_mutex_1.Mutex();
|
|
175
117
|
;
|
|
176
118
|
//# sourceMappingURL=baseController.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"baseController.js","sourceRoot":"","sources":["../../../src/utils/baseClass/baseController.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,gDAAsE;AACtE,6CAA0C;AAE1C,yCAAuD;
|
|
1
|
+
{"version":3,"file":"baseController.js","sourceRoot":"","sources":["../../../src/utils/baseClass/baseController.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,gDAAsE;AACtE,6CAA0C;AAE1C,yCAAuD;AAGvD,4CAA+C;AAC/C,mDAAgD;AAGhD,MAAsB,cAAc;IAG1B,gBAAgB;;YAClB,IAAI,WAAwB,CAAC;YAE7B,IAAI;gBACA,2CAA2C;gBAC3C,WAAW,GAAG,6BAAa,CAAC,WAAW,EAAE,CAA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EAAE,uBAAuB,CAAC,eAAe,CAAC,CAAC;qBAC1E;oBACD,OAAO,GAAG,EAAE;wBACR,uBAAuB,CAAC,eAAe,CAAC,SAAS,GAAG,KAAK,CAAC;wBAC1D,MAAM,GAAG,CAAC;qBACb;iBACJ;aACJ;YAAC,OAAO,GAAG,EAAE;gBACV,IAAI,CAAC,GAAG,CAAC,CAAC;aACb;YAED,eAAM,CAAC,OAAO,CAAC,GAAG,GAAG,CAAC,WAAW,EAAE,CAAC,CAAC;QACzC,CAAC;KAAA;CACJ;AA7FD,wCA6FC;AAAA,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "skyeye-svc-common-utils",
|
|
3
|
-
"version": "2.0.0-dev0.
|
|
3
|
+
"version": "2.0.0-dev0.38",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -21,15 +21,14 @@
|
|
|
21
21
|
"homepage": "https://github.com/HandshakesByDC/SkyEye-SVC-Common-Utils#readme",
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"@azure/data-tables": "^13.2.2",
|
|
24
|
-
"@azure/identity": "
|
|
25
|
-
"@azure/keyvault-secrets": "
|
|
26
|
-
"@azure/service-bus": "7.9.
|
|
24
|
+
"@azure/identity": "^4.0.1",
|
|
25
|
+
"@azure/keyvault-secrets": "^4.8.0",
|
|
26
|
+
"@azure/service-bus": "^7.9.4",
|
|
27
27
|
"@azure/storage-blob": "^12.17.0",
|
|
28
28
|
"@azure/storage-queue": "^12.16.0",
|
|
29
29
|
"@azure/search-documents": "11.2.1",
|
|
30
30
|
"@azure/abort-controller": "1.0.4",
|
|
31
31
|
"@sendgrid/mail": "^8.1.1",
|
|
32
|
-
"async-mutex": "^0.4.1",
|
|
33
32
|
"cron-parser": "^4.9.0",
|
|
34
33
|
"dateformat": "^4.6.3",
|
|
35
34
|
"dotenv": "^16.4.5",
|
|
@@ -37,7 +36,7 @@
|
|
|
37
36
|
"express": "^4.18.2",
|
|
38
37
|
"https": "^1.0.0",
|
|
39
38
|
"ioredis": "^5.3.2",
|
|
40
|
-
"jsonwebtoken": "^9.0.
|
|
39
|
+
"jsonwebtoken": "^9.0.2",
|
|
41
40
|
"lodash": "^4.17.21",
|
|
42
41
|
"moment": "^2.30.1",
|
|
43
42
|
"morgan": "^1.10.0",
|
|
@@ -55,9 +54,9 @@
|
|
|
55
54
|
"@types/dateformat": "^5.0.2",
|
|
56
55
|
"@types/morgan": "~1.9.9",
|
|
57
56
|
"@types/node-fetch": "^2.6.11",
|
|
58
|
-
"@types/express": "4.17.21",
|
|
59
|
-
"@types/jsonwebtoken": "^9.0.
|
|
60
|
-
"@types/lodash": "4.14.202",
|
|
57
|
+
"@types/express": "^4.17.21",
|
|
58
|
+
"@types/jsonwebtoken": "^9.0.6",
|
|
59
|
+
"@types/lodash": "^4.14.202",
|
|
61
60
|
"@types/swagger-jsdoc": "^6.0.4"
|
|
62
61
|
}
|
|
63
62
|
}
|
|
@@ -6,13 +6,11 @@ import { BaseControllerParameter } from '../../models';
|
|
|
6
6
|
import { QueryRunner } from 'typeorm';
|
|
7
7
|
import { commonAppConst } from '../appConst';
|
|
8
8
|
import { commonAppConfig } from '../appConfig';
|
|
9
|
-
import { Mutex } from 'async-mutex';
|
|
10
9
|
import { AppDataSource } from './appDataSource';
|
|
11
10
|
|
|
12
11
|
|
|
13
12
|
export abstract class BaseController {
|
|
14
13
|
protected abstract executeImpl(params: any, baseControllerParameter: BaseControllerParameter): Promise<any>;
|
|
15
|
-
static mutex: Mutex = new Mutex();
|
|
16
14
|
|
|
17
15
|
async startTransaction(): Promise<QueryRunner> {
|
|
18
16
|
let queryRunner: QueryRunner;
|
|
@@ -21,8 +19,7 @@ export abstract class BaseController {
|
|
|
21
19
|
// Use queryRunner if transaction is needed
|
|
22
20
|
queryRunner = AppDataSource.getInstance().createQueryRunner();
|
|
23
21
|
await queryRunner.startTransaction();
|
|
24
|
-
|
|
25
|
-
return Promise.resolve(queryRunner);
|
|
22
|
+
return queryRunner;
|
|
26
23
|
} catch (error) {
|
|
27
24
|
if (queryRunner && !queryRunner.isReleased) {
|
|
28
25
|
try {
|
|
@@ -32,7 +29,7 @@ export abstract class BaseController {
|
|
|
32
29
|
}
|
|
33
30
|
}
|
|
34
31
|
|
|
35
|
-
|
|
32
|
+
throw new Error(`Connect DB Fail!`);
|
|
36
33
|
}
|
|
37
34
|
}
|
|
38
35
|
|
|
@@ -78,86 +75,31 @@ export abstract class BaseController {
|
|
|
78
75
|
try {
|
|
79
76
|
baseControllerParameter.userInfo = getUserInfo(res);
|
|
80
77
|
if (commonAppConfig.SqlEnable) {
|
|
81
|
-
|
|
82
|
-
this.startTransaction()
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
return sendResponse(res, next, baseControllerParameter.serviceResponse);
|
|
89
|
-
}).catch((err: Error) => {
|
|
90
|
-
baseControllerParameter.serviceResponse.isSuccess = false;
|
|
91
|
-
this.endTransaction(baseControllerParameter).then(() => {
|
|
92
|
-
next(err);
|
|
93
|
-
});
|
|
94
|
-
});;
|
|
95
|
-
});
|
|
96
|
-
} else {
|
|
97
|
-
this.executeImpl(req.body, baseControllerParameter).then(() => {
|
|
98
|
-
return sendResponse(res, next, baseControllerParameter.serviceResponse);
|
|
99
|
-
}).catch((err: Error) => {
|
|
78
|
+
try {
|
|
79
|
+
baseControllerParameter.queryRunner = await this.startTransaction();
|
|
80
|
+
await this.executeImpl(req.body, baseControllerParameter);
|
|
81
|
+
await this.endTransaction(baseControllerParameter);
|
|
82
|
+
await sendResponse(res, next, baseControllerParameter.serviceResponse);
|
|
83
|
+
}
|
|
84
|
+
catch (err) {
|
|
100
85
|
baseControllerParameter.serviceResponse.isSuccess = false;
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
}
|
|
104
|
-
} catch (err) {
|
|
105
|
-
next(err);
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
logger.profile(`${req.originalUrl}`);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
public async executeGrpc(call: any, callback: any): Promise<any> {
|
|
112
|
-
let baseControllerParameter: BaseControllerParameter = new BaseControllerParameter();
|
|
113
|
-
baseControllerParameter.serviceResponse = { isSuccess: false, message: undefined, data: undefined, totalCount: undefined };
|
|
114
|
-
|
|
115
|
-
try {
|
|
116
|
-
baseControllerParameter.userInfo = undefined;
|
|
117
|
-
|
|
118
|
-
const authorization: string = call.metadata.get(commonAppConst.httpHeader.AUTHORIZATION);
|
|
119
|
-
if (!!authorization && authorization.length) {
|
|
120
|
-
const headerInfo: string[] = authorization[0].split(' ');
|
|
121
|
-
if (headerInfo.length === 2 && headerInfo[0] === commonAppConst.httpHeader.BEARER) {
|
|
122
|
-
baseControllerParameter.userInfo = await verifyJWT (headerInfo[1]);
|
|
86
|
+
await this.endTransaction(baseControllerParameter);
|
|
87
|
+
throw err;
|
|
123
88
|
}
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
if (commonAppConfig.SqlEnable) {
|
|
127
|
-
BaseController.mutex.runExclusive(async () => {
|
|
128
|
-
this.startTransaction().then((queryRunner: QueryRunner) => {
|
|
129
|
-
baseControllerParameter.queryRunner = queryRunner;
|
|
130
|
-
return this.executeImpl(call.request, baseControllerParameter);
|
|
131
|
-
}).then(() => {
|
|
132
|
-
return this.endTransaction(baseControllerParameter);
|
|
133
|
-
}).then(() => {
|
|
134
|
-
return callback(null, baseControllerParameter.serviceResponse);
|
|
135
|
-
}).catch((err: Error) => {
|
|
136
|
-
baseControllerParameter.serviceResponse.isSuccess = false;
|
|
137
|
-
baseControllerParameter.serviceResponse.error = true;
|
|
138
|
-
baseControllerParameter.serviceResponse.message = err.message;
|
|
139
|
-
|
|
140
|
-
this.endTransaction(baseControllerParameter).then(() => {
|
|
141
|
-
throw err;
|
|
142
|
-
});
|
|
143
|
-
});;
|
|
144
|
-
});
|
|
145
89
|
} else {
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
90
|
+
try {
|
|
91
|
+
await this.executeImpl(req.body, baseControllerParameter);
|
|
92
|
+
await sendResponse(res, next, baseControllerParameter.serviceResponse);
|
|
93
|
+
}
|
|
94
|
+
catch (err) {
|
|
149
95
|
baseControllerParameter.serviceResponse.isSuccess = false;
|
|
150
|
-
baseControllerParameter.serviceResponse.error = true;
|
|
151
|
-
baseControllerParameter.serviceResponse.message = err.message;
|
|
152
|
-
|
|
153
96
|
throw err;
|
|
154
|
-
}
|
|
97
|
+
}
|
|
155
98
|
}
|
|
156
99
|
} catch (err) {
|
|
157
|
-
|
|
158
|
-
baseControllerParameter.serviceResponse.isSuccess = false;
|
|
159
|
-
baseControllerParameter.serviceResponse.error = true;
|
|
160
|
-
return callback(null, baseControllerParameter.serviceResponse);
|
|
100
|
+
next(err);
|
|
161
101
|
}
|
|
102
|
+
|
|
103
|
+
logger.profile(`${req.originalUrl}`);
|
|
162
104
|
}
|
|
163
105
|
};
|