Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 77cfa37

Browse filesBrowse files
cnradicheffervescentia
authored andcommitted
feat(configuration): allow a proxy url to be provided in place of generating a groupby url (#84)
1 parent ab47470 commit 77cfa37
Copy full SHA for 77cfa37

2 files changed

+31-1Lines changed: 31 additions & 1 deletion

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎src/core/bridge.ts‎

Copy file name to clipboardExpand all lines: src/core/bridge.ts
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ export class BrowserBridge extends AbstractBridge {
218218
super(config);
219219
const scheme = https ? 'https' : 'http';
220220
const port = https ? ':443' : '';
221-
this.baseUrl = `${scheme}://${customerId}-cors.groupbycloud.com${port}/api/v1`;
221+
this.baseUrl = config.proxyUrl || `${scheme}://${customerId}-cors.groupbycloud.com${port}/api/v1`;
222222
this.bridgeUrl = this.baseUrl + SEARCH;
223223
this.refinementsUrl = this.bridgeUrl + REFINEMENTS;
224224
}
@@ -230,4 +230,5 @@ export class BrowserBridge extends AbstractBridge {
230230

231231
export interface BridgeConfig {
232232
timeout?: number;
233+
proxyUrl?: string;
233234
}
Collapse file

‎test/unit/core/bridge.ts‎

Copy file name to clipboardExpand all lines: test/unit/core/bridge.ts
+29Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import suite from '../_suite';
66

77
const CLIENT_KEY = 'XXX-XXX-XXX-XXX';
88
const CUSTOMER_ID = 'services';
9+
const PROXY_ENDPOINT = 'https://dance.groovebycloud.com';
910

1011
suite('Bridge', ({ expect, spy, stub }) => {
1112
let bridge;
@@ -231,6 +232,20 @@ suite('Bridge', ({ expect, spy, stub }) => {
231232
done();
232233
});
233234
});
235+
236+
it('should send requests to baseUrl prefixed search endpoint when provided', (done) => {
237+
browserFetch.post(`${PROXY_ENDPOINT}/search`, (url, req) => {
238+
return JSON.stringify('success');
239+
});
240+
241+
const browser = new BrowserBridge(CUSTOMER_ID, true, { proxyUrl: PROXY_ENDPOINT });
242+
query = new Query('pants');
243+
browser.fetch = browserFetch;
244+
browser.search(query, (err, results) => {
245+
expect(results).to.eq('success');
246+
done();
247+
});
248+
});
234249
});
235250

236251
describe('refinements()', () => {
@@ -256,6 +271,20 @@ suite('Bridge', ({ expect, spy, stub }) => {
256271
done();
257272
});
258273
});
274+
275+
it('should send requests to baseUrl prefixed refinements endpoint when provided', (done) => {
276+
browserFetch.post(`${PROXY_ENDPOINT}/search/refinements`, (url, req) => {
277+
return JSON.stringify('success');
278+
});
279+
280+
const browser = new BrowserBridge(CUSTOMER_ID, true, { proxyUrl: PROXY_ENDPOINT });
281+
query = new Query('pants');
282+
browser.fetch = browserFetch;
283+
browser.refinements(query, 'designer', (err, results) => {
284+
expect(results).to.eq('success');
285+
done();
286+
});
287+
});
259288
});
260289
});
261290

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.