Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const routeArgs = R.getRouteArgs(this.target, name);
const baseBodyArg = baseRouteArgs[baseKey];
R.setRouteArgs(
{
...routeArgs,
[key]: {
...baseBodyArg,
index: parsedBody.index,
},
},
this.target,
name,
);
/* istanbul ignore else */
if (isEqual(override, 'createManyBase')) {
const paramTypes = R.getRouteArgsTypes(this.targetProto, name);
const metatype = paramTypes[parsedBody.index];
const types = [String, Boolean, Number, Array, Object];
const toCopy =
isIn(metatype, types) || /* istanbul ignore next */ isNil(metatype);
/* istanbul ignore else */
if (toCopy) {
const baseParamTypes = R.getRouteArgsTypes(this.targetProto, override);
const baseMetatype = baseParamTypes[1];
paramTypes.splice(parsedBody.index, 1, baseMetatype);
R.setRouteArgsTypes(paramTypes, this.targetProto, name);
}
}
}
}
setSwaggerResponseOk(name) {
const status = util_1.isEqual(name, 'createManyBase') || util_1.isEqual(name, 'createOneBase')
? common_1.HttpStatus.CREATED
: common_1.HttpStatus.OK;
const isArray = util_1.isEqual(name, 'createManyBase') || util_1.isEqual(name, 'getManyBase');
const metadata = swagger_helper_1.Swagger.getResponseOk(this.targetProto[name]);
const responseOkMeta = swagger_helper_1.Swagger.createReponseOkMeta(status, isArray, this.modelType);
swagger_helper_1.Swagger.setResponseOk(Object.assign({}, metadata, responseOkMeta), this.targetProto[name]);
}
}
setRouteArgsTypes(name) {
if (util_1.isEqual(name, 'createManyBase')) {
const bulkDto = validation_helper_1.Validation.createBulkDto(this.options);
reflection_helper_1.R.setRouteArgsTypes([Object, bulkDto], this.targetProto, name);
}
else if (util_1.isEqual(name, 'createOneBase') ||
util_1.isEqual(name, 'updateOneBase') ||
util_1.isEqual(name, 'replaceOneBase')) {
reflection_helper_1.R.setRouteArgsTypes([Object, this.modelType], this.targetProto, name);
}
else {
reflection_helper_1.R.setRouteArgsTypes([Object], this.targetProto, name);
}
}
setInterceptors(name) {
setRouteArgs(name) {
let rest = {};
const toValidate = [
'createManyBase',
'createOneBase',
'updateOneBase',
'replaceOneBase',
];
if (util_1.isIn(name, toValidate)) {
const group = util_1.isEqual(name, 'updateOneBase') || util_1.isEqual(name, 'replaceOneBase')
? enums_1.CrudValidationGroups.UPDATE
: enums_1.CrudValidationGroups.CREATE;
rest = reflection_helper_1.R.setBodyArg(1, [validation_helper_1.Validation.getValidationPipe(this.options, group)]);
}
reflection_helper_1.R.setRouteArgs(Object.assign({}, reflection_helper_1.R.setParsedRequestArg(0), rest), this.target, name);
}
setRouteArgsTypes(name) {
setRouteArgsTypes(name) {
if (util_1.isEqual(name, 'createManyBase')) {
const bulkDto = validation_helper_1.Validation.createBulkDto(this.options);
reflection_helper_1.R.setRouteArgsTypes([Object, bulkDto], this.targetProto, name);
}
else if (util_1.isEqual(name, 'createOneBase') ||
util_1.isEqual(name, 'updateOneBase') ||
util_1.isEqual(name, 'replaceOneBase')) {
reflection_helper_1.R.setRouteArgsTypes([Object, this.modelType], this.targetProto, name);
}
else {
reflection_helper_1.R.setRouteArgsTypes([Object], this.targetProto, name);
}
}
setInterceptors(name) {
setRouteArgsTypes(name) {
if (util_1.isEqual(name, 'createManyBase')) {
const bulkDto = validation_helper_1.Validation.createBulkDto(this.options);
reflection_helper_1.R.setRouteArgsTypes([Object, bulkDto], this.targetProto, name);
}
else if (util_1.isEqual(name, 'createOneBase') ||
util_1.isEqual(name, 'updateOneBase') ||
util_1.isEqual(name, 'replaceOneBase')) {
reflection_helper_1.R.setRouteArgsTypes([Object, this.modelType], this.targetProto, name);
}
else {
reflection_helper_1.R.setRouteArgsTypes([Object], this.targetProto, name);
}
}
setInterceptors(name) {
const allowed = [
'createManyBase',
'createOneBase',
'updateOneBase',
'replaceOneBase',
];
const withBody = util_1.isIn(override, allowed);
const parsedBody = reflection_helper_1.R.getParsedBody(this.targetProto[name]);
if (withBody && parsedBody) {
const baseKey = `${route_paramtypes_enum_1.RouteParamtypes.BODY}:1`;
const key = `${route_paramtypes_enum_1.RouteParamtypes.BODY}:${parsedBody.index}`;
const baseRouteArgs = reflection_helper_1.R.getRouteArgs(this.target, override);
const routeArgs = reflection_helper_1.R.getRouteArgs(this.target, name);
const baseBodyArg = baseRouteArgs[baseKey];
reflection_helper_1.R.setRouteArgs(Object.assign({}, routeArgs, { [key]: Object.assign({}, baseBodyArg, { index: parsedBody.index }) }), this.target, name);
if (util_1.isEqual(override, 'createManyBase')) {
const paramTypes = reflection_helper_1.R.getRouteArgsTypes(this.targetProto, name);
const metatype = paramTypes[parsedBody.index];
const types = [String, Boolean, Number, Array, Object];
const toCopy = util_1.isIn(metatype, types) || util_1.isNil(metatype);
if (toCopy) {
const baseParamTypes = reflection_helper_1.R.getRouteArgsTypes(this.targetProto, override);
const baseMetatype = baseParamTypes[1];
paramTypes.splice(parsedBody.index, 1, baseMetatype);
reflection_helper_1.R.setRouteArgsTypes(paramTypes, this.targetProto, name);
}
}
}
}
getPrimaryParam() {
const route = routesSchema.find((r) => isEqual(r.name, override));
setSwaggerResponseOk(name) {
const status = util_1.isEqual(name, 'createManyBase') || util_1.isEqual(name, 'createOneBase')
? common_1.HttpStatus.CREATED
: common_1.HttpStatus.OK;
const isArray = util_1.isEqual(name, 'createManyBase') || util_1.isEqual(name, 'getManyBase');
const metadata = swagger_helper_1.Swagger.getResponseOk(this.targetProto[name]);
const responseOkMeta = swagger_helper_1.Swagger.createReponseOkMeta(status, isArray, this.modelType);
swagger_helper_1.Swagger.setResponseOk(Object.assign({}, metadata, responseOkMeta), this.targetProto[name]);
}
}