Skip to content

Commit c2ec78d

Browse files
Fixed linting errors
1 parent e6aea8b commit c2ec78d

File tree

3 files changed

+19
-23
lines changed

3 files changed

+19
-23
lines changed

lib/contentstack.js

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ import getUserAgent from './core/Util.js'
88
import contentstackClient from './contentstackClient.js'
99
import httpClient from './core/contentstackHTTPClient.js'
1010
const regionHostMap = {
11-
'NA': 'api.contentstack.io',
12-
'EU': 'eu-api.contentstack.com',
13-
'AZURE_NA': 'azure-na-api.contentstack.com',
14-
'AZURE_EU': 'azure-eu-api.contentstack.com',
15-
'GCP_NA': 'gcp-na-api.contentstack.com',
16-
'GCP_EU': 'gcp-eu-api.contentstack.com'
11+
NA: 'api.contentstack.io',
12+
EU: 'eu-api.contentstack.com',
13+
AZURE_NA: 'azure-na-api.contentstack.com',
14+
AZURE_EU: 'azure-eu-api.contentstack.com',
15+
GCP_NA: 'gcp-na-api.contentstack.com',
16+
GCP_EU: 'gcp-eu-api.contentstack.com'
1717
}
1818

1919
/**
@@ -169,24 +169,23 @@ const regionHostMap = {
169169
* @returns Contentstack.Client
170170
*/
171171
export function client (params = {}) {
172-
173172
let defaultHostName
174173

175-
if (params.region) {
176-
const region = params.region.toUpperCase()
177-
if (!regionHostMap[region]) {
178-
throw new Error(`Invalid region '${params.region}' provided. Allowed regions are: ${Object.keys(regionHostMap).join(', ')}`)
179-
}
180-
defaultHostName = regionHostMap[region]
181-
} else if (params.host) {
174+
if (params.region) {
175+
const region = params.region.toUpperCase()
176+
if (!regionHostMap[region]) {
177+
throw new Error(`Invalid region '${params.region}' provided. Allowed regions are: ${Object.keys(regionHostMap).join(', ')}`)
178+
}
179+
defaultHostName = regionHostMap[region]
180+
} else if (params.host) {
182181
defaultHostName = params.host
183-
} else {
182+
} else {
184183
defaultHostName = regionHostMap['NA']
185-
}
184+
}
186185

187-
const defaultParameter = {
188-
defaultHostName: defaultHostName
189-
}
186+
const defaultParameter = {
187+
defaultHostName: defaultHostName
188+
}
190189

191190
const sdkAgent = `contentstack-management-javascript/${packages.version}`
192191
const userAgentHeader = getUserAgent(sdkAgent,

lib/core/contentstackHTTPClient.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export default function contentstackHttpClient (options) {
5454
const version = config.version || 'v3'
5555

5656
if (config.region) {
57-
config.host = config.defaultHostName //set region on priority
57+
config.host = config.defaultHostName // set region on priority
5858
}
5959
if (isHost(config.host)) {
6060
const parsed = config.host.split(':')

test/sanity-check/api/user-test.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,6 @@ describe('Contentstack User Session api Test', () => {
125125
done()
126126
})
127127

128-
129128
it('should throw error for invalid region', done => {
130129
try {
131130
contentstack.client({ region: 'DUMMYREGION' })
@@ -135,6 +134,4 @@ describe('Contentstack User Session api Test', () => {
135134
done()
136135
}
137136
})
138-
139-
140137
})

0 commit comments

Comments
 (0)