@spotify-confidence/client-http
Advanced tools
Comparing version 0.0.3 to 0.1.0
@@ -31,2 +31,3 @@ import { Configuration, ResolveContext } from './Configuration'; | ||
baseUrl?: string; | ||
timeout: number; | ||
}; | ||
@@ -41,2 +42,3 @@ export type AppliedFlag = { | ||
private readonly clientSecret; | ||
private readonly timeout; | ||
private readonly fetchImplementation; | ||
@@ -43,0 +45,0 @@ constructor(options: ConfidenceClientOptions); |
@@ -29,2 +29,3 @@ "use strict"; | ||
this.backendApplyEnabled = options.apply; | ||
this.timeout = options.timeout; | ||
if (options.baseUrl) { | ||
@@ -40,6 +41,10 @@ this.baseUrl = options.baseUrl; | ||
const payload = Object.assign({ clientSecret: this.clientSecret, evaluationContext: context, apply: this.backendApplyEnabled }, options); | ||
const controller = new AbortController(); | ||
const timeoutId = setTimeout(() => controller.abort(), this.timeout); | ||
const response = yield this.fetchImplementation(`${this.baseUrl}/v1/flags:resolve`, { | ||
method: 'POST', | ||
body: JSON.stringify(payload), | ||
signal: controller.signal, | ||
}); | ||
clearTimeout(timeoutId); | ||
const responseBody = yield response.json(); | ||
@@ -46,0 +51,0 @@ return { |
@@ -31,2 +31,3 @@ import { Configuration, ResolveContext } from './Configuration'; | ||
baseUrl?: string; | ||
timeout: number; | ||
}; | ||
@@ -41,2 +42,3 @@ export type AppliedFlag = { | ||
private readonly clientSecret; | ||
private readonly timeout; | ||
private readonly fetchImplementation; | ||
@@ -43,0 +45,0 @@ constructor(options: ConfidenceClientOptions); |
@@ -26,2 +26,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
this.backendApplyEnabled = options.apply; | ||
this.timeout = options.timeout; | ||
if (options.baseUrl) { | ||
@@ -37,6 +38,10 @@ this.baseUrl = options.baseUrl; | ||
const payload = Object.assign({ clientSecret: this.clientSecret, evaluationContext: context, apply: this.backendApplyEnabled }, options); | ||
const controller = new AbortController(); | ||
const timeoutId = setTimeout(() => controller.abort(), this.timeout); | ||
const response = yield this.fetchImplementation(`${this.baseUrl}/v1/flags:resolve`, { | ||
method: 'POST', | ||
body: JSON.stringify(payload), | ||
signal: controller.signal, | ||
}); | ||
clearTimeout(timeoutId); | ||
const responseBody = yield response.json(); | ||
@@ -43,0 +48,0 @@ return { |
@@ -31,2 +31,3 @@ import { Configuration, ResolveContext } from './Configuration'; | ||
baseUrl?: string; | ||
timeout: number; | ||
}; | ||
@@ -41,2 +42,3 @@ export type AppliedFlag = { | ||
private readonly clientSecret; | ||
private readonly timeout; | ||
private readonly fetchImplementation; | ||
@@ -43,0 +45,0 @@ constructor(options: ConfidenceClientOptions); |
@@ -26,2 +26,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
this.backendApplyEnabled = options.apply; | ||
this.timeout = options.timeout; | ||
if (options.baseUrl) { | ||
@@ -37,6 +38,10 @@ this.baseUrl = options.baseUrl; | ||
const payload = Object.assign({ clientSecret: this.clientSecret, evaluationContext: context, apply: this.backendApplyEnabled }, options); | ||
const controller = new AbortController(); | ||
const timeoutId = setTimeout(() => controller.abort(), this.timeout); | ||
const response = yield this.fetchImplementation(`${this.baseUrl}/v1/flags:resolve`, { | ||
method: 'POST', | ||
body: JSON.stringify(payload), | ||
signal: controller.signal, | ||
}); | ||
clearTimeout(timeoutId); | ||
const responseBody = yield response.json(); | ||
@@ -43,0 +48,0 @@ return { |
# Changelog | ||
## [0.1.0](https://github.com/spotify/confidence-openfeature-provider-js/compare/client-http-v0.0.3...client-http-v0.1.0) (2023-11-15) | ||
### ⚠ BREAKING CHANGES | ||
* **client-http,web,server,react,examples:** new required option: timeout | ||
### ✨ New Features | ||
* **client-http,web,server,react,examples:** add timeout for network request ([f460b97](https://github.com/spotify/confidence-openfeature-provider-js/commit/f460b97ec4e1c56375de52fd1eb664c7b9be1f35)) | ||
## [0.0.3](https://github.com/spotify/confidence-openfeature-provider-js/compare/client-http-v0.0.2...client-http-v0.0.3) (2023-10-26) | ||
@@ -4,0 +15,0 @@ |
{ | ||
"name": "@spotify-confidence/client-http", | ||
"license": "Apache-2.0", | ||
"version": "0.0.3", | ||
"version": "0.1.0", | ||
"module": "build/esm/index.js", | ||
@@ -17,3 +17,3 @@ "main": "build/cjs/index.js", | ||
}, | ||
"gitHead": "6066377a115fb694a7af12ee1a7dc60f73b2fee3" | ||
"gitHead": "2bf37b7bab49dfe95fe753ad28689827d9885743" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
193766
1037