Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
private createNonTemplatedLink(rel: Relation, resource: object) {
let relationPath = _.findKey(this.api.pipelineByName, rel.pipeline() as any);
if (relationPath !== undefined) {
console.log(rel.pipeline)
let url = "";
let query = QueryTemplate.hydrate(rel.query, resource);
if (query['id'] && rel.type == 'one') {
url = `/${query['id']}?`;
delete (query['id']);
} else {
url = '?';
}
_.each(query, (value, key) => {
if (Array.isArray(value)) {
value.forEach((subValue) => {
url += `${key}[]=${subValue}&`;
})
} else {
url += `${key}=${value}&`;
}
public async create(next, resources, options?) {
if (this.notImplementedMethods.indexOf("create") !== -1) {
throw notImplementedError("create", Object.getPrototypeOf(this).constructor.name);
}
return next(resources, options)
}
public async read(next, query?, options?) {
if (this.notImplementedMethods.indexOf("read") !== -1) {
throw notImplementedError("read", Object.getPrototypeOf(this).constructor.name);
}
return next(query, options)
}
public async replace(next, id, values, options?) {
if (this.notImplementedMethods.indexOf("replace") !== -1) {
throw notImplementedError("replace", Object.getPrototypeOf(this).constructor.name);
}
return next(id, values, options)
}
public async delete(next, query, options?) {
if (this.notImplementedMethods.indexOf("delete") !== -1) {
throw notImplementedError("delete", Object.getPrototypeOf(this).constructor.name);
}
return next(query, options)
}
}
public async patch(next, query, values, options?) {
if (this.notImplementedMethods.indexOf("patch") !== -1) {
throw notImplementedError("patch", Object.getPrototypeOf(this).constructor.name);
}
return next(query, values, options)
}
value.forEach((subValue) => {
url += `${key}[]=${QueryTemplate.escape(subValue)}&`;
})
} else {
_.each(nonTemplatedParts, (value, key) => {
if (key == 'id' && rel.type == 'one') {
idUrl = `/${value}`;
} else if (Array.isArray(value)) {
value.forEach((subValue) => {
url += `${key}[]=${QueryTemplate.escape(subValue)}&`;
})
} else {
url += `${key}=${QueryTemplate.escape(value)}&`;
}
});
private createTemplatedLink(rel: Relation): object {
let relationPath = _.findKey(this.api.pipelineByName, rel.pipeline() as any);
if (relationPath !== undefined) {
let idUrl = "";
let url = "?";
let templatedParts = QueryTemplate.getTemplatedParts(rel.query);
let nonTemplatedParts = QueryTemplate.getNonTemplatedParts(rel.query);
_.each(nonTemplatedParts, (value, key) => {
if (key == 'id' && rel.type == 'one') {
idUrl = `/${value}`;
} else if (Array.isArray(value)) {
value.forEach((subValue) => {
url += `${key}[]=${QueryTemplate.escape(subValue)}&`;
})
} else {
url += `${key}=${QueryTemplate.escape(value)}&`;
}
});
let templatedParams: string[] = [];
_.each(templatedParts, (value, key) => {
if (key == 'id' && rel.type == 'one') {
private createTemplatedLink(rel: Relation): object {
let relationPath = _.findKey(this.api.pipelineByName, rel.pipeline() as any);
if (relationPath !== undefined) {
let idUrl = "";
let url = "?";
let templatedParts = QueryTemplate.getTemplatedParts(rel.query);
let nonTemplatedParts = QueryTemplate.getNonTemplatedParts(rel.query);
_.each(nonTemplatedParts, (value, key) => {
if (key == 'id' && rel.type == 'one') {
idUrl = `/${value}`;
} else if (Array.isArray(value)) {
value.forEach((subValue) => {
url += `${key}[]=${QueryTemplate.escape(subValue)}&`;
})
} else {
url += `${key}=${QueryTemplate.escape(value)}&`;
}
});
let templatedParams: string[] = [];
_.each(templatedParts, (value, key) => {