m
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
import { ApiPropertyOptions } from '@nestjs/swagger';
|
||||
export declare const ApiOptional: (options?: ApiPropertyOptions) => <TFunction extends Function, Y>(target: TFunction | object, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
|
||||
@@ -0,0 +1,13 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.ApiOptional = void 0;
|
||||
const common_1 = require("@nestjs/common");
|
||||
const swagger_1 = require("@nestjs/swagger");
|
||||
const class_validator_1 = require("class-validator");
|
||||
const ApiOptional = (options) => {
|
||||
return (0, common_1.applyDecorators)((0, class_validator_1.ValidateIf)((o, value) => {
|
||||
return typeof value != 'undefined';
|
||||
}), (0, swagger_1.ApiPropertyOptional)(options));
|
||||
};
|
||||
exports.ApiOptional = ApiOptional;
|
||||
//# sourceMappingURL=api_optional.decorator.js.map
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"api_optional.decorator.js","sourceRoot":"","sources":["../../../../src/app/common/decorator/api_optional.decorator.ts"],"names":[],"mappings":";;;AAAA,2CAAiD;AACjD,6CAA0E;AAC1E,qDAA6C;AAOtC,MAAM,WAAW,GAAG,CAAC,OAA4B,EAAE,EAAE;IAC1D,OAAO,IAAA,wBAAe,EACpB,IAAA,4BAAU,EAAC,CAAC,CAAM,EAAE,KAAK,EAAE,EAAE;QAC3B,OAAO,OAAO,KAAK,IAAI,WAAW,CAAC;IACrC,CAAC,CAAC,EACF,IAAA,6BAAmB,EAAC,OAAO,CAAC,CAC7B,CAAC;AACJ,CAAC,CAAC;AAPW,QAAA,WAAW,eAOtB"}
|
||||
@@ -0,0 +1,5 @@
|
||||
import { ModuleMetadata } from '@nestjs/common';
|
||||
export declare const AppModule: (opt: {
|
||||
controllersDir: string;
|
||||
serviceDir: string;
|
||||
}, metadata: ModuleMetadata) => ClassDecorator;
|
||||
@@ -0,0 +1,35 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.AppModule = void 0;
|
||||
const common_1 = require("@nestjs/common");
|
||||
const glob_1 = require("glob");
|
||||
const path_1 = require("path");
|
||||
const AppModule = (opt, metadata) => {
|
||||
const servicePath = (0, path_1.join)(opt.serviceDir, './*.service.{j,t}s');
|
||||
const serviceFiles = glob_1.glob.sync(servicePath);
|
||||
const services = [];
|
||||
serviceFiles.map((file) => {
|
||||
const ms = require(file);
|
||||
for (let k in ms) {
|
||||
const service = ms[k];
|
||||
services.push(service);
|
||||
}
|
||||
});
|
||||
const controllerPath = (0, path_1.join)(opt.controllersDir, './*.controller.{j,t}s');
|
||||
const controllerFiles = glob_1.glob.sync(controllerPath);
|
||||
const controllers = [];
|
||||
controllerFiles.map((file) => {
|
||||
const ms = require(file);
|
||||
for (let k in ms) {
|
||||
const service = ms[k];
|
||||
controllers.push(service);
|
||||
}
|
||||
});
|
||||
return (0, common_1.Module)({
|
||||
...metadata,
|
||||
controllers: [...controllers, ...(metadata.controllers || [])],
|
||||
providers: [...services, ...(metadata.providers || [])],
|
||||
});
|
||||
};
|
||||
exports.AppModule = AppModule;
|
||||
//# sourceMappingURL=app_module.decorator.js.map
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"app_module.decorator.js","sourceRoot":"","sources":["../../../../src/app/common/decorator/app_module.decorator.ts"],"names":[],"mappings":";;;AAKA,2CAAwC;AAExC,+BAA4B;AAC5B,+BAA4B;AAOrB,MAAM,SAAS,GAAG,CACvB,GAAmD,EACnD,QAAwB,EACxB,EAAE;IACF,MAAM,WAAW,GAAG,IAAA,WAAI,EAAC,GAAG,CAAC,UAAU,EAAE,oBAAoB,CAAC,CAAC;IAC/D,MAAM,YAAY,GAAG,WAAI,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IAC5C,MAAM,QAAQ,GAAU,EAAE,CAAC;IAC3B,YAAY,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;QACxB,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;QACzB,KAAK,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC;YACjB,MAAM,OAAO,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC;YACtB,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACzB,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,MAAM,cAAc,GAAG,IAAA,WAAI,EAAC,GAAG,CAAC,cAAc,EAAE,uBAAuB,CAAC,CAAC;IACzE,MAAM,eAAe,GAAG,WAAI,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;IAClD,MAAM,WAAW,GAAU,EAAE,CAAC;IAC9B,eAAe,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;QAC3B,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;QACzB,KAAK,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC;YACjB,MAAM,OAAO,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC;YACtB,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC5B,CAAC;IACH,CAAC,CAAC,CAAC;IACH,OAAO,IAAA,eAAM,EAAC;QACZ,GAAG,QAAQ;QACX,WAAW,EAAE,CAAC,GAAG,WAAW,EAAE,GAAG,CAAC,QAAQ,CAAC,WAAW,IAAI,EAAE,CAAC,CAAC;QAC9D,SAAS,EAAE,CAAC,GAAG,QAAQ,EAAE,GAAG,CAAC,QAAQ,CAAC,SAAS,IAAI,EAAE,CAAC,CAAC;KACxD,CAAC,CAAC;AACL,CAAC,CAAC;AA9BW,QAAA,SAAS,aA8BpB"}
|
||||
@@ -0,0 +1,2 @@
|
||||
import { ValidationOptions } from 'class-validator';
|
||||
export declare function IsEnumNumberString(entity: object, validationOptions?: ValidationOptions): PropertyDecorator;
|
||||
@@ -0,0 +1,28 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.IsEnumNumberString = IsEnumNumberString;
|
||||
const class_validator_1 = require("class-validator");
|
||||
const IS_ENUM_NUMBER_STRING = 'IsEnumNumberString';
|
||||
function validEnumValues(entity) {
|
||||
return Object.entries(entity)
|
||||
.filter(([key]) => isNaN(parseInt(key)))
|
||||
.map(([, value]) => value);
|
||||
}
|
||||
function IsEnumNumberString(entity, validationOptions) {
|
||||
return (0, class_validator_1.ValidateBy)({
|
||||
name: IS_ENUM_NUMBER_STRING,
|
||||
constraints: [entity, validEnumValues(entity)],
|
||||
validator: {
|
||||
validate: (value, args) => {
|
||||
let result = (0, class_validator_1.isEnum)(value, args?.constraints[0]);
|
||||
if (!result && typeof value == 'string') {
|
||||
result = (0, class_validator_1.isEnum)(Number(value), args?.constraints[0]);
|
||||
}
|
||||
return result;
|
||||
},
|
||||
defaultMessage: (0, class_validator_1.buildMessage)((eachPrefix) => eachPrefix +
|
||||
'$property must be one of the following values: $constraint2', validationOptions),
|
||||
},
|
||||
}, validationOptions);
|
||||
}
|
||||
//# sourceMappingURL=is_enum_mumber_string.js.map
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"is_enum_mumber_string.js","sourceRoot":"","sources":["../../../../src/app/common/decorator/is_enum_mumber_string.ts"],"names":[],"mappings":";;AAgBA,gDA2BC;AA3CD,qDAKyB;AAEzB,MAAM,qBAAqB,GAAG,oBAAoB,CAAC;AAEnD,SAAS,eAAe,CAAC,MAAW;IAElC,OAAO,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC;SAC1B,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC;SACvC,GAAG,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,KAAe,CAAC,CAAC;AACzC,CAAC;AAED,SAAgB,kBAAkB,CAChC,MAAc,EACd,iBAAqC;IAErC,OAAO,IAAA,4BAAU,EACf;QACE,IAAI,EAAE,qBAAqB;QAC3B,WAAW,EAAE,CAAC,MAAM,EAAE,eAAe,CAAC,MAAM,CAAC,CAAC;QAC9C,SAAS,EAAE;YACT,QAAQ,EAAE,CAAC,KAAK,EAAE,IAAI,EAAW,EAAE;gBACjC,IAAI,MAAM,GAAG,IAAA,wBAAM,EAAC,KAAK,EAAE,IAAI,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;gBACjD,IAAI,CAAC,MAAM,IAAI,OAAO,KAAK,IAAI,QAAQ,EAAE,CAAC;oBACxC,MAAM,GAAG,IAAA,wBAAM,EAAC,MAAM,CAAC,KAAK,CAAC,EAAE,IAAI,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;gBACvD,CAAC;gBAED,OAAO,MAAM,CAAC;YAChB,CAAC;YACD,cAAc,EAAE,IAAA,8BAAY,EAC1B,CAAC,UAAU,EAAE,EAAE,CACb,UAAU;gBACV,6DAA6D,EAC/D,iBAAiB,CAClB;SACF;KACF,EACD,iBAAiB,CAClB,CAAC;AACJ,CAAC"}
|
||||
@@ -0,0 +1,2 @@
|
||||
import { ValidationOptions } from 'class-validator';
|
||||
export declare function IsNumberOrNumberStr(validationOptions?: ValidationOptions): PropertyDecorator;
|
||||
@@ -0,0 +1,21 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.IsNumberOrNumberStr = IsNumberOrNumberStr;
|
||||
const class_validator_1 = require("class-validator");
|
||||
const lodash_1 = require("lodash");
|
||||
const IS_ENUM_NUMBER_STRING = 'IsNumberOrNumberStr';
|
||||
function IsNumberOrNumberStr(validationOptions) {
|
||||
return (0, class_validator_1.ValidateBy)({
|
||||
name: IS_ENUM_NUMBER_STRING,
|
||||
validator: {
|
||||
validate: (value) => {
|
||||
if (typeof value == 'number') {
|
||||
return (0, lodash_1.isNumber)(value);
|
||||
}
|
||||
return (0, class_validator_1.isNumberString)(value);
|
||||
},
|
||||
defaultMessage: (0, class_validator_1.buildMessage)((eachPrefix) => eachPrefix + '$property must be a number or number string', validationOptions),
|
||||
},
|
||||
}, validationOptions);
|
||||
}
|
||||
//# sourceMappingURL=is_number_or_number_str.js.map
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"is_number_or_number_str.js","sourceRoot":"","sources":["../../../../src/app/common/decorator/is_number_or_number_str.ts"],"names":[],"mappings":";;AAUA,kDAuBC;AAjCD,qDAKyB;AACzB,mCAAkC;AAElC,MAAM,qBAAqB,GAAG,qBAAqB,CAAC;AAEpD,SAAgB,mBAAmB,CACjC,iBAAqC;IAErC,OAAO,IAAA,4BAAU,EACf;QACE,IAAI,EAAE,qBAAqB;QAC3B,SAAS,EAAE;YACT,QAAQ,EAAE,CAAC,KAAK,EAAW,EAAE;gBAC3B,IAAI,OAAO,KAAK,IAAI,QAAQ,EAAE,CAAC;oBAC7B,OAAO,IAAA,iBAAQ,EAAC,KAAK,CAAC,CAAC;gBACzB,CAAC;gBAED,OAAO,IAAA,gCAAc,EAAC,KAAK,CAAC,CAAC;YAC/B,CAAC;YACD,cAAc,EAAE,IAAA,8BAAY,EAC1B,CAAC,UAAU,EAAE,EAAE,CACb,UAAU,GAAG,6CAA6C,EAC5D,iBAAiB,CAClB;SACF;KACF,EACD,iBAAiB,CAClB,CAAC;AACJ,CAAC"}
|
||||
@@ -0,0 +1,6 @@
|
||||
import { ValidationOptions } from 'class-validator';
|
||||
export interface ValidationJsonOptions extends ValidationOptions {
|
||||
validateField?(key: string, value: any): true | string;
|
||||
validateArray?(index: number, value: any): true | string;
|
||||
}
|
||||
export declare function IsValidAndTransformJson(validationOptions?: ValidationJsonOptions): (object: object, propertyName: string) => void;
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.IsValidAndTransformJson = IsValidAndTransformJson;
|
||||
const class_validator_1 = require("class-validator");
|
||||
function IsValidAndTransformJson(validationOptions) {
|
||||
return function (object, propertyName) {
|
||||
let errMessage = '';
|
||||
(0, class_validator_1.registerDecorator)({
|
||||
target: object.constructor,
|
||||
propertyName: propertyName,
|
||||
options: validationOptions,
|
||||
constraints: [],
|
||||
validator: {
|
||||
validate(value, args) {
|
||||
try {
|
||||
const json = JSON.parse(value);
|
||||
if (Array.isArray(json)) {
|
||||
if (validationOptions?.validateArray) {
|
||||
for (let i = 0; i < json.length; i++) {
|
||||
const result = validationOptions.validateArray(i, json[i]);
|
||||
if (typeof result == 'string') {
|
||||
errMessage = args.property + `->${result}`;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (validationOptions?.validateField) {
|
||||
const keys = Object.keys(json);
|
||||
for (let i = 0; i < keys.length; i++) {
|
||||
const key = keys[i];
|
||||
const result = validationOptions.validateField(key, json[key]);
|
||||
if (typeof result == 'string') {
|
||||
errMessage = args.property + `->${result}`;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
args.object[args.property] = json;
|
||||
return true;
|
||||
}
|
||||
catch (e) {
|
||||
errMessage = args.property + `->${e}`;
|
||||
return false;
|
||||
}
|
||||
},
|
||||
defaultMessage() {
|
||||
return errMessage;
|
||||
},
|
||||
},
|
||||
});
|
||||
};
|
||||
}
|
||||
//# sourceMappingURL=is_valid_json.js.map
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"is_valid_json.js","sourceRoot":"","sources":["../../../../src/app/common/decorator/is_valid_json.ts"],"names":[],"mappings":";;AAWA,0DAsDC;AAjED,qDAIyB;AAOzB,SAAgB,uBAAuB,CACrC,iBAAyC;IAEzC,OAAO,UAAU,MAAc,EAAE,YAAoB;QACnD,IAAI,UAAU,GAAG,EAAE,CAAC;QACpB,IAAA,mCAAiB,EAAC;YAChB,MAAM,EAAE,MAAM,CAAC,WAAW;YAC1B,YAAY,EAAE,YAAY;YAC1B,OAAO,EAAE,iBAAiB;YAC1B,WAAW,EAAE,EAAE;YACf,SAAS,EAAE;gBACT,QAAQ,CAAC,KAAa,EAAE,IAAyB;oBAC/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CAAC;wBAClC,OAAO,IAAI,CAAC;oBACd,CAAC;oBAAC,OAAO,CAAC,EAAE,CAAC;wBACX,UAAU,GAAG,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC,EAAE,CAAC;wBACtC,OAAO,KAAK,CAAC;oBACf,CAAC;gBACH,CAAC;gBACD,cAAc;oBACZ,OAAO,UAAU,CAAC;gBACpB,CAAC;aACF;SACF,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC"}
|
||||
@@ -0,0 +1,4 @@
|
||||
import { ExecutionContext } from '@nestjs/common';
|
||||
import { Reflector } from '@nestjs/core';
|
||||
export declare const AuthPublic: () => import("@nestjs/common").CustomDecorator<string>;
|
||||
export declare const isAuthPublic: (reflector: Reflector, context: ExecutionContext) => boolean;
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.isAuthPublic = exports.AuthPublic = void 0;
|
||||
const common_1 = require("@nestjs/common");
|
||||
const IS_AUTH_PUBLIC_KEY = 'isAuthPublic';
|
||||
const AuthPublic = () => (0, common_1.SetMetadata)(IS_AUTH_PUBLIC_KEY, true);
|
||||
exports.AuthPublic = AuthPublic;
|
||||
const isAuthPublic = (reflector, context) => {
|
||||
return !!reflector.getAllAndOverride(IS_AUTH_PUBLIC_KEY, [
|
||||
context.getHandler(),
|
||||
context.getClass(),
|
||||
]);
|
||||
};
|
||||
exports.isAuthPublic = isAuthPublic;
|
||||
//# sourceMappingURL=public.decorator.js.map
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"public.decorator.js","sourceRoot":"","sources":["../../../../src/app/common/decorator/public.decorator.ts"],"names":[],"mappings":";;;AAAA,2CAA+D;AAK/D,MAAM,kBAAkB,GAAG,cAAc,CAAC;AACnC,MAAM,UAAU,GAAG,GAAG,EAAE,CAAC,IAAA,oBAAW,EAAC,kBAAkB,EAAE,IAAI,CAAC,CAAC;AAAzD,QAAA,UAAU,cAA+C;AAE/D,MAAM,YAAY,GAAG,CAC1B,SAAoB,EACpB,OAAyB,EACzB,EAAE;IACF,OAAO,CAAC,CAAC,SAAS,CAAC,iBAAiB,CAAU,kBAAkB,EAAE;QAChE,OAAO,CAAC,UAAU,EAAE;QACpB,OAAO,CAAC,QAAQ,EAAE;KACnB,CAAC,CAAC;AACL,CAAC,CAAC;AARW,QAAA,YAAY,gBAQvB"}
|
||||
Reference in New Issue
Block a user