pg-mvc-service 2.1.41 → 2.1.42
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/Controller.d.ts +24 -3
- package/dist/Controller.d.ts.map +1 -1
- package/dist/Controller.js +126 -106
- package/package.json +1 -1
package/dist/Controller.d.ts
CHANGED
|
@@ -48,7 +48,30 @@ export declare class Controller<IEnv extends IBaseEnv = IBaseEnv> {
|
|
|
48
48
|
protected middleware(): Promise<void>;
|
|
49
49
|
protected outputSuccessLog(): Promise<void>;
|
|
50
50
|
protected outputErrorLog(ex: any): Promise<void>;
|
|
51
|
-
|
|
51
|
+
runHono(): Promise<(globalThis.Response & TypedResponse<{
|
|
52
|
+
[x: string]: any;
|
|
53
|
+
}, 200, "json">) | (globalThis.Response & TypedResponse<{
|
|
54
|
+
message: string;
|
|
55
|
+
}, 401, "json">) | (globalThis.Response & TypedResponse<{
|
|
56
|
+
message: string;
|
|
57
|
+
}, 403, "json">) | (globalThis.Response & TypedResponse<{
|
|
58
|
+
errorCode: string;
|
|
59
|
+
errorMessage: string;
|
|
60
|
+
}, 400, "json">) | (globalThis.Response & TypedResponse<{
|
|
61
|
+
errorCode: string;
|
|
62
|
+
errorMessage: string;
|
|
63
|
+
}, 409, "json">) | (globalThis.Response & TypedResponse<{
|
|
64
|
+
errorCode: string;
|
|
65
|
+
errorMessage: string;
|
|
66
|
+
}, 422, "json">) | (globalThis.Response & TypedResponse<{
|
|
67
|
+
errorMessage: string;
|
|
68
|
+
}, 503, "json">) | (globalThis.Response & TypedResponse<{
|
|
69
|
+
errorCode: string;
|
|
70
|
+
errorMessage: string;
|
|
71
|
+
}, 404, "json">) | (globalThis.Response & TypedResponse<{
|
|
72
|
+
message: string;
|
|
73
|
+
}, 500, "json">)>;
|
|
74
|
+
runExpress(): Promise<Response<any, Record<string, any>> | undefined>;
|
|
52
75
|
private readonly req?;
|
|
53
76
|
protected get Req(): Request;
|
|
54
77
|
private readonly res?;
|
|
@@ -83,8 +106,6 @@ export declare class Controller<IEnv extends IBaseEnv = IBaseEnv> {
|
|
|
83
106
|
protected get DbPort(): string | number | undefined;
|
|
84
107
|
protected get DbIsSslConnect(): boolean;
|
|
85
108
|
private setPool;
|
|
86
|
-
private handleExceptionExpress;
|
|
87
|
-
private handleExceptionHono;
|
|
88
109
|
private pool?;
|
|
89
110
|
private get Pool();
|
|
90
111
|
private client?;
|
package/dist/Controller.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Controller.d.ts","sourceRoot":"","sources":["../src/Controller.ts"],"names":[],"mappings":"AAAA,OAAc,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,MAAM,CAAA;AAE7C,OAAO,EAAE,IAAI,EAAE,KAAK,UAAU,EAAE,MAAM,IAAI,CAAC;AAE3C,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAGxD,KAAK,WAAW,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC;AAE7E,MAAM,MAAM,UAAU,GAAG,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,OAAO,GAAG,QAAQ,CAAC;AACrE,MAAM,WAAW,MAAM;IACnB,MAAM,EAAE,WAAW,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;CACvB;AAED,UAAU,QAAQ;IACd,OAAO,CAAC,EAAE,M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U,CAAC,QAAQ,GAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,SAAS,GAAC;QAAC,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAC,EAChF,MAAM,EAAE,UAAU,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE;QAAC,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAC,GAAG,OAAO,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC;CA0C1H"}
|
package/dist/Controller.js
CHANGED
|
@@ -52,15 +52,10 @@ class Controller {
|
|
|
52
52
|
outputErrorLog(ex) {
|
|
53
53
|
return __awaiter(this, void 0, void 0, function* () { });
|
|
54
54
|
}
|
|
55
|
-
|
|
55
|
+
runHono() {
|
|
56
56
|
return __awaiter(this, void 0, void 0, function* () {
|
|
57
57
|
try {
|
|
58
|
-
|
|
59
|
-
yield this.request.setRequest(this.Module, this.Req);
|
|
60
|
-
}
|
|
61
|
-
else {
|
|
62
|
-
yield this.request.setRequest(this.Module, this.C);
|
|
63
|
-
}
|
|
58
|
+
yield this.request.setRequest(this.Module, this.C);
|
|
64
59
|
if (this.isSetDbConnection) {
|
|
65
60
|
this.client = yield this.Pool.connect();
|
|
66
61
|
yield this.Client.query('BEGIN');
|
|
@@ -75,23 +70,141 @@ class Controller {
|
|
|
75
70
|
this.outputSuccessLog().catch((ex) => {
|
|
76
71
|
console.error(ex);
|
|
77
72
|
});
|
|
78
|
-
|
|
79
|
-
|
|
73
|
+
return this.C.json(this.response.ResponseData, 200);
|
|
74
|
+
}
|
|
75
|
+
catch (ex) {
|
|
76
|
+
this.outputErrorLog(ex).catch((ex) => {
|
|
77
|
+
console.error(ex);
|
|
78
|
+
});
|
|
79
|
+
if (ex instanceof Exception_1.AuthException) {
|
|
80
|
+
return this.C.json({
|
|
81
|
+
message: "Authentication expired. Please login again."
|
|
82
|
+
}, 401);
|
|
83
|
+
}
|
|
84
|
+
else if (ex instanceof Exception_1.ForbiddenException) {
|
|
85
|
+
return this.C.json({
|
|
86
|
+
message: 'Forbidden error'
|
|
87
|
+
}, 403);
|
|
88
|
+
}
|
|
89
|
+
else if (ex instanceof Exception_1.InputErrorException) {
|
|
90
|
+
return this.C.json({
|
|
91
|
+
errorCode: `${this.apiCode}-${ex.ErrorId}`,
|
|
92
|
+
errorMessage: ex.message
|
|
93
|
+
}, 400);
|
|
94
|
+
}
|
|
95
|
+
else if (ex instanceof Exception_1.DbConflictException) {
|
|
96
|
+
return this.C.json({
|
|
97
|
+
errorCode: `${this.apiCode}-${ex.ErrorId}`,
|
|
98
|
+
errorMessage: ex.message
|
|
99
|
+
}, 409);
|
|
100
|
+
}
|
|
101
|
+
else if (ex instanceof Exception_1.UnprocessableException) {
|
|
102
|
+
return this.C.json({
|
|
103
|
+
errorCode: `${this.apiCode}-${ex.ErrorId}`,
|
|
104
|
+
errorMessage: ex.message
|
|
105
|
+
}, 422);
|
|
106
|
+
}
|
|
107
|
+
else if (ex instanceof Exception_1.MaintenanceException) {
|
|
108
|
+
return this.C.json({
|
|
109
|
+
errorMessage: ex.message
|
|
110
|
+
}, 503);
|
|
111
|
+
}
|
|
112
|
+
else if (ex instanceof Exception_1.NotFoundException) {
|
|
113
|
+
return this.C.json({
|
|
114
|
+
errorCode: `${this.apiCode}-${ex.ErrorId}`,
|
|
115
|
+
errorMessage: ex.message
|
|
116
|
+
}, 404);
|
|
80
117
|
}
|
|
81
118
|
else {
|
|
82
|
-
return this.C.json(
|
|
119
|
+
return this.C.json({
|
|
120
|
+
message: 'Internal server error'
|
|
121
|
+
}, 500);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
finally {
|
|
125
|
+
if (this.isExecuteRollback) {
|
|
126
|
+
yield this.Client.query('ROLLBACK');
|
|
127
|
+
}
|
|
128
|
+
this.isExecuteRollback = false;
|
|
129
|
+
if (this.client !== undefined) {
|
|
130
|
+
yield this.client.release();
|
|
131
|
+
}
|
|
132
|
+
if (this.pool !== undefined) {
|
|
133
|
+
yield this.pool.end();
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
runExpress() {
|
|
139
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
140
|
+
try {
|
|
141
|
+
yield this.request.setRequest(this.Module, this.Req);
|
|
142
|
+
if (this.isSetDbConnection) {
|
|
143
|
+
this.client = yield this.Pool.connect();
|
|
144
|
+
yield this.Client.query('BEGIN');
|
|
145
|
+
this.isExecuteRollback = true;
|
|
146
|
+
}
|
|
147
|
+
yield this.middleware();
|
|
148
|
+
yield this.main();
|
|
149
|
+
if (this.isSetDbConnection) {
|
|
150
|
+
yield this.Client.query('COMMIT');
|
|
151
|
+
this.isExecuteRollback = false;
|
|
83
152
|
}
|
|
153
|
+
this.outputSuccessLog().catch((ex) => {
|
|
154
|
+
console.error(ex);
|
|
155
|
+
});
|
|
156
|
+
return this.Res.status(200).json(this.response.ResponseData);
|
|
84
157
|
}
|
|
85
158
|
catch (ex) {
|
|
86
159
|
this.outputErrorLog(ex).catch((ex) => {
|
|
87
160
|
console.error(ex);
|
|
88
161
|
});
|
|
89
|
-
if (
|
|
90
|
-
|
|
162
|
+
if (ex instanceof Exception_1.AuthException) {
|
|
163
|
+
this.Res.status(401).json({
|
|
164
|
+
message: "Authentication expired. Please login again."
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
else if (ex instanceof Exception_1.ForbiddenException) {
|
|
168
|
+
this.Res.status(403).json({
|
|
169
|
+
message: 'Forbidden error'
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
else if (ex instanceof Exception_1.InputErrorException) {
|
|
173
|
+
this.Res.status(400).json({
|
|
174
|
+
errorCode: `${this.apiCode}-${ex.ErrorId}`,
|
|
175
|
+
errorMessage: ex.message
|
|
176
|
+
});
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
else if (ex instanceof Exception_1.DbConflictException) {
|
|
180
|
+
this.Res.status(409).json({
|
|
181
|
+
errorCode: `${this.apiCode}-${ex.ErrorId}`,
|
|
182
|
+
errorMessage: ex.message
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
else if (ex instanceof Exception_1.UnprocessableException) {
|
|
186
|
+
this.Res.status(422).json({
|
|
187
|
+
errorCode: `${this.apiCode}-${ex.ErrorId}`,
|
|
188
|
+
errorMessage: ex.message
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
else if (ex instanceof Exception_1.MaintenanceException) {
|
|
192
|
+
this.Res.status(503).json({
|
|
193
|
+
errorMessage: ex.message
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
else if (ex instanceof Exception_1.NotFoundException) {
|
|
197
|
+
this.Res.status(404).json({
|
|
198
|
+
errorCode: `${this.apiCode}-${ex.ErrorId}`,
|
|
199
|
+
errorMessage: ex.message
|
|
200
|
+
});
|
|
91
201
|
}
|
|
92
202
|
else {
|
|
93
|
-
|
|
203
|
+
this.Res.status(500).json({
|
|
204
|
+
message: 'Internal server error'
|
|
205
|
+
});
|
|
94
206
|
}
|
|
207
|
+
return;
|
|
95
208
|
}
|
|
96
209
|
finally {
|
|
97
210
|
if (this.isExecuteRollback) {
|
|
@@ -279,99 +392,6 @@ class Controller {
|
|
|
279
392
|
throw new Error("Failed to connect to the database. Please check the connection settings.");
|
|
280
393
|
}
|
|
281
394
|
}
|
|
282
|
-
handleExceptionExpress(ex) {
|
|
283
|
-
if (ex instanceof Exception_1.AuthException) {
|
|
284
|
-
this.Res.status(401).json({
|
|
285
|
-
message: "Authentication expired. Please login again."
|
|
286
|
-
});
|
|
287
|
-
}
|
|
288
|
-
else if (ex instanceof Exception_1.ForbiddenException) {
|
|
289
|
-
this.Res.status(403).json({
|
|
290
|
-
message: 'Forbidden error'
|
|
291
|
-
});
|
|
292
|
-
}
|
|
293
|
-
else if (ex instanceof Exception_1.InputErrorException) {
|
|
294
|
-
this.Res.status(400).json({
|
|
295
|
-
errorCode: `${this.apiCode}-${ex.ErrorId}`,
|
|
296
|
-
errorMessage: ex.message
|
|
297
|
-
});
|
|
298
|
-
return;
|
|
299
|
-
}
|
|
300
|
-
else if (ex instanceof Exception_1.DbConflictException) {
|
|
301
|
-
this.Res.status(409).json({
|
|
302
|
-
errorCode: `${this.apiCode}-${ex.ErrorId}`,
|
|
303
|
-
errorMessage: ex.message
|
|
304
|
-
});
|
|
305
|
-
}
|
|
306
|
-
else if (ex instanceof Exception_1.UnprocessableException) {
|
|
307
|
-
this.Res.status(422).json({
|
|
308
|
-
errorCode: `${this.apiCode}-${ex.ErrorId}`,
|
|
309
|
-
errorMessage: ex.message
|
|
310
|
-
});
|
|
311
|
-
}
|
|
312
|
-
else if (ex instanceof Exception_1.MaintenanceException) {
|
|
313
|
-
this.Res.status(503).json({
|
|
314
|
-
errorMessage: ex.message
|
|
315
|
-
});
|
|
316
|
-
}
|
|
317
|
-
else if (ex instanceof Exception_1.NotFoundException) {
|
|
318
|
-
this.Res.status(404).json({
|
|
319
|
-
errorCode: `${this.apiCode}-${ex.ErrorId}`,
|
|
320
|
-
errorMessage: ex.message
|
|
321
|
-
});
|
|
322
|
-
}
|
|
323
|
-
else {
|
|
324
|
-
this.Res.status(500).json({
|
|
325
|
-
message: 'Internal server error'
|
|
326
|
-
});
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
handleExceptionHono(ex) {
|
|
330
|
-
if (ex instanceof Exception_1.AuthException) {
|
|
331
|
-
return this.C.json({
|
|
332
|
-
message: "Authentication expired. Please login again."
|
|
333
|
-
}, 401);
|
|
334
|
-
}
|
|
335
|
-
else if (ex instanceof Exception_1.ForbiddenException) {
|
|
336
|
-
return this.C.json({
|
|
337
|
-
message: 'Forbidden error'
|
|
338
|
-
}, 403);
|
|
339
|
-
}
|
|
340
|
-
else if (ex instanceof Exception_1.InputErrorException) {
|
|
341
|
-
return this.C.json({
|
|
342
|
-
errorCode: `${this.apiCode}-${ex.ErrorId}`,
|
|
343
|
-
errorMessage: ex.message
|
|
344
|
-
}, 400);
|
|
345
|
-
}
|
|
346
|
-
else if (ex instanceof Exception_1.DbConflictException) {
|
|
347
|
-
return this.C.json({
|
|
348
|
-
errorCode: `${this.apiCode}-${ex.ErrorId}`,
|
|
349
|
-
errorMessage: ex.message
|
|
350
|
-
}, 409);
|
|
351
|
-
}
|
|
352
|
-
else if (ex instanceof Exception_1.UnprocessableException) {
|
|
353
|
-
return this.C.json({
|
|
354
|
-
errorCode: `${this.apiCode}-${ex.ErrorId}`,
|
|
355
|
-
errorMessage: ex.message
|
|
356
|
-
}, 422);
|
|
357
|
-
}
|
|
358
|
-
else if (ex instanceof Exception_1.MaintenanceException) {
|
|
359
|
-
return this.C.json({
|
|
360
|
-
errorMessage: ex.message
|
|
361
|
-
}, 503);
|
|
362
|
-
}
|
|
363
|
-
else if (ex instanceof Exception_1.NotFoundException) {
|
|
364
|
-
return this.C.json({
|
|
365
|
-
errorCode: `${this.apiCode}-${ex.ErrorId}`,
|
|
366
|
-
errorMessage: ex.message
|
|
367
|
-
}, 404);
|
|
368
|
-
}
|
|
369
|
-
else {
|
|
370
|
-
return this.C.json({
|
|
371
|
-
message: 'Internal server error'
|
|
372
|
-
}, 500);
|
|
373
|
-
}
|
|
374
|
-
}
|
|
375
395
|
get Pool() {
|
|
376
396
|
var _a;
|
|
377
397
|
if (this.pool === undefined) {
|