@heliyos/heliyos-api-core 1.0.51 → 1.0.52

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/axios.js +21 -3
  2. package/package.json +1 -1
package/dist/axios.js CHANGED
@@ -6,6 +6,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.coreAxios = void 0;
7
7
  const axios_1 = __importDefault(require("axios"));
8
8
  const logger_1 = require("./logger");
9
+ const http_1 = __importDefault(require("http"));
10
+ const https_1 = __importDefault(require("https"));
9
11
  const config = {
10
12
  withCredentials: true,
11
13
  };
@@ -49,23 +51,39 @@ const handleAxiosError = (err) => {
49
51
  : false;
50
52
  throw custom_error;
51
53
  };
54
+ // Create HTTP agents with connection pooling
55
+ const httpAgent = new http_1.default.Agent({
56
+ keepAlive: true, // Reuse connections
57
+ maxSockets: 100, // Allow up to 100 concurrent connections (increase from default 5!)
58
+ maxFreeSockets: 10, // Keep 10 idle connections open
59
+ timeout: 60000, // Socket timeout: 60 seconds
60
+ });
61
+ const httpsAgent = new https_1.default.Agent({
62
+ keepAlive: true,
63
+ maxSockets: 100,
64
+ maxFreeSockets: 10,
65
+ timeout: 60000,
66
+ });
52
67
  // Axios server configs
53
68
  const servers = {
54
69
  // Auth server
55
70
  authServer: axios_1.default.create(Object.assign(Object.assign({}, config), { baseURL: process.env.BASE_URL_AUTH_SERVER, auth: {
56
71
  username: "auth",
57
72
  password: process.env.SECRET_OF_AUTH_SERVER,
58
- } })),
73
+ }, httpAgent,
74
+ httpsAgent })),
59
75
  // Agent server
60
76
  agentServer: axios_1.default.create(Object.assign(Object.assign({}, config), { baseURL: process.env.BASE_URL_AGENT_SERVER, auth: {
61
77
  username: "agent",
62
78
  password: process.env.SECRET_OF_AGENT_SERVER,
63
- } })),
79
+ }, httpAgent,
80
+ httpsAgent })),
64
81
  // Platform server
65
82
  platformServer: axios_1.default.create(Object.assign(Object.assign({}, config), { baseURL: process.env.BASE_URL_PLATFORM_SERVER, auth: {
66
83
  username: "platform",
67
84
  password: process.env.SECRET_OF_PLATFORM_SERVER,
68
- } })),
85
+ }, httpAgent,
86
+ httpsAgent })),
69
87
  // Export axios plain object to call some third party external calls
70
88
  axios: axios_1.default,
71
89
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@heliyos/heliyos-api-core",
3
- "version": "1.0.51",
3
+ "version": "1.0.52",
4
4
  "description": "Heliyos's core api functions and middlewares. Its a private package hosted on npm.",
5
5
  "main": "./dist/index.js",
6
6
  "scripts": {