Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@devcycle/nodejs-server-sdk

Package Overview
Dependencies
Maintainers
6
Versions
192
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@devcycle/nodejs-server-sdk - npm Package Compare versions

Comparing version 1.4.11 to 1.4.12

11

package.json
{
"name": "@devcycle/nodejs-server-sdk",
"version": "1.4.11",
"version": "1.4.12",
"description": "The DevCycle NodeJS Server SDK used for feature management.",
"license": "MIT",
"devDependencies": {
"@devcycle/bucketing-test-data": "^1.0.32",
"@devcycle/bucketing-test-data": "^1.0.33",
"assemblyscript-json": "*",

@@ -12,4 +12,4 @@ "assemblyscript-regex": "*"

"dependencies": {
"@devcycle/bucketing-assembly-script": "^1.1.12",
"@devcycle/types": "1.0.44",
"@devcycle/bucketing-assembly-script": "^1.1.13",
"@devcycle/types": "1.0.45",
"class-transformer": "0.5.1",

@@ -24,3 +24,4 @@ "@nestjs/class-validator": "^0.13.4",

"as-uuid": "^0.0.4",
"axios": "^0.24.0"
"axios": "^0.27.2",
"axios-retry": "^3.3.1"
},

@@ -27,0 +28,0 @@ "engines": {

@@ -70,3 +70,3 @@ "use strict";

return __awaiter(this, void 0, void 0, function () {
var url, res, ex_1;
var url, res, ex_1, errMsg;
return __generator(this, function (_d) {

@@ -87,4 +87,10 @@ switch (_d.label) {

ex_1 = _d.sent();
this.logger.error("Request to get config failed for url: ".concat(url, ", ") +
"response message: ".concat(ex_1.message, ", response data ").concat((_b = ex_1 === null || ex_1 === void 0 ? void 0 : ex_1.response) === null || _b === void 0 ? void 0 : _b.data));
errMsg = "Request to get config failed for url: ".concat(url, ", ") +
"response message: ".concat(ex_1.message, ", response data ").concat((_b = ex_1 === null || ex_1 === void 0 ? void 0 : ex_1.response) === null || _b === void 0 ? void 0 : _b.data);
if (this.hasConfig) {
this.logger.debug(errMsg);
}
else {
this.logger.error(errMsg);
}
res = null;

@@ -96,3 +102,3 @@ return [3 /*break*/, 4];

}
else if ((res === null || res === void 0 ? void 0 : res.status) === 200) {
else if ((res === null || res === void 0 ? void 0 : res.status) === 200 && (res === null || res === void 0 ? void 0 : res.data)) {
(0, bucketing_1.getBucketingLib)().setConfigData(this.environmentKey, JSON.stringify(res.data));

@@ -103,3 +109,3 @@ this.hasConfig = true;

else if (this.hasConfig) {
this.logger.error("Failed to download config, using cached version. url: ".concat(url, "."));
this.logger.debug("Failed to download config, using cached version. url: ".concat(url, "."));
}

@@ -106,0 +112,0 @@ else {

@@ -14,3 +14,3 @@ import { AxiosRequestConfig, AxiosResponse } from 'axios';

export declare function postTrack(user: DVCPopulatedUser, event: DVCEvent, envKey: string, logger: DVCLogger, options: DVCOptions): Promise<void>;
export declare function post(requestConfig: AxiosRequestConfig, envKey: string): Promise<AxiosResponse>;
export declare function get(requestConfig: AxiosRequestConfig): Promise<AxiosResponse>;
export declare function post(requestConfig: AxiosRequestConfig, envKey: string, retryable?: boolean): Promise<AxiosResponse>;
export declare function get(requestConfig: AxiosRequestConfig, retryable?: boolean): Promise<AxiosResponse>;

@@ -55,5 +55,27 @@ "use strict";

var axios_1 = __importDefault(require("axios"));
var axios_retry_1 = __importDefault(require("axios-retry"));
var validateStatus = function (status) { return status < 400 && status >= 200; };
var axiosClient = axios_1.default.create({
validateStatus: function (status) { return status < 400 && status >= 200; },
timeout: 10 * 1000,
validateStatus: validateStatus,
});
var axiosRetryableClient = axios_1.default.create({
timeout: 5 * 1000,
validateStatus: validateStatus,
});
var retryConfig = {
retries: 5,
// will do exponential retry until axios.timeout
retryDelay: axios_retry_1.default.exponentialDelay,
shouldResetTimeout: true,
retryCondition: function (error) {
return !error.response || (error.response.status || 0) >= 500;
}
};
(0, axios_retry_1.default)(axiosRetryableClient, retryConfig);
var axiosRetryableConfigClient = axios_1.default.create({
timeout: 5 * 1000,
validateStatus: validateStatus,
});
(0, axios_retry_1.default)(axiosRetryableConfigClient, __assign(__assign({}, retryConfig), { retries: 1 }));
exports.HOST = '.devcycle.com';

@@ -81,3 +103,3 @@ exports.EVENT_URL = 'https://events';

data: { batch: eventsBatch }
}, envKey)];
}, envKey, false)];
case 1:

@@ -107,3 +129,4 @@ res = _c.sent();

}
return [4 /*yield*/, get({
return [4 /*yield*/, axiosRetryableConfigClient.request({
method: 'GET',
url: url,

@@ -148,3 +171,3 @@ timeout: requestTimeout,

headers: { 'Authorization': envKey, 'Content-Type': 'application/json' },
data: user
data: user,
}, envKey)];

@@ -207,7 +230,11 @@ case 1: return [2 /*return*/, _a.sent()];

exports.postTrack = postTrack;
function post(requestConfig, envKey) {
function post(requestConfig, envKey, retryable) {
if (retryable === void 0) { retryable = true; }
return __awaiter(this, void 0, void 0, function () {
var client;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, axiosClient.request(__assign(__assign({}, requestConfig), { headers: { 'Authorization': envKey }, method: 'POST' }))];
case 0:
client = retryable ? axiosRetryableClient : axiosClient;
return [4 /*yield*/, client.request(__assign(__assign({}, requestConfig), { headers: { 'Authorization': envKey }, method: 'POST' }))];
case 1: return [2 /*return*/, _a.sent()];

@@ -219,7 +246,11 @@ }

exports.post = post;
function get(requestConfig) {
function get(requestConfig, retryable) {
if (retryable === void 0) { retryable = true; }
return __awaiter(this, void 0, void 0, function () {
var client;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, axiosClient.request(__assign(__assign({}, requestConfig), { method: 'GET' }))];
case 0:
client = retryable ? axiosRetryableClient : axiosClient;
return [4 /*yield*/, client.request(__assign(__assign({}, requestConfig), { method: 'GET' }))];
case 1: return [2 /*return*/, _a.sent()];

@@ -226,0 +257,0 @@ }

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc