Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(int-978): adding default header for all requests #60

Merged
merged 3 commits into from
Jul 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"p-series": "^2.1.0",
"path": "^0.12.7",
"simple-uuid": "^0.0.1",
"storyblok-js-client": "^4.5.6",
"storyblok-js-client": "^5.12.0",
"update-notifier": "^5.1.0",
"xml-js": "^1.6.11"
},
Expand All @@ -65,4 +65,4 @@
"master"
]
}
}
}
8 changes: 7 additions & 1 deletion src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,18 @@ const COMMANDS = {
SYNC: 'sync'
}

const DEFAULT_AGENT = {
SB_Agent: 'SB-CLI',
SB_Agent_Version: process.env.npm_package_version || '3.0.0'
}

module.exports = {
LOGIN_URL,
SIGNUP_URL,
API_URL,
SYNC_TYPES,
US_API_URL,
CN_API_URL,
COMMANDS
COMMANDS,
DEFAULT_AGENT
}
12 changes: 9 additions & 3 deletions src/utils/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const inquirer = require('inquirer')

const creds = require('./creds')
const getQuestions = require('./get-questions')
const { SIGNUP_URL, API_URL, US_API_URL, CN_API_URL } = require('../constants')
const { SIGNUP_URL, API_URL, US_API_URL, CN_API_URL, DEFAULT_AGENT } = require('../constants')

module.exports = {
accessToken: '',
Expand All @@ -20,7 +20,10 @@ module.exports = {
return new Storyblok({
accessToken: this.accessToken,
oauthToken: this.oauthToken,
region: this.region
region: this.region,
headers: {
...DEFAULT_AGENT
}
}, this.apiSwitcher(region))
} catch (error) {
throw new Error(error)
Expand Down Expand Up @@ -277,7 +280,10 @@ module.exports = {
const customClient = new Storyblok({
accessToken: this.accessToken,
oauthToken: this.oauthToken,
region
region,
headers: {
...DEFAULT_AGENT
}
}, this.apiSwitcher(region))
return await customClient
.get('spaces/', {})
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4359,10 +4359,10 @@ static-extend@^0.1.1:
define-property "^0.2.5"
object-copy "^0.1.0"

storyblok-js-client@^4.5.6:
version "4.5.6"
resolved "https://registry.yarnpkg.com/storyblok-js-client/-/storyblok-js-client-4.5.6.tgz#caab0bb1ead8618f84afcc35be9305883d85e628"
integrity sha512-S0cXKkEqGDibD32K48FFodjeu/+eF++nrHhrLzo/bKxrnyQiPChPccFAnzsJCQ6uMvRuVGZzjKwM5/sMeBRthg==
storyblok-js-client@^5.12.0:
version "5.12.0"
resolved "https://registry.yarnpkg.com/storyblok-js-client/-/storyblok-js-client-5.12.0.tgz#e8100296609d3574990bdb8a7cdf3b031125e193"
integrity sha512-g096AwVtRfs+epfvuiQlI4RDTRcn+/h+WxkWQd8rm95MnRzgZMo1LJcg9NQU8Hy172dvrcjH2+DBsPxw0NAoYw==

string-length@^4.0.1:
version "4.0.2"
Expand Down