Skip to content
This repository was archived by the owner on Jan 5, 2026. It is now read-only.

Commit cf9814a

Browse files
author
Aamod Pisat
committed
config version changes
1 parent 669fd1a commit cf9814a

4 files changed

Lines changed: 20 additions & 19 deletions

File tree

lib/config/default.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ module.exports = exports = {
5959
}
6060
},
6161
contentstack: {
62-
host: "https://api.contentstack.io/v3",
62+
host: "https://api.contentstack.io",
63+
version: "v3",
6364
socket: "https://contentstack-realtime.built.io/",
6465
urls: {
6566
stacks: "/stacks/",

lib/connect.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ var configTemplate = function () {
8888
, ' ],'
8989
, ' plugins: {},'
9090
, ' contentstack: {'
91-
, ' api_key: "' + inputs.api_key + '",'
92-
, ' access_token: "' + inputs.access_token + '"'
91+
, ' api_key: "' + inputs.api_key.trim() + '",'
92+
, ' access_token: "' + inputs.access_token.trim() + '"'
9393
, ' }'
9494
, '};'
9595
].join(eol);
@@ -246,7 +246,7 @@ Connect.prototype.init = function () {
246246
// get environement from the specified stack
247247
function (_cb) {
248248
request({
249-
url: api.host + api.urls.environments,
249+
url: api.host + '/' + api.version + api.urls.environments,
250250
method: "POST",
251251
headers: self.headers,
252252
json: {
@@ -436,7 +436,7 @@ Connect.prototype.stackInput = function (done) {
436436
function checkSite() {
437437
process.stdout.write('\x1b[33m\nValidating the stack...\x1b[0m');
438438
request({
439-
url: api.host + api.urls.stacks,
439+
url: api.host + '/' + api.version + api.urls.stacks,
440440
method: "GET",
441441
headers: self.headers,
442442
qs: {

lib/publish.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ var publish = function (_event, options) {
145145
_.merge(inputs, result);
146146
// setting the default values
147147
inputs.type = inputs.type || "all";
148-
inputs.language = (inputs.language) ? inputs.language : masterLocale[0];
148+
inputs.language = (inputs.language) ? inputs.language.trim() : masterLocale[0];
149149
inputs.languages = (inputs.language) ? inputs.language : masterLocale[0];
150150
if (inputs.type === "assets") {
151151
delete inputs.content_types;
@@ -198,7 +198,7 @@ publish.prototype.init = function () {
198198
headers.authtoken = user.authtoken;
199199
// get environment id from Built.io Contentstack
200200
_request({
201-
url: api.host + api.urls.environments,
201+
url: api.host + '/' + api.version + api.urls.environments,
202202
headers: headers,
203203
method: "POST",
204204
json: {
@@ -329,7 +329,7 @@ publish.prototype.publishEntries = function (entries, content_type, language) {
329329
return (function (cb) {
330330
var entry_id = (entry['_metadata']) ? entry['_metadata']['uid'] : entry['uid'],
331331
_options = {
332-
url: api.host + api.urls.content_types + content_type['uid'] + api.urls.entries + entry_id + '/' + inputs.event,
332+
url: api.host + '/' + api.version + api.urls.content_types + content_type['uid'] + api.urls.entries + entry_id + '/' + inputs.event,
333333
headers: headers,
334334
method: 'POST',
335335
json: {
@@ -368,7 +368,7 @@ publish.prototype.publishEntries = function (entries, content_type, language) {
368368
publish.prototype.assets = function (callback) {
369369
var self = this,
370370
option = {
371-
url: api.host + api.urls.assets,
371+
url: api.host + '/' + api.version + api.urls.assets,
372372
qs: {
373373
include_count: true,
374374
limit: bound,
@@ -402,7 +402,7 @@ publish.prototype.assets = function (callback) {
402402
_calls.push(function (asset) {
403403
return (function (cb) {
404404
var options = {
405-
url: api.host + api.urls.assets + asset.uid + '/' + inputs.event,
405+
url: api.host + '/' + api.version + api.urls.assets + asset.uid + '/' + inputs.event,
406406
method: "POST",
407407
headers: headers,
408408
json: {
@@ -433,7 +433,7 @@ publish.prototype.assets = function (callback) {
433433
_calls.push(function (offset, limit) {
434434
return (function (cb) {
435435
var _options = {
436-
url: api.host + api.urls.assets,
436+
url: api.host + '/' + api.version + api.urls.assets,
437437
method: "GET",
438438
headers: headers,
439439
qs: {

lib/utils.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ Utility.prototype.getEntries = function (content_type, locale, _query, fields, e
4848

4949
_getEntries = function (skip) {
5050
var options = {
51-
url: api.host + api.urls.content_types + content_type + api.urls.entries,
51+
url: api.host + '/' + api.version + api.urls.content_types + content_type + api.urls.entries,
5252
headers: self.headers,
5353
method: "POST",
5454
json: {
@@ -102,7 +102,7 @@ Utility.prototype.getEntries = function (content_type, locale, _query, fields, e
102102
* */
103103
Utility.prototype.getContentTypes = function () {
104104
return request({
105-
url: api.host + api.urls.content_types,
105+
url: api.host + '/' + api.version + api.urls.content_types,
106106
qs: {desc: "created_at"},
107107
headers: this.headers,
108108
method: "GET",
@@ -115,7 +115,7 @@ Utility.prototype.getContentTypes = function () {
115115
* */
116116
Utility.prototype.login = function (user) {
117117
return request({
118-
url: api.host + api.urls.session,
118+
url: api.host + '/' + api.version + api.urls.session,
119119
headers: this.headers,
120120
method: "POST",
121121
json: user
@@ -127,7 +127,7 @@ Utility.prototype.login = function (user) {
127127
* */
128128
Utility.prototype.getEnvironment = function (environment) {
129129
return request({
130-
url: api.host + api.urls.environments + environment,
130+
url: api.host + '/' + api.version + api.urls.environments + environment,
131131
headers: this.headers,
132132
method: "GET",
133133
json: true
@@ -139,7 +139,7 @@ Utility.prototype.getEnvironment = function (environment) {
139139
Utility.prototype.getAssets = function (options) {
140140
return request({
141141
method: "GET",
142-
url: api.host + api.urls.assets,
142+
url: api.host + '/' + api.version + api.urls.assets,
143143
qs: options,
144144
headers: this.headers,
145145
json: true
@@ -150,7 +150,7 @@ Utility.prototype.getAssets = function (options) {
150150
* */
151151
Utility.prototype.getStack = function (headers) {
152152
return request({
153-
url: api.host + api.urls.stacks,
153+
url: api.host + '/' + api.version + api.urls.stacks,
154154
headers: headers || this.headers,
155155
method: "GET",
156156
qs: {
@@ -165,7 +165,7 @@ Utility.prototype.getStack = function (headers) {
165165
* */
166166
Utility.prototype.getEnvironments = function (headers, query) {
167167
return request({
168-
url: api.host + api.urls.environments,
168+
url: api.host + '/' + api.version + api.urls.environments,
169169
qs: query || {},
170170
headers: headers || this.headers,
171171
method: "GET",
@@ -229,7 +229,7 @@ Utility.prototype.inputs = {
229229
},
230230
conform: function (input) {
231231
var languages = config.get('languages'),
232-
idx = _.findIndex(languages, {"code": input});
232+
idx = _.findIndex(languages, {"code": input.trim()});
233233
return (idx > -1);
234234
}
235235
}

0 commit comments

Comments
 (0)