Skip to content

Commit d1fead6

Browse files
committed
feat(init): add serverURL option as an alias for serverURLs
1 parent abf0a3d commit d1fead6

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

src/init.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ let _disableAppRouter = false;
4949
* @param {String} options.appKey application key
5050
* @param {String} [options.masterKey] application master key
5151
* @param {Boolean} [options.production]
52-
* @param {String|ServerURLs} [options.serverURLs] URLs for services. if a string was given, it will be applied for all services.
52+
* @param {String|ServerURLs} [options.serverURL] URLs for services. if a string was given, it will be applied for all services.
5353
* @param {Boolean} [options.disableCurrentUser]
5454
*/
5555
AV.init = function init(options, ...params) {
@@ -65,7 +65,8 @@ AV.init = function init(options, ...params) {
6565
appKey,
6666
masterKey,
6767
hookKey,
68-
serverURLs,
68+
serverURL,
69+
serverURLs = serverURL,
6970
disableCurrentUser,
7071
production,
7172
realtime,
@@ -78,7 +79,7 @@ AV.init = function init(options, ...params) {
7879
if (isCNApp(appId)) {
7980
if (!serverURLs && isEmpty(AV._config.serverURLs)) {
8081
throw new TypeError(
81-
`serverURLs option is required for apps from CN region`
82+
`serverURL option is required for apps from CN region`
8283
);
8384
}
8485
}
@@ -163,12 +164,13 @@ AV._setServerURLs = (urls, disableAppRouter = true) => {
163164
};
164165
/**
165166
* Set server URLs for services.
166-
* @function AV.setServerURLs
167-
* @since 3.0.0
167+
* @function AV.setServerURL
168+
* @since 4.3.0
168169
* @param {String|ServerURLs} urls URLs for services. if a string was given, it will be applied for all services.
169-
* You can also set them when initializing SDK with `options.serverURLs`
170+
* You can also set them when initializing SDK with `options.serverURL`
170171
*/
171-
AV.setServerURLs = urls => AV._setServerURLs(urls);
172+
AV.setServerURL = urls => AV._setServerURLs(urls);
173+
AV.setServerURLs = AV.setServerURL;
172174

173175
AV.keepErrorRawMessage = value => {
174176
AV._sharedConfig.keepErrorRawMessage = value;

storage.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1229,10 +1229,12 @@ export function init(options: {
12291229
hookKey?: string;
12301230
region?: string;
12311231
production?: boolean;
1232+
serverURL?: string | ServerURLs;
12321233
serverURLs?: string | ServerURLs;
12331234
disableCurrentUser?: boolean;
12341235
realtime?: Realtime;
12351236
}): void;
1237+
export function setServerURL(urls: string | ServerURLs): void;
12361238
export function setServerURLs(urls: string | ServerURLs): void;
12371239
export function setProduction(production: boolean): void;
12381240
export function setRequestTimeout(ms: number): void;

0 commit comments

Comments
 (0)