Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function getApiClient(token) {
return createClient({
middlewares: [
createAuthMiddlewareWithExistingToken(token),
createHttpMiddleware({
host: 'https://api.sphere.io',
fetch,
}),
],
})
}
static _setupClient(
apiConfig: ApiConfigOptions,
accessToken: string
): Object {
if (!apiConfig)
throw new Error('The constructor must be passed an `apiConfig` object')
return createClient({
middlewares: [
createAuthMiddlewareWithExistingToken(
accessToken ? `Bearer ${accessToken}` : ''
),
createAuthMiddlewareForClientCredentialsFlow({ ...apiConfig, fetch }),
createUserAgentMiddleware({
libraryName: pkg.name,
libraryVersion: pkg.version,
}),
createHttpMiddleware({
host: apiConfig.apiUrl,
fetch,
}),
],
})
}
constructor(options: resourceDeleterOptions) {
if (!options.apiConfig)
throw new Error('The constructor must passed an `apiConfig` object')
if (!options.resource) throw new Error('A `resource` object must be passed')
this.apiConfig = options.apiConfig
this.client = createClient({
middlewares: [
createAuthMiddlewareWithExistingToken(
options.accessToken ? `Bearer ${options.accessToken}` : ''
),
createAuthMiddlewareForClientCredentialsFlow({
...this.apiConfig,
fetch,
}),
createUserAgentMiddleware({
libraryName: pkg.name,
libraryVersion: pkg.version,
}),
createHttpMiddleware({ host: this.apiConfig.apiUrl, fetch }),
createQueueMiddleware({
concurrency: 20,
}),
],
})
constructor(options: ExporterOptions) {
if (!options.apiConfig)
throw new Error('The constructor must be passed an `apiConfig` object')
this.apiConfig = options.apiConfig
this.client = createClient({
middlewares: [
createAuthMiddlewareWithExistingToken(
options.accessToken ? `Bearer ${options.accessToken}` : ''
),
createAuthMiddlewareForClientCredentialsFlow({
...this.apiConfig,
fetch,
}),
createUserAgentMiddleware({
libraryName: pkg.name,
libraryVersion: pkg.version,
}),
createHttpMiddleware({
host: this.apiConfig.apiUrl,
enableRetry: true,
fetch,
}),
],
constructor(options: ErasureOptions) {
if (!options.apiConfig)
throw new Error('The constructor must be passed an `apiConfig` object')
this.apiConfig = options.apiConfig
this.client = createClient({
middlewares: [
createAuthMiddlewareWithExistingToken(
options.accessToken ? `Bearer ${options.accessToken}` : ''
),
createAuthMiddlewareForClientCredentialsFlow({
...this.apiConfig,
fetch,
}),
createUserAgentMiddleware({
libraryName: pkg.name,
libraryVersion: pkg.version,
}),
createHttpMiddleware({ host: this.apiConfig.apiUrl, fetch }),
],
})
this.logger = {
...silentLogger,
constructor(options: CategoryExporterOptions) {
if (!options.apiConfig)
throw new Error('The constructor must be passed an `apiConfig` object')
this.apiConfig = options.apiConfig
this.client = createClient({
middlewares: [
createAuthMiddlewareWithExistingToken(
options.accessToken ? `Bearer ${options.accessToken}` : ''
),
createAuthMiddlewareForClientCredentialsFlow({
...this.apiConfig,
fetch,
}),
createUserAgentMiddleware({
libraryName: pkg.name,
libraryVersion: pkg.version,
}),
createHttpMiddleware({
host: this.apiConfig.apiUrl,
enableRetry: true,
fetch,
}),
],
constructor(options: ExporterOptions) {
if (!options.apiConfig)
throw new Error('The constructor must be passed an `apiConfig` object')
this.apiConfig = options.apiConfig
this.client = createClient({
middlewares: [
createAuthMiddlewareWithExistingToken(
options.accessToken ? `Bearer ${options.accessToken}` : ''
),
createAuthMiddlewareForClientCredentialsFlow({
...this.apiConfig,
fetch,
}),
createUserAgentMiddleware({
libraryName: pkg.name,
libraryVersion: pkg.version,
}),
createHttpMiddleware({
host: this.apiConfig.apiUrl,
enableRetry: true,
fetch,
}),
],
constructor(options: ExporterOptions) {
if (!options.apiConfig)
throw Error('The constructor must be passed an `apiConfig` object')
this.apiConfig = options.apiConfig
this.client = createClient({
middlewares: [
createAuthMiddlewareWithExistingToken(
options.accessToken ? `Bearer ${options.accessToken}` : ''
),
createAuthMiddlewareForClientCredentialsFlow({
...this.apiConfig,
fetch,
}),
createUserAgentMiddleware({
libraryName: pkg.name,
libraryVersion: pkg.version,
}),
createHttpMiddleware({
host: this.apiConfig.apiUrl,
fetch,
}),
],
})
constructor(options: ConstructorOptions, logger: LoggerOptions) {
if (!options.apiConfig)
throw new StateImportError(
'The constructor must be passed an `apiConfig` object'
)
this.apiConfig = options.apiConfig
this.accessToken = options.accessToken
this.continueOnProblems = options.continueOnProblems || false
this.client = createClient({
middlewares: [
createAuthMiddlewareWithExistingToken(
this.accessToken ? `Bearer ${this.accessToken}` : ''
),
createAuthMiddlewareForClientCredentialsFlow({
...this.apiConfig,
fetch,
}),
createUserAgentMiddleware({
libraryName: pkg.name,
libraryVersion: pkg.version,
}),
createHttpMiddleware({
host: this.apiConfig.apiUrl,
fetch,
}),
],
})