Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
private mergeOptions() {
// merge auth config
const authOptions = R.getCrudAuthOptions(this.target);
this.options.auth = isObjectFull(authOptions) ? authOptions : {};
this.options.auth.property =
this.options.auth.property || CrudConfigService.config.auth.property;
// merge query config
const query = isObjectFull(this.options.query) ? this.options.query : {};
this.options.query = { ...CrudConfigService.config.query, ...query };
// merge routes config
const routes = isObjectFull(this.options.routes) ? this.options.routes : {};
this.options.routes = deepmerge(CrudConfigService.config.routes, routes, {
arrayMerge: (a, b, c) => b,
});
// set params
this.options.params = isObjectFull(this.options.params)
? this.options.params
: isObjectFull(CrudConfigService.config.params)
? CrudConfigService.config.params
: {};
const hasPrimary = this.getPrimaryParam();
if (!hasPrimary) {
this.options.params['id'] = {
field: 'id',
type: 'number',
primary: true,
this.options.auth = isObjectFull(authOptions) ? authOptions : {};
this.options.auth.property =
this.options.auth.property || CrudConfigService.config.auth.property;
// merge query config
const query = isObjectFull(this.options.query) ? this.options.query : {};
this.options.query = { ...CrudConfigService.config.query, ...query };
// merge routes config
const routes = isObjectFull(this.options.routes) ? this.options.routes : {};
this.options.routes = deepmerge(CrudConfigService.config.routes, routes, {
arrayMerge: (a, b, c) => b,
});
// set params
this.options.params = isObjectFull(this.options.params)
? this.options.params
: isObjectFull(CrudConfigService.config.params)
? CrudConfigService.config.params
: {};
const hasPrimary = this.getPrimaryParam();
if (!hasPrimary) {
this.options.params['id'] = {
field: 'id',
type: 'number',
primary: true,
};
}
// set dto
if (!isObjectFull(this.options.dto)) {
this.options.dto = {};
const hasPrimary = this.getPrimaryParam();
if (!hasPrimary) {
this.options.params['id'] = {
field: 'id',
type: 'number',
primary: true,
};
}
// set dto
if (!isObjectFull(this.options.dto)) {
this.options.dto = {};
}
// set serialize
const serialize = isObjectFull(this.options.serialize) ? this.options.serialize : {};
this.options.serialize = { ...CrudConfigService.config.serialize, ...serialize };
this.options.serialize.get = isFalse(this.options.serialize.get)
? false
: this.options.serialize.get || this.modelType;
this.options.serialize.getMany = isFalse(this.options.serialize.getMany)
? false
: this.options.serialize.getMany
? this.options.serialize.getMany
: isFalse(this.options.serialize.get)
? /* istanbul ignore next */ false
: SerializeHelper.createGetManyDto(this.options.serialize.get, this.modelName);
this.options.serialize.create = isFalse(this.options.serialize.create)
? false
: this.options.serialize.create || this.modelType;
this.options.serialize.update = isFalse(this.options.serialize.update)
? false
this.options.params = isObjectFull(this.options.params)
? this.options.params
: isObjectFull(CrudConfigService.config.params)
? CrudConfigService.config.params
: {};
const hasPrimary = this.getPrimaryParam();
if (!hasPrimary) {
this.options.params['id'] = {
field: 'id',
type: 'number',
primary: true,
};
}
// set dto
if (!isObjectFull(this.options.dto)) {
this.options.dto = {};
}
// set serialize
const serialize = isObjectFull(this.options.serialize) ? this.options.serialize : {};
this.options.serialize = { ...CrudConfigService.config.serialize, ...serialize };
this.options.serialize.get = isFalse(this.options.serialize.get)
? false
: this.options.serialize.get || this.modelType;
this.options.serialize.getMany = isFalse(this.options.serialize.getMany)
? false
: this.options.serialize.getMany
? this.options.serialize.getMany
: isFalse(this.options.serialize.get)
? /* istanbul ignore next */ false
: SerializeHelper.createGetManyDto(this.options.serialize.get, this.modelName);
private mergeOptions() {
// merge auth config
const authOptions = R.getCrudAuthOptions(this.target);
this.options.auth = isObjectFull(authOptions) ? authOptions : {};
this.options.auth.property =
this.options.auth.property || CrudConfigService.config.auth.property;
// merge query config
const query = isObjectFull(this.options.query) ? this.options.query : {};
this.options.query = { ...CrudConfigService.config.query, ...query };
// merge routes config
const routes = isObjectFull(this.options.routes) ? this.options.routes : {};
this.options.routes = deepmerge(CrudConfigService.config.routes, routes, {
arrayMerge: (a, b, c) => b,
});
// set params
this.options.params = isObjectFull(this.options.params)
? this.options.params
static load(config = {}) {
if (util_1.isObjectFull(config.queryParser)) {
crud_request_1.RequestQueryBuilder.setOptions(config.queryParser);
}
const query = util_1.isObjectFull(config.query) ? config.query : {};
const routes = util_1.isObjectFull(config.routes) ? config.routes : {};
const params = util_1.isObjectFull(config.params) ? config.params : {};
CrudConfigService.config = deepmerge(CrudConfigService.config, { query, routes, params }, { arrayMerge: (a, b, c) => b });
}
}
static load(config: CrudGlobalConfig = {}) {
if (isObjectFull(config.queryParser)) {
RequestQueryBuilder.setOptions(config.queryParser);
}
const auth = isObjectFull(config.auth) ? config.auth : {};
const query = isObjectFull(config.query) ? config.query : {};
const routes = isObjectFull(config.routes) ? config.routes : {};
const params = isObjectFull(config.params) ? config.params : {};
const serialize = isObjectFull(config.serialize) ? config.serialize : {};
CrudConfigService.config = deepmerge(
CrudConfigService.config,
{ auth, query, routes, params, serialize },
{ arrayMerge: (a, b, c) => b },
);
}
}
mergeOptions() {
const query = util_1.isObjectFull(this.options.query) ? this.options.query : {};
this.options.query = Object.assign({}, module_1.CrudConfigService.config.query, query);
const routes = util_1.isObjectFull(this.options.routes) ? this.options.routes : {};
this.options.routes = deepmerge(module_1.CrudConfigService.config.routes, routes, {
arrayMerge: (a, b, c) => b,
});
const params = util_1.isObjectFull(this.options.params) ? this.options.params : {};
this.options.params = Object.assign({}, module_1.CrudConfigService.config.params, params);
reflection_helper_1.R.setCrudOptions(this.options, this.target);
}
getRoutesSchema() {
static load(config: CrudGlobalConfig = {}) {
if (isObjectFull(config.queryParser)) {
RequestQueryBuilder.setOptions(config.queryParser);
}
const auth = isObjectFull(config.auth) ? config.auth : {};
const query = isObjectFull(config.query) ? config.query : {};
const routes = isObjectFull(config.routes) ? config.routes : {};
const params = isObjectFull(config.params) ? config.params : {};
const serialize = isObjectFull(config.serialize) ? config.serialize : {};
CrudConfigService.config = deepmerge(
CrudConfigService.config,
{ auth, query, routes, params, serialize },
{ arrayMerge: (a, b, c) => b },
);
}
}