Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed headers filter from loopbackApi #1331

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 2 additions & 18 deletions src/app/shared/sdk/lb.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ export class LoopBackConfig {
private static version: string | number = "api/v3";
private static authPrefix: string = "";
private static debug: boolean = true;
private static filterOn: string = "headers";
private static whereOn: string = "headers";
private static filterOn: string = "url";
private static whereOn: string = "url";
private static secure: boolean = false;
private static withCredentials: boolean = false;

Expand Down Expand Up @@ -65,26 +65,10 @@ export class LoopBackConfig {
LoopBackConfig.filterOn = "url";
}

public static filterOnHeaders(): void {
LoopBackConfig.filterOn = "headers";
}

public static whereOnUrl(): void {
LoopBackConfig.whereOn = "url";
}

public static whereOnHeaders(): void {
LoopBackConfig.whereOn = "headers";
}

public static isHeadersFilteringSet(): boolean {
return LoopBackConfig.filterOn === "headers";
}

public static isHeadersWhereSet(): boolean {
return LoopBackConfig.whereOn === "headers";
}

public static setSecureWebSockets(): void {
LoopBackConfig.secure = true;
}
Expand Down
25 changes: 6 additions & 19 deletions src/app/shared/sdk/services/core/base.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,30 +124,17 @@ export abstract class BaseLoopBackApi {

// Separate filter object from url params and add to search query
if (urlParams.filter) {
if (LoopBackConfig.isHeadersFilteringSet()) {
headers = headers.append("filter", JSON.stringify(urlParams.filter));
} else {
queryString = `?filter=${encodeURIComponent(
JSON.stringify(urlParams.filter),
)}`;
}
queryString = `?filter=${encodeURIComponent(
JSON.stringify(urlParams.filter),
)}`;
delete urlParams.filter;
}

// Separate where object from url params and add to search query
if (urlParams.where) {
if (LoopBackConfig.isHeadersWhereSet()) {
/**
CODE BELOW WILL GENERATE THE FOLLOWING ISSUES:
- https://github.com/mean-expert-official/loopback-sdk-builder/issues/356
- https://github.com/mean-expert-official/loopback-sdk-builder/issues/328
**/
headers = headers.append("where", JSON.stringify(urlParams.where));
} else {
queryString = `?where=${encodeURIComponent(
JSON.stringify(urlParams.where),
)}`;
}
queryString = `?where=${encodeURIComponent(
JSON.stringify(urlParams.where),
)}`;
delete urlParams.where;
}

Expand Down
Loading