pg-mvc-service 2.0.38 → 2.0.40
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/Service.js +8 -1
- package/dist/index.js +2 -1
- package/dist/models/TableModel.js +3 -0
- package/package.json +1 -1
- package/src/Service.ts +7 -1
- package/src/index.ts +1 -1
- package/src/models/TableModel.ts +5 -1
package/dist/Service.js
CHANGED
|
@@ -140,6 +140,13 @@ class Service {
|
|
|
140
140
|
});
|
|
141
141
|
return;
|
|
142
142
|
}
|
|
143
|
+
else if (ex instanceof Exception_1.NotFoundException) {
|
|
144
|
+
this.res.status(404).json({
|
|
145
|
+
errorCode: `${this.apiCode}-${ex.ErrorId}`,
|
|
146
|
+
errorMessage: ex.message
|
|
147
|
+
});
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
143
150
|
this.res.status(500).json({
|
|
144
151
|
message: 'Internal server error'
|
|
145
152
|
});
|
|
@@ -260,7 +267,7 @@ class Service {
|
|
|
260
267
|
}
|
|
261
268
|
catch (ex) {
|
|
262
269
|
let response = ex.response;
|
|
263
|
-
if (response && [400, 401, 403, 409, 422].includes(response.status)) {
|
|
270
|
+
if (response && [400, 401, 403, 404, 409, 422].includes(response.status)) {
|
|
264
271
|
return response;
|
|
265
272
|
}
|
|
266
273
|
throw ex;
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.runCron = exports.BaseCron = exports.rollback = exports.migrate = exports.MigrateDatabase = exports.MigrateTable = exports.createTableDoc = exports.TableModel = exports.ResponseType = exports.RequestType = exports.EncryptClient = exports.StringClient = exports.Base64Client = exports.AwsS3Client = exports.createSwagger = exports.UnprocessableException = exports.DbConflictException = exports.ForbiddenException = exports.InputErrorException = exports.AuthException = exports.MaintenanceException = exports.Service = void 0;
|
|
3
|
+
exports.runCron = exports.BaseCron = exports.rollback = exports.migrate = exports.MigrateDatabase = exports.MigrateTable = exports.createTableDoc = exports.TableModel = exports.ResponseType = exports.RequestType = exports.EncryptClient = exports.StringClient = exports.Base64Client = exports.AwsS3Client = exports.createSwagger = exports.NotFoundException = exports.UnprocessableException = exports.DbConflictException = exports.ForbiddenException = exports.InputErrorException = exports.AuthException = exports.MaintenanceException = exports.Service = void 0;
|
|
4
4
|
var Service_1 = require("./Service");
|
|
5
5
|
Object.defineProperty(exports, "Service", { enumerable: true, get: function () { return Service_1.Service; } });
|
|
6
6
|
var Exception_1 = require("./exceptions/Exception");
|
|
@@ -10,6 +10,7 @@ Object.defineProperty(exports, "InputErrorException", { enumerable: true, get: f
|
|
|
10
10
|
Object.defineProperty(exports, "ForbiddenException", { enumerable: true, get: function () { return Exception_1.ForbiddenException; } });
|
|
11
11
|
Object.defineProperty(exports, "DbConflictException", { enumerable: true, get: function () { return Exception_1.DbConflictException; } });
|
|
12
12
|
Object.defineProperty(exports, "UnprocessableException", { enumerable: true, get: function () { return Exception_1.UnprocessableException; } });
|
|
13
|
+
Object.defineProperty(exports, "NotFoundException", { enumerable: true, get: function () { return Exception_1.NotFoundException; } });
|
|
13
14
|
var Swagger_1 = require("./documents/Swagger");
|
|
14
15
|
Object.defineProperty(exports, "createSwagger", { enumerable: true, get: function () { return Swagger_1.createSwagger; } });
|
|
15
16
|
var AwsS3Client_1 = require("./clients/AwsS3Client");
|
|
@@ -354,6 +354,9 @@ class TableModel {
|
|
|
354
354
|
throwUnprocessableException(code, message) {
|
|
355
355
|
throw new Exception_1.UnprocessableException(`${this.id}-${code}`, message);
|
|
356
356
|
}
|
|
357
|
+
throwNotFoundException(code, message) {
|
|
358
|
+
throw new Exception_1.NotFoundException(`${this.id}-${code}`, message);
|
|
359
|
+
}
|
|
357
360
|
validateOptions(options, isInsert, pkOrId) {
|
|
358
361
|
return __awaiter(this, void 0, void 0, function* () {
|
|
359
362
|
if (Object.keys(options).length === 0) {
|
package/package.json
CHANGED
package/src/Service.ts
CHANGED
|
@@ -121,6 +121,12 @@ export class Service {
|
|
|
121
121
|
errorMessage : ex.message
|
|
122
122
|
});
|
|
123
123
|
return;
|
|
124
|
+
} else if (ex instanceof NotFoundException) {
|
|
125
|
+
this.res.status(404).json({
|
|
126
|
+
errorCode : `${this.apiCode}-${ex.ErrorId}`,
|
|
127
|
+
errorMessage : ex.message
|
|
128
|
+
});
|
|
129
|
+
return;
|
|
124
130
|
}
|
|
125
131
|
|
|
126
132
|
this.res.status(500).json({
|
|
@@ -254,7 +260,7 @@ export class Service {
|
|
|
254
260
|
}
|
|
255
261
|
} catch (ex) {
|
|
256
262
|
let response = (ex as any).response as AxiosResponse<TResponse>;
|
|
257
|
-
if (response && [400, 401, 403, 409, 422].includes(response.status)) {
|
|
263
|
+
if (response && [400, 401, 403, 404, 409, 422].includes(response.status)) {
|
|
258
264
|
return response;
|
|
259
265
|
}
|
|
260
266
|
throw ex;
|
package/src/index.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { Service } from './Service';
|
|
2
|
-
export { MaintenanceException, AuthException, InputErrorException, ForbiddenException, DbConflictException, UnprocessableException } from './exceptions/Exception';
|
|
2
|
+
export { MaintenanceException, AuthException, InputErrorException, ForbiddenException, DbConflictException, UnprocessableException, NotFoundException } from './exceptions/Exception';
|
|
3
3
|
export { createSwagger } from './documents/Swagger';
|
|
4
4
|
export { AwsS3Client } from './clients/AwsS3Client';
|
|
5
5
|
export { Base64Client } from './clients/Base64Client';
|
package/src/models/TableModel.ts
CHANGED
|
@@ -4,7 +4,7 @@ import ValidateValueUtil from './SqlUtils/ValidateValueUtil';
|
|
|
4
4
|
import SelectExpression from './SqlUtils/SelectExpression';
|
|
5
5
|
import WhereExpression from './SqlUtils/WhereExpression';
|
|
6
6
|
import ValidateClient from './ValidateClient';
|
|
7
|
-
import { DbConflictException, UnprocessableException } from '../exceptions/Exception';
|
|
7
|
+
import { DbConflictException, NotFoundException, UnprocessableException } from '../exceptions/Exception';
|
|
8
8
|
import ExpressionClient from './ExpressionClient';
|
|
9
9
|
import UpdateExpression from './SqlUtils/UpdateExpression';
|
|
10
10
|
import MessageUtil, { TOptionErrorMessage } from './Utils/MessageUtil';
|
|
@@ -419,6 +419,10 @@ export class TableModel {
|
|
|
419
419
|
throw new UnprocessableException(`${this.id}-${code}`, message);
|
|
420
420
|
}
|
|
421
421
|
|
|
422
|
+
protected throwNotFoundException(code: string, message: string): never {
|
|
423
|
+
throw new NotFoundException(`${this.id}-${code}`, message);
|
|
424
|
+
}
|
|
425
|
+
|
|
422
426
|
protected async validateOptions(options: {[key: string]: any}, isInsert: boolean, pkOrId?: string | number | boolean | {[key: string]: any}): Promise<void> {
|
|
423
427
|
if (Object.keys(options).length === 0) {
|
|
424
428
|
throw new Error('At least one key-value pair is required in options.');
|