Skip to content

Commit 052463d

Browse files
authored
Merge pull request #31 from contentstack/automation
Stack instance issue resolved
2 parents ea01ed7 + 7b67754 commit 052463d

File tree

3 files changed

+39
-9
lines changed

3 files changed

+39
-9
lines changed

.npmignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ docs-config.json
44
test.js
55
test/
66
reports/
7-
csio-templates/
7+
contentstack-templates/
88
js-sdk-reference/
99
examples/
10-
10+
mocktest.json

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "contentstack",
3-
"version": "3.9.0",
3+
"version": "3.9.1",
44
"description": "Contentstack Javascript SDK",
55
"homepage": "https://www.contentstack.com/",
66
"author": {
@@ -9,7 +9,7 @@
99
},
1010
"main": "dist/node/contentstack.js",
1111
"browser": "dist/web/contentstack.js",
12-
"_id": "[email protected].0",
12+
"_id": "[email protected].1",
1313
"scripts": {
1414
"test": "tape test/index.js | tap-html --out ./tap-html.html",
1515
"automate": "node test.js",
@@ -44,14 +44,14 @@
4444
],
4545
"dist": {
4646
"shasum": "a328ed07240476a26b31a23261355dc929e1da63",
47-
"tarball": "https://registry.npmjs.org/contentstack/-/contentstack-3.9.0.tgz"
47+
"tarball": "https://registry.npmjs.org/contentstack/-/contentstack-3.9.1.tgz"
4848
},
4949
"license": "MIT",
5050
"directories": {},
51-
"_resolved": "https://registry.npmjs.org/contentstack/-/contentstack-3.9.0.tgz",
51+
"_resolved": "https://registry.npmjs.org/contentstack/-/contentstack-3.9.1.tgz",
5252
"_npmOperationalInternal": {
5353
"host": "packages-18-east.internal.npmjs.com",
54-
"tmp": "tmp/contentstack-3.9.0.tgz_1477830884275_0.9869455888401717"
54+
"tmp": "tmp/contentstack-3.9.1.tgz_1477830884275_0.9869455888401717"
5555
},
5656
"devDependencies": {
5757
"babel-core": "6.26.0",

src/core/stack.js

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ export default class Stack {
5050
this.config = config;
5151
this.cachePolicy = CacheProvider.policies.IGNORE_CACHE;
5252
this.provider = CacheProvider.providers('localstorage');
53+
console.error(stack_arguments.length);
54+
5355
switch (stack_arguments.length) {
5456
case 1:
5557
if (typeof stack_arguments[0] === "object" && typeof stack_arguments[0].api_key === "string" && typeof stack_arguments[0].delivery_token === "string" && typeof stack_arguments[0].environment === "string") {
@@ -62,7 +64,36 @@ export default class Stack {
6264
} else {
6365
console.error("Kindly provide valid object parameters. The specified API Key, Delivery Token, or Environment Name is invalid.");
6466
}
65-
case 3, 4, 5:
67+
case 3:
68+
if (typeof stack_arguments[0] === "string" && typeof stack_arguments[1] === "string" && typeof stack_arguments[2] === "string") {
69+
this.headers = {
70+
api_key: stack_arguments[0],
71+
access_token: stack_arguments[1]
72+
};
73+
this.environment = stack_arguments[2];
74+
return this;
75+
} else {
76+
console.error("Kindly provide valid string parameters.");
77+
}
78+
case 4:
79+
if (typeof stack_arguments[0] === "string" && typeof stack_arguments[1] === "string" && typeof stack_arguments[2] === "string") {
80+
this.headers = {
81+
api_key: stack_arguments[0],
82+
access_token: stack_arguments[1]
83+
};
84+
this.environment = stack_arguments[2];
85+
return this;
86+
} else {
87+
console.error("Kindly provide valid string parameters.");
88+
}
89+
if (stack_arguments[3]) {
90+
if(typeof stack_arguments[3] === "string" && stack_arguments[3].region !== "us" && stack_arguments[3].region === "eu") {
91+
config['host'] = stack_arguments[0].region+"-"+"cdn.contentstack.com";
92+
} else if (typeof stack_arguments[3] === 'object') {
93+
this.fetchOptions = stack_arguments[3]
94+
}
95+
}
96+
case 5:
6697
if (typeof stack_arguments[0] === "string" && typeof stack_arguments[1] === "string" && typeof stack_arguments[2] === "string") {
6798
this.headers = {
6899
api_key: stack_arguments[0],
@@ -80,7 +111,6 @@ export default class Stack {
80111
this.fetchOptions = stack_arguments[3]
81112
}
82113
}
83-
84114
if (stack_arguments[4] && typeof stack_arguments[4] === 'object') {
85115
this.fetchOptions = stack_arguments[3]
86116
}

0 commit comments

Comments
 (0)