@nest-omni/core 1.0.1 → 1.0.2
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/boilerplate.polyfill.js.map +1 -1
- package/dist/common/abstract-client.service.js.map +1 -1
- package/dist/common/abstract.entity.js.map +1 -1
- package/dist/common/dto/abstract.dto.js.map +1 -1
- package/dist/common/utils.js.map +1 -1
- package/dist/decorators/auth-user.decorator.js.map +1 -1
- package/dist/decorators/field.decorators.js.map +1 -1
- package/dist/decorators/omni-auth.decorator.js.map +1 -1
- package/dist/decorators/swagger.schema.js.map +1 -1
- package/dist/decorators/transform.decorators.js.map +1 -1
- package/dist/decorators/user-check.decorator.js.map +1 -1
- package/dist/decorators/user.decorator.js.map +1 -1
- package/dist/filters/bad-request.filter.js.map +1 -1
- package/dist/health-checker/health-checker.controller.js.map +1 -1
- package/dist/health-checker/health-indicators/service.indicator.js.map +1 -1
- package/dist/helpers/common.helper.js.map +1 -1
- package/dist/helpers/date.helper.js.map +1 -1
- package/dist/interceptors/language-interceptor.service.js.map +1 -1
- package/dist/interceptors/translation-interceptor.service.js.map +1 -1
- package/dist/middlewares/request-id.middleware.js.map +1 -1
- package/dist/providers/context.provider.js.map +1 -1
- package/dist/providers/generator.provider.js.map +1 -1
- package/dist/setup/bootstrap.setup.js.map +1 -1
- package/dist/setup-swagger.js.map +1 -1
- package/dist/shared/serviceRegistryModule.js.map +1 -1
- package/dist/shared/services/api-config.service.js.map +1 -1
- package/dist/shared/services/translation.service.js.map +1 -1
- package/dist/snake-naming.strategy.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/validators/file-mimetype.validator.js.map +1 -1
- package/dist/validators/is-unique.validator.js.map +1 -1
- package/dist/validators/skip-empty.validator.js.map +1 -1
- package/package.json +10 -3
- package/dist/guards/auth.guard.d.ts +0 -4
- package/dist/guards/auth.guard.js +0 -13
- package/dist/guards/auth.guard.js.map +0 -1
- package/dist/guards/roles.guard.d.ts +0 -7
- package/dist/guards/roles.guard.js +0 -36
- package/dist/guards/roles.guard.js.map +0 -1
- package/dist/helpers/excel.helper.d.ts +0 -12
- package/dist/helpers/excel.helper.js +0 -250
- package/dist/helpers/excel.helper.js.map +0 -1
- package/src/boilerplate.polyfill.d.ts +0 -39
- package/src/boilerplate.polyfill.js +0 -78
- package/src/boilerplate.polyfill.ts +0 -202
- package/src/common/abstract-client.service.d.ts +0 -20
- package/src/common/abstract-client.service.js +0 -39
- package/src/common/abstract-client.service.ts +0 -56
- package/src/common/abstract.entity.d.ts +0 -24
- package/src/common/abstract.entity.js +0 -152
- package/src/common/abstract.entity.ts +0 -73
- package/src/common/dto/abstract.dto.d.ts +0 -13
- package/src/common/dto/abstract.dto.js +0 -96
- package/src/common/dto/abstract.dto.ts +0 -64
- package/src/common/dto/bulk-id.dto.d.ts +0 -3
- package/src/common/dto/bulk-id.dto.js +0 -63
- package/src/common/dto/bulk-id.dto.ts +0 -13
- package/src/common/dto/create-translation.dto.d.ts +0 -5
- package/src/common/dto/create-translation.dto.js +0 -63
- package/src/common/dto/create-translation.dto.ts +0 -10
- package/src/common/dto/page-meta.dto.d.ts +0 -15
- package/src/common/dto/page-meta.dto.js +0 -88
- package/src/common/dto/page-meta.dto.ts +0 -37
- package/src/common/dto/page-options.dto.d.ts +0 -8
- package/src/common/dto/page-options.dto.js +0 -87
- package/src/common/dto/page-options.dto.ts +0 -35
- package/src/common/dto/page.dto.d.ts +0 -11
- package/src/common/dto/page.dto.js +0 -94
- package/src/common/dto/page.dto.ts +0 -36
- package/src/common/utils.d.ts +0 -14
- package/src/common/utils.js +0 -39
- package/src/common/utils.ts +0 -45
- package/src/constants/index.d.ts +0 -4
- package/src/constants/index.js +0 -20
- package/src/constants/index.ts +0 -4
- package/src/constants/language-code.d.ts +0 -5
- package/src/constants/language-code.js +0 -10
- package/src/constants/language-code.ts +0 -7
- package/src/constants/order.d.ts +0 -4
- package/src/constants/order.js +0 -8
- package/src/constants/order.ts +0 -4
- package/src/constants/role-type.d.ts +0 -4
- package/src/constants/role-type.js +0 -8
- package/src/constants/role-type.ts +0 -4
- package/src/constants/token-type.d.ts +0 -4
- package/src/constants/token-type.js +0 -8
- package/src/constants/token-type.ts +0 -4
- package/src/decorators/api-page-ok-response.decorator.d.ts +0 -5
- package/src/decorators/api-page-ok-response.decorator.js +0 -25
- package/src/decorators/api-page-ok-response.decorator.ts +0 -31
- package/src/decorators/auth-user.decorator.d.ts +0 -1
- package/src/decorators/auth-user.decorator.js +0 -15
- package/src/decorators/auth-user.decorator.ts +0 -16
- package/src/decorators/controller.decorator.d.ts +0 -1
- package/src/decorators/controller.decorator.js +0 -34
- package/src/decorators/controller.decorator.ts +0 -8
- package/src/decorators/field.decorators.d.ts +0 -71
- package/src/decorators/field.decorators.js +0 -455
- package/src/decorators/field.decorators.ts +0 -773
- package/src/decorators/http.decorators.d.ts +0 -3
- package/src/decorators/http.decorators.js +0 -8
- package/src/decorators/http.decorators.ts +0 -10
- package/src/decorators/index.d.ts +0 -12
- package/src/decorators/index.js +0 -28
- package/src/decorators/index.ts +0 -12
- package/src/decorators/omni-auth.decorator.d.ts +0 -8
- package/src/decorators/omni-auth.decorator.js +0 -60
- package/src/decorators/omni-auth.decorator.ts +0 -46
- package/src/decorators/operation.decorator.d.ts +0 -1
- package/src/decorators/operation.decorator.js +0 -6
- package/src/decorators/operation.decorator.ts +0 -4
- package/src/decorators/property.decorators.d.ts +0 -15
- package/src/decorators/property.decorators.js +0 -36
- package/src/decorators/property.decorators.ts +0 -62
- package/src/decorators/public-route.decorator.d.ts +0 -3
- package/src/decorators/public-route.decorator.js +0 -8
- package/src/decorators/public-route.decorator.ts +0 -8
- package/src/decorators/swagger.schema.d.ts +0 -5
- package/src/decorators/swagger.schema.js +0 -82
- package/src/decorators/swagger.schema.ts +0 -117
- package/src/decorators/timestamp-column.decorator.d.ts +0 -1
- package/src/decorators/timestamp-column.decorator.js +0 -28
- package/src/decorators/timestamp-column.decorator.ts +0 -29
- package/src/decorators/transform.decorators.d.ts +0 -35
- package/src/decorators/transform.decorators.js +0 -122
- package/src/decorators/transform.decorators.ts +0 -147
- package/src/decorators/translate.decorator.d.ts +0 -5
- package/src/decorators/translate.decorator.js +0 -18
- package/src/decorators/translate.decorator.ts +0 -19
- package/src/decorators/use-dto.decorator.d.ts +0 -4
- package/src/decorators/use-dto.decorator.js +0 -9
- package/src/decorators/use-dto.decorator.ts +0 -11
- package/src/decorators/user-check.decorator.d.ts +0 -6
- package/src/decorators/user-check.decorator.js +0 -44
- package/src/decorators/user-check.decorator.ts +0 -30
- package/src/decorators/user.decorator.d.ts +0 -8
- package/src/decorators/user.decorator.js +0 -62
- package/src/decorators/user.decorator.ts +0 -48
- package/src/decorators/user_auth.decorator.d.ts +0 -1
- package/src/decorators/user_auth.decorator.js +0 -16
- package/src/decorators/user_auth.decorator.ts +0 -15
- package/src/decorators/validator.decorators.d.ts +0 -10
- package/src/decorators/validator.decorators.js +0 -59
- package/src/decorators/validator.decorators.ts +0 -78
- package/src/exceptions/file-not-image.exception.d.ts +0 -4
- package/src/exceptions/file-not-image.exception.js +0 -10
- package/src/exceptions/file-not-image.exception.ts +0 -7
- package/src/exceptions/index.d.ts +0 -2
- package/src/exceptions/index.js +0 -18
- package/src/exceptions/index.ts +0 -2
- package/src/exceptions/page-type.exception.d.ts +0 -4
- package/src/exceptions/page-type.exception.js +0 -10
- package/src/exceptions/page-type.exception.ts +0 -7
- package/src/exceptions/user-not-found.exception.d.ts +0 -4
- package/src/exceptions/user-not-found.exception.js +0 -10
- package/src/exceptions/user-not-found.exception.ts +0 -7
- package/src/filters/bad-request.filter.d.ts +0 -5
- package/src/filters/bad-request.filter.js +0 -104
- package/src/filters/bad-request.filter.ts +0 -67
- package/src/filters/constraint-errors.d.ts +0 -1
- package/src/filters/constraint-errors.js +0 -7
- package/src/filters/constraint-errors.ts +0 -5
- package/src/filters/index.d.ts +0 -3
- package/src/filters/index.js +0 -19
- package/src/filters/index.ts +0 -3
- package/src/filters/query-failed.filter.d.ts +0 -10
- package/src/filters/query-failed.filter.js +0 -81
- package/src/filters/query-failed.filter.ts +0 -32
- package/src/health-checker/health-checker.controller.d.ts +0 -15
- package/src/health-checker/health-checker.controller.js +0 -104
- package/src/health-checker/health-checker.controller.ts +0 -51
- package/src/health-checker/health-checker.module.d.ts +0 -2
- package/src/health-checker/health-checker.module.js +0 -69
- package/src/health-checker/health-checker.module.ts +0 -13
- package/src/health-checker/health-indicators/service.indicator.d.ts +0 -8
- package/src/health-checker/health-indicators/service.indicator.js +0 -102
- package/src/health-checker/health-indicators/service.indicator.ts +0 -44
- package/src/helpers/common.helper.d.ts +0 -16
- package/src/helpers/common.helper.js +0 -49
- package/src/helpers/common.helper.ts +0 -49
- package/src/helpers/date.helper.d.ts +0 -10
- package/src/helpers/date.helper.js +0 -81
- package/src/helpers/date.helper.ts +0 -64
- package/src/helpers/excel.helper.d.ts +0 -27
- package/src/helpers/excel.helper.js +0 -338
- package/src/helpers/index.d.ts +0 -3
- package/src/helpers/index.js +0 -19
- package/src/helpers/index.ts +0 -3
- package/src/i18n/en_US/validation.json +0 -38
- package/src/i18n/zh_CN/validation.json +0 -38
- package/src/index.d.ts +0 -11
- package/src/index.js +0 -28
- package/src/index.ts +0 -12
- package/src/interceptors/auth-user.interceptor.d.ts +0 -4
- package/src/interceptors/auth-user.interceptor.js +0 -68
- package/src/interceptors/auth-user.interceptor.ts +0 -20
- package/src/interceptors/index.d.ts +0 -2
- package/src/interceptors/index.js +0 -18
- package/src/interceptors/index.ts +0 -2
- package/src/interceptors/language-interceptor.service.d.ts +0 -6
- package/src/interceptors/language-interceptor.service.js +0 -74
- package/src/interceptors/language-interceptor.service.ts +0 -31
- package/src/interceptors/translation-interceptor.service.d.ts +0 -5
- package/src/interceptors/translation-interceptor.service.js +0 -83
- package/src/interceptors/translation-interceptor.service.ts +0 -43
- package/src/interfaces/IApiFile.d.ts +0 -4
- package/src/interfaces/IApiFile.js +0 -2
- package/src/interfaces/IApiFile.ts +0 -4
- package/src/interfaces/IFile.d.ts +0 -9
- package/src/interfaces/IFile.js +0 -2
- package/src/interfaces/IFile.ts +0 -8
- package/src/interfaces/ITranslationDecoratorInterface.d.ts +0 -3
- package/src/interfaces/ITranslationDecoratorInterface.js +0 -2
- package/src/interfaces/ITranslationDecoratorInterface.ts +0 -3
- package/src/interfaces/index.d.ts +0 -3
- package/src/interfaces/index.js +0 -19
- package/src/interfaces/index.ts +0 -3
- package/src/interfaces/response.d.ts +0 -25
- package/src/interfaces/response.js +0 -2
- package/src/interfaces/response.ts +0 -37
- package/src/middlewares/index.d.ts +0 -3
- package/src/middlewares/index.js +0 -19
- package/src/middlewares/index.ts +0 -3
- package/src/middlewares/omni-auth.middleware.d.ts +0 -1
- package/src/middlewares/omni-auth.middleware.js +0 -13
- package/src/middlewares/omni-auth.middleware.ts +0 -10
- package/src/middlewares/powerby.middleware.d.ts +0 -1
- package/src/middlewares/powerby.middleware.js +0 -10
- package/src/middlewares/powerby.middleware.ts +0 -6
- package/src/middlewares/request-id.middleware.d.ts +0 -7
- package/src/middlewares/request-id.middleware.js +0 -22
- package/src/middlewares/request-id.middleware.ts +0 -28
- package/src/providers/context.provider.d.ts +0 -32
- package/src/providers/context.provider.js +0 -73
- package/src/providers/context.provider.ts +0 -98
- package/src/providers/generator.provider.d.ts +0 -13
- package/src/providers/generator.provider.js +0 -54
- package/src/providers/generator.provider.ts +0 -66
- package/src/providers/index.d.ts +0 -2
- package/src/providers/index.js +0 -18
- package/src/providers/index.ts +0 -2
- package/src/setup/bootstrap.setup.d.ts +0 -5
- package/src/setup/bootstrap.setup.js +0 -138
- package/src/setup/bootstrap.setup.ts +0 -139
- package/src/setup/index.d.ts +0 -1
- package/src/setup/index.js +0 -17
- package/src/setup/index.ts +0 -1
- package/src/setup/microservices.setup.js +0 -55
- package/src/setup-swagger.d.ts +0 -2
- package/src/setup-swagger.js +0 -62
- package/src/setup-swagger.ts +0 -67
- package/src/shared/index.d.ts +0 -2
- package/src/shared/index.js +0 -18
- package/src/shared/index.ts +0 -2
- package/src/shared/serviceRegistryModule.d.ts +0 -2
- package/src/shared/serviceRegistryModule.js +0 -176
- package/src/shared/serviceRegistryModule.ts +0 -110
- package/src/shared/services/api-config.service.d.ts +0 -73
- package/src/shared/services/api-config.service.js +0 -335
- package/src/shared/services/api-config.service.ts +0 -319
- package/src/shared/services/aws-s3.service.d.ts +0 -10
- package/src/shared/services/aws-s3.service.js +0 -96
- package/src/shared/services/aws-s3.service.ts +0 -39
- package/src/shared/services/generator.service.d.ts +0 -4
- package/src/shared/services/generator.service.js +0 -67
- package/src/shared/services/generator.service.ts +0 -13
- package/src/shared/services/index.d.ts +0 -5
- package/src/shared/services/index.js +0 -21
- package/src/shared/services/index.ts +0 -5
- package/src/shared/services/translation.service.d.ts +0 -9
- package/src/shared/services/translation.service.js +0 -109
- package/src/shared/services/translation.service.ts +0 -59
- package/src/shared/services/validator.service.d.ts +0 -3
- package/src/shared/services/validator.service.js +0 -64
- package/src/shared/services/validator.service.ts +0 -10
- package/src/snake-naming.strategy.d.ts +0 -11
- package/src/snake-naming.strategy.js +0 -37
- package/src/snake-naming.strategy.ts +0 -64
- package/src/types.d.ts +0 -9
- package/src/types.js +0 -2
- package/src/types.ts +0 -44
- package/src/validators/file-mimetype.validator.d.ts +0 -13
- package/src/validators/file-mimetype.validator.js +0 -21
- package/src/validators/file-mimetype.validator.ts +0 -34
- package/src/validators/index.d.ts +0 -3
- package/src/validators/index.js +0 -19
- package/src/validators/index.ts +0 -3
- package/src/validators/is-exists.validator.d.ts +0 -18
- package/src/validators/is-exists.validator.js +0 -99
- package/src/validators/is-exists.validator.ts +0 -60
- package/src/validators/is-unique.validator.d.ts +0 -17
- package/src/validators/is-unique.validator.js +0 -131
- package/src/validators/is-unique.validator.ts +0 -93
- package/src/validators/phone-country-code.validator.d.ts +0 -2
- package/src/validators/phone-country-code.validator.js +0 -30
- package/src/validators/phone-country-code.validator.ts +0 -36
- package/src/validators/same-as.validator.d.ts +0 -2
- package/src/validators/same-as.validator.js +0 -25
- package/src/validators/same-as.validator.ts +0 -27
- package/src/validators/skip-empty.validator.d.ts +0 -6
- package/src/validators/skip-empty.validator.js +0 -23
- package/src/validators/skip-empty.validator.ts +0 -25
- package/tsconfig.json +0 -21
- package/tsconfig.lib.json +0 -16
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import type { ValidationOptions } from 'class-validator';
|
|
2
|
-
import {
|
|
3
|
-
IsPhoneNumber as isPhoneNumber,
|
|
4
|
-
registerDecorator,
|
|
5
|
-
ValidateIf,
|
|
6
|
-
} from 'class-validator';
|
|
7
|
-
import { isString } from 'lodash';
|
|
8
|
-
|
|
9
|
-
export function IsPassword(
|
|
10
|
-
validationOptions?: ValidationOptions,
|
|
11
|
-
): PropertyDecorator {
|
|
12
|
-
return (object, propertyName: string) => {
|
|
13
|
-
registerDecorator({
|
|
14
|
-
propertyName,
|
|
15
|
-
name: 'isPassword',
|
|
16
|
-
target: object.constructor,
|
|
17
|
-
constraints: [],
|
|
18
|
-
options: validationOptions,
|
|
19
|
-
validator: {
|
|
20
|
-
validate(value: string) {
|
|
21
|
-
return /^[\d!#$%&*@A-Z^a-z]*$/.test(value);
|
|
22
|
-
},
|
|
23
|
-
},
|
|
24
|
-
});
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export function IsPhoneNumber(
|
|
29
|
-
validationOptions?: ValidationOptions & {
|
|
30
|
-
region?: Parameters<typeof isPhoneNumber>[0];
|
|
31
|
-
},
|
|
32
|
-
): PropertyDecorator {
|
|
33
|
-
return isPhoneNumber(validationOptions?.region, {
|
|
34
|
-
message: 'error.phoneNumber',
|
|
35
|
-
...validationOptions,
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export function IsTmpKey(
|
|
40
|
-
validationOptions?: ValidationOptions,
|
|
41
|
-
): PropertyDecorator {
|
|
42
|
-
return (object, propertyName: string) => {
|
|
43
|
-
registerDecorator({
|
|
44
|
-
propertyName,
|
|
45
|
-
name: 'tmpKey',
|
|
46
|
-
target: object.constructor,
|
|
47
|
-
options: validationOptions,
|
|
48
|
-
validator: {
|
|
49
|
-
validate(value: string): boolean {
|
|
50
|
-
return isString(value) && /^tmp\//.test(value);
|
|
51
|
-
},
|
|
52
|
-
defaultMessage(): string {
|
|
53
|
-
return 'error.invalidTmpKey';
|
|
54
|
-
},
|
|
55
|
-
},
|
|
56
|
-
});
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
export function IsUndefinable(options?: ValidationOptions): PropertyDecorator {
|
|
61
|
-
return ValidateIf((obj, value) => value !== undefined, options);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
export function IsEmptyable(options?: ValidationOptions): PropertyDecorator {
|
|
65
|
-
return ValidateIf(
|
|
66
|
-
(obj, value) =>
|
|
67
|
-
!(
|
|
68
|
-
value === null ||
|
|
69
|
-
value === undefined ||
|
|
70
|
-
(isString(value) && value.trim() === '')
|
|
71
|
-
),
|
|
72
|
-
options,
|
|
73
|
-
);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
export function IsNullable(options?: ValidationOptions): PropertyDecorator {
|
|
77
|
-
return ValidateIf((obj, value) => value !== null, options);
|
|
78
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.FileNotImageException = void 0;
|
|
4
|
-
const common_1 = require("@nestjs/common");
|
|
5
|
-
class FileNotImageException extends common_1.BadRequestException {
|
|
6
|
-
constructor(error) {
|
|
7
|
-
super('error.fileNotImage', error);
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
exports.FileNotImageException = FileNotImageException;
|
package/src/exceptions/index.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
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("./file-not-image.exception"), exports);
|
|
18
|
-
__exportStar(require("./user-not-found.exception"), exports);
|
package/src/exceptions/index.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PageTypeException = void 0;
|
|
4
|
-
const common_1 = require("@nestjs/common");
|
|
5
|
-
class PageTypeException extends common_1.BadRequestException {
|
|
6
|
-
constructor() {
|
|
7
|
-
super('error.pageType');
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
exports.PageTypeException = PageTypeException;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.UserNotFoundException = void 0;
|
|
4
|
-
const common_1 = require("@nestjs/common");
|
|
5
|
-
class UserNotFoundException extends common_1.NotFoundException {
|
|
6
|
-
constructor(error) {
|
|
7
|
-
super('error.userNotFound', error);
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
exports.UserNotFoundException = UserNotFoundException;
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
3
|
-
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
|
4
|
-
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
5
|
-
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
|
6
|
-
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
|
7
|
-
var _, done = false;
|
|
8
|
-
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
9
|
-
var context = {};
|
|
10
|
-
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
|
11
|
-
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
|
12
|
-
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
|
13
|
-
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
|
14
|
-
if (kind === "accessor") {
|
|
15
|
-
if (result === void 0) continue;
|
|
16
|
-
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
|
17
|
-
if (_ = accept(result.get)) descriptor.get = _;
|
|
18
|
-
if (_ = accept(result.set)) descriptor.set = _;
|
|
19
|
-
if (_ = accept(result.init)) initializers.unshift(_);
|
|
20
|
-
}
|
|
21
|
-
else if (_ = accept(result)) {
|
|
22
|
-
if (kind === "field") initializers.unshift(_);
|
|
23
|
-
else descriptor[key] = _;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
27
|
-
done = true;
|
|
28
|
-
};
|
|
29
|
-
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
|
30
|
-
var useValue = arguments.length > 2;
|
|
31
|
-
for (var i = 0; i < initializers.length; i++) {
|
|
32
|
-
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
33
|
-
}
|
|
34
|
-
return useValue ? value : void 0;
|
|
35
|
-
};
|
|
36
|
-
var __setFunctionName = (this && this.__setFunctionName) || function (f, name, prefix) {
|
|
37
|
-
if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
|
|
38
|
-
return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
|
|
39
|
-
};
|
|
40
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
|
-
exports.HttpExceptionFilter = void 0;
|
|
42
|
-
const common_1 = require("@nestjs/common");
|
|
43
|
-
const typeorm_1 = require("typeorm");
|
|
44
|
-
const nestjs_i18n_1 = require("nestjs-i18n");
|
|
45
|
-
let HttpExceptionFilter = (() => {
|
|
46
|
-
let _classDecorators = [(0, common_1.Catch)()];
|
|
47
|
-
let _classDescriptor;
|
|
48
|
-
let _classExtraInitializers = [];
|
|
49
|
-
let _classThis;
|
|
50
|
-
var HttpExceptionFilter = _classThis = class {
|
|
51
|
-
catch(exception, host) {
|
|
52
|
-
const i18n = nestjs_i18n_1.I18nContext.current(host);
|
|
53
|
-
const ctx = host.switchToHttp();
|
|
54
|
-
const response = ctx.getResponse();
|
|
55
|
-
const request = ctx.getRequest();
|
|
56
|
-
let statusCode = exception instanceof common_1.HttpException ? exception.getStatus() : 500;
|
|
57
|
-
let error = exception instanceof common_1.HttpException
|
|
58
|
-
? exception.message
|
|
59
|
-
: 'Internal server error';
|
|
60
|
-
if (exception instanceof typeorm_1.EntityNotFoundError) {
|
|
61
|
-
statusCode = 404;
|
|
62
|
-
error = 'Entity not found';
|
|
63
|
-
}
|
|
64
|
-
if (statusCode === 500) {
|
|
65
|
-
console.error(exception);
|
|
66
|
-
}
|
|
67
|
-
const getFirstError = (error, property = '') => {
|
|
68
|
-
var _a;
|
|
69
|
-
if (((_a = error === null || error === void 0 ? void 0 : error.children) === null || _a === void 0 ? void 0 : _a.length) > 0) {
|
|
70
|
-
const firstError = error.children[0];
|
|
71
|
-
firstError['property'] = `${property}.${firstError['property']}`;
|
|
72
|
-
return getFirstError(firstError, firstError.property);
|
|
73
|
-
}
|
|
74
|
-
return error;
|
|
75
|
-
};
|
|
76
|
-
if (exception instanceof nestjs_i18n_1.I18nValidationException) {
|
|
77
|
-
const firstErros = getFirstError(exception.errors[0], exception.errors[0].property);
|
|
78
|
-
const constraint = Object.values(firstErros.constraints)[0];
|
|
79
|
-
const [translationKey, argsString] = constraint.split('|');
|
|
80
|
-
const args = !!argsString ? JSON.parse(argsString) : {};
|
|
81
|
-
error = i18n.translate(translationKey, {
|
|
82
|
-
args: Object.assign({ property: firstErros.property, value: firstErros.value, constraints: firstErros.constraints }, args),
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
const parseJson = {
|
|
86
|
-
code: statusCode,
|
|
87
|
-
msg: error,
|
|
88
|
-
requestId: request.id,
|
|
89
|
-
timestamp: new Date().toISOString(),
|
|
90
|
-
};
|
|
91
|
-
return response.status(200).json(parseJson);
|
|
92
|
-
}
|
|
93
|
-
};
|
|
94
|
-
__setFunctionName(_classThis, "HttpExceptionFilter");
|
|
95
|
-
(() => {
|
|
96
|
-
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
|
|
97
|
-
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
98
|
-
HttpExceptionFilter = _classThis = _classDescriptor.value;
|
|
99
|
-
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
100
|
-
__runInitializers(_classThis, _classExtraInitializers);
|
|
101
|
-
})();
|
|
102
|
-
return HttpExceptionFilter = _classThis;
|
|
103
|
-
})();
|
|
104
|
-
exports.HttpExceptionFilter = HttpExceptionFilter;
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import type { ArgumentsHost, ExceptionFilter } from '@nestjs/common';
|
|
2
|
-
import { Catch, HttpException } from '@nestjs/common';
|
|
3
|
-
import { Request, Response } from 'express';
|
|
4
|
-
import { EntityNotFoundError } from 'typeorm';
|
|
5
|
-
import { I18nContext, I18nValidationException } from 'nestjs-i18n';
|
|
6
|
-
|
|
7
|
-
@Catch()
|
|
8
|
-
export class HttpExceptionFilter implements ExceptionFilter {
|
|
9
|
-
catch(exception, host: ArgumentsHost) {
|
|
10
|
-
const i18n = I18nContext.current(host);
|
|
11
|
-
const ctx = host.switchToHttp();
|
|
12
|
-
const response: Response = ctx.getResponse();
|
|
13
|
-
const request: Request = ctx.getRequest();
|
|
14
|
-
let statusCode =
|
|
15
|
-
exception instanceof HttpException ? exception.getStatus() : 500;
|
|
16
|
-
let error =
|
|
17
|
-
exception instanceof HttpException
|
|
18
|
-
? exception.message
|
|
19
|
-
: 'Internal server error';
|
|
20
|
-
|
|
21
|
-
if (exception instanceof EntityNotFoundError) {
|
|
22
|
-
statusCode = 404;
|
|
23
|
-
error = 'Entity not found';
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
if (statusCode === 500) {
|
|
27
|
-
console.error(exception);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
const getFirstError = (error, property = '') => {
|
|
31
|
-
if (error?.children?.length > 0) {
|
|
32
|
-
const firstError = error.children[0];
|
|
33
|
-
firstError['property'] = `${property}.${firstError['property']}`;
|
|
34
|
-
return getFirstError(firstError, firstError.property);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
return error;
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
if (exception instanceof I18nValidationException) {
|
|
41
|
-
const firstErros = getFirstError(
|
|
42
|
-
exception.errors[0],
|
|
43
|
-
exception.errors[0].property,
|
|
44
|
-
);
|
|
45
|
-
const constraint = Object.values(firstErros.constraints)[0] as string;
|
|
46
|
-
const [translationKey, argsString] = constraint.split('|');
|
|
47
|
-
const args = !!argsString ? JSON.parse(argsString) : {};
|
|
48
|
-
error = i18n.translate(translationKey, {
|
|
49
|
-
args: {
|
|
50
|
-
property: firstErros.property,
|
|
51
|
-
value: firstErros.value,
|
|
52
|
-
constraints: firstErros.constraints,
|
|
53
|
-
...args,
|
|
54
|
-
},
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
const parseJson = {
|
|
59
|
-
code: statusCode,
|
|
60
|
-
msg: error,
|
|
61
|
-
requestId: request.id,
|
|
62
|
-
timestamp: new Date().toISOString(),
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
return response.status(200).json(parseJson);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const constraintErrors: Record<string, string>;
|
package/src/filters/index.d.ts
DELETED
package/src/filters/index.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
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("./bad-request.filter"), exports);
|
|
18
|
-
__exportStar(require("./constraint-errors"), exports);
|
|
19
|
-
__exportStar(require("./query-failed.filter"), exports);
|
package/src/filters/index.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { ArgumentsHost, ExceptionFilter } from '@nestjs/common';
|
|
2
|
-
import { Reflector } from '@nestjs/core';
|
|
3
|
-
import { QueryFailedError } from 'typeorm';
|
|
4
|
-
export declare class QueryFailedFilter implements ExceptionFilter<QueryFailedError> {
|
|
5
|
-
reflector: Reflector;
|
|
6
|
-
constructor(reflector: Reflector);
|
|
7
|
-
catch(exception: QueryFailedError & {
|
|
8
|
-
constraint?: string;
|
|
9
|
-
}, host: ArgumentsHost): void;
|
|
10
|
-
}
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
3
|
-
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
|
4
|
-
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
5
|
-
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
|
6
|
-
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
|
7
|
-
var _, done = false;
|
|
8
|
-
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
9
|
-
var context = {};
|
|
10
|
-
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
|
11
|
-
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
|
12
|
-
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
|
13
|
-
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
|
14
|
-
if (kind === "accessor") {
|
|
15
|
-
if (result === void 0) continue;
|
|
16
|
-
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
|
17
|
-
if (_ = accept(result.get)) descriptor.get = _;
|
|
18
|
-
if (_ = accept(result.set)) descriptor.set = _;
|
|
19
|
-
if (_ = accept(result.init)) initializers.unshift(_);
|
|
20
|
-
}
|
|
21
|
-
else if (_ = accept(result)) {
|
|
22
|
-
if (kind === "field") initializers.unshift(_);
|
|
23
|
-
else descriptor[key] = _;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
27
|
-
done = true;
|
|
28
|
-
};
|
|
29
|
-
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
|
30
|
-
var useValue = arguments.length > 2;
|
|
31
|
-
for (var i = 0; i < initializers.length; i++) {
|
|
32
|
-
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
33
|
-
}
|
|
34
|
-
return useValue ? value : void 0;
|
|
35
|
-
};
|
|
36
|
-
var __setFunctionName = (this && this.__setFunctionName) || function (f, name, prefix) {
|
|
37
|
-
if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
|
|
38
|
-
return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
|
|
39
|
-
};
|
|
40
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
|
-
exports.QueryFailedFilter = void 0;
|
|
42
|
-
const common_1 = require("@nestjs/common");
|
|
43
|
-
const http_1 = require("http");
|
|
44
|
-
const typeorm_1 = require("typeorm");
|
|
45
|
-
const constraint_errors_1 = require("./constraint-errors");
|
|
46
|
-
let QueryFailedFilter = (() => {
|
|
47
|
-
let _classDecorators = [(0, common_1.Catch)(typeorm_1.QueryFailedError)];
|
|
48
|
-
let _classDescriptor;
|
|
49
|
-
let _classExtraInitializers = [];
|
|
50
|
-
let _classThis;
|
|
51
|
-
var QueryFailedFilter = _classThis = class {
|
|
52
|
-
constructor(reflector) {
|
|
53
|
-
this.reflector = reflector;
|
|
54
|
-
}
|
|
55
|
-
catch(exception, host) {
|
|
56
|
-
var _a;
|
|
57
|
-
const ctx = host.switchToHttp();
|
|
58
|
-
const response = ctx.getResponse();
|
|
59
|
-
const status = ((_a = exception.constraint) === null || _a === void 0 ? void 0 : _a.startsWith('UQ'))
|
|
60
|
-
? common_1.HttpStatus.CONFLICT
|
|
61
|
-
: common_1.HttpStatus.INTERNAL_SERVER_ERROR;
|
|
62
|
-
response.status(status).json({
|
|
63
|
-
code: status,
|
|
64
|
-
error: http_1.STATUS_CODES[status],
|
|
65
|
-
msg: exception.constraint
|
|
66
|
-
? constraint_errors_1.constraintErrors[exception.constraint]
|
|
67
|
-
: undefined,
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
};
|
|
71
|
-
__setFunctionName(_classThis, "QueryFailedFilter");
|
|
72
|
-
(() => {
|
|
73
|
-
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
|
|
74
|
-
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
75
|
-
QueryFailedFilter = _classThis = _classDescriptor.value;
|
|
76
|
-
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
77
|
-
__runInitializers(_classThis, _classExtraInitializers);
|
|
78
|
-
})();
|
|
79
|
-
return QueryFailedFilter = _classThis;
|
|
80
|
-
})();
|
|
81
|
-
exports.QueryFailedFilter = QueryFailedFilter;
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import type { ArgumentsHost, ExceptionFilter } from '@nestjs/common';
|
|
2
|
-
import { Catch, HttpStatus } from '@nestjs/common';
|
|
3
|
-
import { Reflector } from '@nestjs/core';
|
|
4
|
-
import { STATUS_CODES } from 'http';
|
|
5
|
-
import { QueryFailedError } from 'typeorm';
|
|
6
|
-
|
|
7
|
-
import { constraintErrors } from './constraint-errors';
|
|
8
|
-
|
|
9
|
-
@Catch(QueryFailedError)
|
|
10
|
-
export class QueryFailedFilter implements ExceptionFilter<QueryFailedError> {
|
|
11
|
-
constructor(public reflector: Reflector) {}
|
|
12
|
-
|
|
13
|
-
catch(
|
|
14
|
-
exception: QueryFailedError & { constraint?: string },
|
|
15
|
-
host: ArgumentsHost,
|
|
16
|
-
) {
|
|
17
|
-
const ctx = host.switchToHttp();
|
|
18
|
-
const response = ctx.getResponse();
|
|
19
|
-
|
|
20
|
-
const status = exception.constraint?.startsWith('UQ')
|
|
21
|
-
? HttpStatus.CONFLICT
|
|
22
|
-
: HttpStatus.INTERNAL_SERVER_ERROR;
|
|
23
|
-
|
|
24
|
-
response.status(status).json({
|
|
25
|
-
code: status,
|
|
26
|
-
error: STATUS_CODES[status],
|
|
27
|
-
msg: exception.constraint
|
|
28
|
-
? constraintErrors[exception.constraint]
|
|
29
|
-
: undefined,
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { HealthCheckResult } from '@nestjs/terminus';
|
|
2
|
-
import { HealthCheckService, TypeOrmHealthIndicator } from '@nestjs/terminus';
|
|
3
|
-
import { ServiceHealthIndicator } from './health-indicators/service.indicator';
|
|
4
|
-
import { RedisHealthIndicator } from '@liaoliaots/nestjs-redis-health';
|
|
5
|
-
import { ApiConfigService } from '../shared/services';
|
|
6
|
-
export declare class HealthCheckerController {
|
|
7
|
-
private configService;
|
|
8
|
-
private healthCheckService;
|
|
9
|
-
private ormIndicator;
|
|
10
|
-
private serviceIndicator;
|
|
11
|
-
private redisIndicator;
|
|
12
|
-
private readonly redis;
|
|
13
|
-
constructor(configService: ApiConfigService, healthCheckService: HealthCheckService, ormIndicator: TypeOrmHealthIndicator, serviceIndicator: ServiceHealthIndicator, redisIndicator: RedisHealthIndicator);
|
|
14
|
-
check(): Promise<HealthCheckResult>;
|
|
15
|
-
}
|