Skip to content

Commit d3c5ee7

Browse files
committed
chore: support regional base host for RQA
1 parent 197e037 commit d3c5ee7

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

apps/testing/src/utils/paramsBuilder.ts

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ export interface InitialParams {
66
userId?: string;
77
nickname?: string;
88
accessToken?: string;
9-
customApiHost?: string;
10-
customWebSocketHost?: string;
119
}
1210

1311
interface ParamsAsProps {
@@ -18,18 +16,24 @@ interface ParamsAsProps {
1816
allowProfileEdit: boolean;
1917
isMultipleFilesMessageEnabled: boolean;
2018
uikitOptions: UIKitOptions;
19+
customApiHost?: string;
20+
customWebSocketHost?: string;
2121
}
2222

2323
export const useConfigParams = (initParams: InitialParams): ParamsAsProps => {
2424
const [searchParams] = useSearchParams();
2525

26+
const { customApiHost = searchParams.get('customApiHost'), customWebSocketHost = searchParams.get('customWebSocketHost') } = getHostBy(
27+
searchParams.get('region'),
28+
);
29+
2630
const response = {
2731
appId: searchParams.get('appId') || initParams.appId,
2832
userId: searchParams.get('userId') || initParams.userId,
2933
nickname: searchParams.get('nickname') || initParams.nickname || initParams.userId,
3034
accessToken: searchParams.get('accessToken') || initParams.accessToken,
31-
customApiHost: searchParams.get('customApiHost') || initParams.customApiHost,
32-
customWebSocketHost: searchParams.get('customWebSocketHost') || initParams.customWebSocketHost,
35+
customApiHost,
36+
customWebSocketHost,
3337
allowProfileEdit: parseValue(searchParams.get('enableProfileEdit')) ?? true,
3438
isMultipleFilesMessageEnabled: parseValue(searchParams.get('enableMultipleFilesMessage')) ?? true,
3539
enableLegacyChannelModules: parseValue(searchParams.get('enableLegacyChannelModules')) ?? false,
@@ -70,6 +74,17 @@ export const useConfigParams = (initParams: InitialParams): ParamsAsProps => {
7074
return response;
7175
};
7276

77+
function getHostBy(region?: string | null) {
78+
if (region?.startsWith('no')) {
79+
return {
80+
customApiHost: `https://api-${region}.sendbirdtest.com`,
81+
customWebSocketHost: `wss://ws-${region}.sendbirdtest.com`,
82+
};
83+
}
84+
85+
return { customApiHost: undefined, customWebSocketHost: undefined };
86+
}
87+
7388
function parseValue(value?: string | null) {
7489
if (!value) return value;
7590
if (value.toLowerCase().match(/true/)) {

0 commit comments

Comments
 (0)