Skip to content

Commit 82a95f8

Browse files
Merge pull request #21 from contentstack/region-support
Region support
2 parents 522298f + db4f925 commit 82a95f8

File tree

4 files changed

+14
-3
lines changed

4 files changed

+14
-3
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "contentstack",
3-
"version": "3.7.0",
3+
"version": "3.7.1",
44
"description": "Contentstack Javascript SDK",
55
"homepage": "https://www.contentstack.com/",
66
"author": {

src/core/contentstack.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import Stack from "./stack";
22
import CacheProvider from './cache-provider/index';
3+
import ContentstackRegion from "./contentstackregion";
34

45

56
/**
@@ -23,6 +24,7 @@ class Contentstack {
2324
* Contentstack.CachePolicy.CACHE_THEN_NETWORK
2425
*/
2526
this.CachePolicy = CacheProvider.policies;
27+
this.Region = ContentstackRegion;
2628
}
2729
/**
2830

src/core/contentstackregion.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
const ContentstackRegion = {
2+
EU: "eu",
3+
US: "us"
4+
};
5+
6+
export default ContentstackRegion;
7+
//module.exports = ContentstackRegion;

src/core/stack.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import Request from './lib/request';
88
import * as cache from './cache';
99
import CacheProvider from './cache-provider/index';
1010

11+
1112
/**
1213
* @class
1314
Stack
@@ -26,11 +27,12 @@ import CacheProvider from './cache-provider/index';
2627
*/
2728
export default class Stack {
2829
constructor(...stack_arguments) {
29-
30+
if(stack_arguments[0].region && stack_arguments[0].region != undefined && stack_arguments[0].region != "us") {
31+
config['host'] = stack_arguments[0].region+"-"+"cdn.contentstack.com"
32+
}
3033
this.config = config;
3134
this.cachePolicy = CacheProvider.policies.IGNORE_CACHE;
3235
this.provider = CacheProvider.providers('localstorage');
33-
//this.sync_cdn_api_key = stack_arguments[0].sync_cdn_api_key;
3436
switch (stack_arguments.length) {
3537
case 1:
3638
if (typeof stack_arguments[0] === "object" && typeof stack_arguments[0].api_key === "string" && typeof stack_arguments[0].access_token === "string" && typeof stack_arguments[0].environment === "string") {

0 commit comments

Comments
 (0)