Skip to content

Commit 8b25014

Browse files
authored
🔀 Merge pull request #148 from leancloud/init
🚸 Set app infos from environments automatically
2 parents f7ae475 + 883599d commit 8b25014

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

lib/storage-extra.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,13 @@ if (process.env.LEANCLOUD_API_SERVER) {
1919
AV.setServerURLs(process.env.LEANCLOUD_API_SERVER);
2020
}
2121

22+
if (AV.version && !AV.version.match(/^[0123]\./)) {
23+
AV._config.applicationId = process.env.LEANCLOUD_APP_ID;
24+
AV._config.applicationKey = process.env.LEANCLOUD_APP_KEY;
25+
AV._config.masterKey = process.env.LEANCLOUD_APP_MASTER_KEY;
26+
AV._config.hookKey = process.env.LEANCLOUD_APP_HOOK_KEY;
27+
}
28+
2229
AV._sharedConfig.userAgent = 'AVOS Cloud Code Node ' + require('../package').version;
2330
AV.Cloud.__prod = process.env.NODE_ENV === 'production' ? 1 : 0;
2431
AV.setProduction(AV.Cloud.__prod);

0 commit comments

Comments
 (0)