Skip to content

Commit

Permalink
removed headers filter from loopbackApi
Browse files Browse the repository at this point in the history
  • Loading branch information
Junjiequan committed Nov 24, 2023
1 parent a8b2916 commit 96ddaa6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 37 deletions.
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

0 comments on commit 96ddaa6

Please sign in to comment.