Skip to content

Commit 086f90a

Browse files
authored
chore: regional host support for RQA (#1244)
## For Internal Contributors * Follow the [Scaled Trunk-Based Development workflow](https://trunkbaseddevelopment.com/) * Branch naming format: `{type}/TICKET_ID/description` * Type: `feat` / `fix` / `chore` / `doc` / `release` * Receive PR review approvals * Rebase your branch with the main branch and wait for CI to pass * Squash merge your commit * Use imperative language in the title and description * Follow the provided template for PR description and squashing ### Template ``` // PR title (Required) [type]: A short description of the changes in imperative language. // PR description (Optional) Add a brief description of the changes in this PR. Bullet points are also fine. // Footer (Recommended) Fixes [<TICKET_ID>](https://sendbird.atlassian.net/browse/<TICKET_ID>) // Changelogs (Recommended) // Add (internal) at the end of each changelog if internal. ### Changelogs // Co-authors // Add this if you pair programmed or they made significant contributions to the ideas in the code and you want to thank them. Co-authored-by: Name name@example.com, Name2 name@example.com ``` ### Checklist Put an `x` in the boxes that apply. You can also fill these out after creating the PR. If unsure, ask the members. This is a reminder of what we look for before merging your code. - [ ] **All tests pass locally with my changes** - [ ] **I have added tests that prove my fix is effective or that my feature works** - [ ] **Public components / utils / props are appropriately exported** - [ ] I have added necessary documentation (if appropriate) ## External Contributions This project is not yet set up to accept pull requests from external contributors. If you have a pull request that you believe should be accepted, please contact the Developer Relations team <developer-advocates@sendbird.com> with details and we'll evaluate if we can set up a [CLA](https://en.wikipedia.org/wiki/Contributor_License_Agreement) to allow for the contribution.
1 parent 197e037 commit 086f90a

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)