Skip to content

Commit cad62c1

Browse files
committed
feat(init): apply app-router globally and retire the region option
1 parent 2ef7a63 commit cad62c1

File tree

4 files changed

+19
-28
lines changed

4 files changed

+19
-28
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ node_js:
66
sudo: false
77
env:
88
global:
9-
- REGION=us
9+
- S3=true
1010
- APPID=QvNM6AG2khJtBQo6WRMWqfLV-gzGzoHsz
1111
- APPKEY=be2YmUduiuEnCB2VR9bLRnnV
1212
- MASTERKEY=1AqFJWElESSui6JKqHiKnLTY

src/init.js

Lines changed: 16 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -10,31 +10,27 @@ const fillServerURLs = url => ({
1010
api: url,
1111
});
1212

13-
function getDefaultServerURLs(appId, region) {
14-
if (region === 'us') return fillServerURLs('https://us-api.leancloud.cn');
15-
let id;
13+
function getDefaultServerURLs(appId) {
14+
let domain;
15+
const id = appId.slice(0, 8).toLowerCase();
1616
switch (appId.slice(-9)) {
1717
case '-9Nh9j0Va':
1818
// TAB
19-
id = appId.slice(0, 8).toLowerCase();
20-
return {
21-
push: `https://${id}.push.lncldapi.com`,
22-
stats: `https://${id}.stats.lncldapi.com`,
23-
engine: `https://${id}.engine.lncldapi.com`,
24-
api: `https://${id}.api.lncldapi.com`,
25-
};
19+
domain = 'lncldapi.com';
20+
break;
2621
case '-MdYXbMMI':
2722
// US
28-
return fillServerURLs('https://us-api.leancloud.cn');
23+
domain = 'lncldglobal.com';
24+
break;
2925
default:
30-
id = appId.slice(0, 8).toLowerCase();
31-
return {
32-
push: `https://${id}.push.lncld.net`,
33-
stats: `https://${id}.stats.lncld.net`,
34-
engine: `https://${id}.engine.lncld.net`,
35-
api: `https://${id}.api.lncld.net`,
36-
};
26+
domain = 'lncld.net';
3727
}
28+
return {
29+
push: `https://${id}.push.${domain}`,
30+
stats: `https://${id}.stats.${domain}`,
31+
engine: `https://${id}.engine.${domain}`,
32+
api: `https://${id}.api.${domain}`,
33+
};
3834
}
3935

4036
let _disableAppRouter = false;
@@ -56,7 +52,6 @@ let _disableAppRouter = false;
5652
* @param {String} options.appId application id
5753
* @param {String} options.appKey application key
5854
* @param {String} [options.masterKey] application master key
59-
* @param {String} [options.region='cn'] region
6055
* @param {Boolean} [options.production]
6156
* @param {String|ServerURLs} [options.serverURLs] URLs for services. if a string was given, it will be applied for all services.
6257
* @param {Boolean} [options.disableCurrentUser]
@@ -67,15 +62,13 @@ AV.init = function init(options, ...params) {
6762
appId: options,
6863
appKey: params[0],
6964
masterKey: params[1],
70-
region: params[2],
7165
});
7266
}
7367
const {
7468
appId,
7569
appKey,
7670
masterKey,
7771
hookKey,
78-
region = 'cn',
7972
serverURLs,
8073
disableCurrentUser,
8174
production,
@@ -96,11 +89,11 @@ AV.init = function init(options, ...params) {
9689
AV._config.disableCurrentUser = disableCurrentUser;
9790
AV._appRouter = new AppRouter(AV);
9891
const disableAppRouter =
99-
_disableAppRouter || typeof serverURLs !== 'undefined' || region !== 'cn';
92+
_disableAppRouter || typeof serverURLs !== 'undefined';
10093
AV._setServerURLs(
10194
extend(
10295
{},
103-
getDefaultServerURLs(appId, region),
96+
getDefaultServerURLs(appId),
10497
AV._config.serverURLs,
10598
typeof serverURLs === 'string' ? fillServerURLs(serverURLs) : serverURLs
10699
),
@@ -112,7 +105,6 @@ AV.init = function init(options, ...params) {
112105
AV._config.realtime = new AV._sharedConfig.liveQueryRealtime({
113106
appId,
114107
appKey,
115-
region,
116108
});
117109
}
118110
};

test/file.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ describe('File', function() {
7777
});
7878

7979
describe('Saving stream in node.js', function() {
80-
if (process.env.REGION === 'us') {
81-
it('should throw in us region', () => {
80+
if (process.env.S3 === 'true') {
81+
it('should throw with s3', () => {
8282
return new AV.File(
8383
'stream-test',
8484
require('fs').createReadStream(__filename)

test/test.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,5 @@ AV.init({
1717
appKey: process.env.APPKEY || 'gNAE1iHowdQvV7cqpfCMGaGN',
1818
masterKey: process.env.MASTERKEY || 'ue9M9nqwD4MQNXD3oiN5rAOv',
1919
hookKey: process.env.HOOKKEY || '2iCbUZDgEF0siKxmCn2kVQXV',
20-
region: process.env.REGION || 'cn',
2120
});
2221
AV.setProduction(true);

0 commit comments

Comments
 (0)