@heliyos/heliyos-api-core 1.0.52 → 1.0.53

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.
package/dist/app.js CHANGED
@@ -56,6 +56,10 @@ const coreApp = (app, routes, options) => __awaiter(void 0, void 0, void 0, func
56
56
  const PORT = process.env.PORT || 3030;
57
57
  // Create HTTP server.
58
58
  const server = http_1.default.createServer(newApp);
59
+ // Keep sockets open long enough for client pools and Service Connect proxies
60
+ server.keepAliveTimeout = 65000;
61
+ server.headersTimeout = 66000;
62
+ server.setTimeout(30000);
59
63
  // Initialize mongoose database connections
60
64
  yield (0, mongoose_1.initializeDatabase)();
61
65
  // Graceful shutdown handler
@@ -92,5 +96,10 @@ const coreApp = (app, routes, options) => __awaiter(void 0, void 0, void 0, func
92
96
  }));
93
97
  server.on("error", onError);
94
98
  server.on("listening", onListening);
99
+ // Log any abrupt disconnects
100
+ server.on("clientError", (err, socket) => {
101
+ logger_1.logger.error("Client connection error:", err);
102
+ socket.end("HTTP/1.1 400 Bad Request\r\n\r\n");
103
+ });
95
104
  });
96
105
  exports.coreApp = coreApp;
package/dist/axios.js CHANGED
@@ -8,6 +8,7 @@ const axios_1 = __importDefault(require("axios"));
8
8
  const logger_1 = require("./logger");
9
9
  const http_1 = __importDefault(require("http"));
10
10
  const https_1 = __importDefault(require("https"));
11
+ const axios_retry_1 = __importDefault(require("axios-retry"));
11
12
  const config = {
12
13
  withCredentials: true,
13
14
  };
@@ -67,11 +68,21 @@ const httpsAgent = new https_1.default.Agent({
67
68
  // Axios server configs
68
69
  const servers = {
69
70
  // Auth server
70
- authServer: axios_1.default.create(Object.assign(Object.assign({}, config), { baseURL: process.env.BASE_URL_AUTH_SERVER, auth: {
71
+ authServer: (0, axios_retry_1.default)(axios_1.default.create(Object.assign(Object.assign({}, config), { baseURL: process.env.BASE_URL_AUTH_SERVER, auth: {
71
72
  username: "auth",
72
73
  password: process.env.SECRET_OF_AUTH_SERVER,
73
74
  }, httpAgent,
74
- httpsAgent })),
75
+ httpsAgent })), {
76
+ retries: 3,
77
+ retryDelay: axios_retry_1.default.exponentialDelay,
78
+ shouldResetTimeout: true,
79
+ retryCondition: (error) => {
80
+ var _a;
81
+ return axios_retry_1.default.isNetworkOrIdempotentRequestError(error) ||
82
+ error.code === "ECONNRESET" ||
83
+ ((_a = error.response) === null || _a === void 0 ? void 0 : _a.status) === 503;
84
+ },
85
+ }),
75
86
  // Agent server
76
87
  agentServer: axios_1.default.create(Object.assign(Object.assign({}, config), { baseURL: process.env.BASE_URL_AGENT_SERVER, auth: {
77
88
  username: "agent",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@heliyos/heliyos-api-core",
3
- "version": "1.0.52",
3
+ "version": "1.0.53",
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": {
@@ -31,6 +31,7 @@
31
31
  "@aws-sdk/client-secrets-manager": "3.682.0",
32
32
  "@aws-sdk/client-sqs": "3.682.0",
33
33
  "axios": "^1.7.7",
34
+ "axios-retry": "4.5.0",
34
35
  "basic-auth": "^2.0.1",
35
36
  "body-parser": "^1.20.3",
36
37
  "compression": "1.8.1",