diff --git a/package-lock.json b/package-lock.json index a6e63c9..15a2cfc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -42,7 +42,7 @@ "koa": "^2.14.2", "koa-bodyparser": "^4.4.1", "koa-route": "^4.0.0", - "nock": "^13.3.8", + "nock": "^14.0.0-beta.7", "npm": "^10.2.4", "prettier": "^3.1.0", "supertest": "^7.0.0", @@ -6412,18 +6412,17 @@ } }, "node_modules/nock": { - "version": "13.5.4", - "resolved": "https://registry.npmjs.org/nock/-/nock-13.5.4.tgz", - "integrity": "sha512-yAyTfdeNJGGBFxWdzSKCBYxs5FxLbCg5X5Q4ets974hcQzG1+qCxvIyOo4j2Ry6MUlhWVMX4OoYDefAIIwupjw==", + "version": "14.0.0-beta.7", + "resolved": "https://registry.npmjs.org/nock/-/nock-14.0.0-beta.7.tgz", + "integrity": "sha512-+EQMm5W9K8YnBE2Ceg4hnJynaCZmvK8ZlFXQ2fxGwtkOkBUq8GpQLTks2m1jpvse9XDxMDDOHgOWpiznFuh0bA==", "dev": true, "license": "MIT", "dependencies": { - "debug": "^4.1.0", "json-stringify-safe": "^5.0.1", "propagate": "^2.0.0" }, "engines": { - "node": ">= 10.13" + "node": ">= 18" } }, "node_modules/node-fetch": { diff --git a/package.json b/package.json index fc916d7..ded2038 100644 --- a/package.json +++ b/package.json @@ -192,7 +192,7 @@ "koa": "^2.14.2", "koa-bodyparser": "^4.4.1", "koa-route": "^4.0.0", - "nock": "^13.3.8", + "nock": "^14.0.0-beta.7", "npm": "^10.2.4", "prettier": "^3.1.0", "supertest": "^7.0.0", diff --git a/src/common/client.ts b/src/common/client.ts index 89eb8db..1e28ac2 100644 --- a/src/common/client.ts +++ b/src/common/client.ts @@ -17,12 +17,6 @@ const INITIAL_SYNC_INTERVAL = 10000; // 10 seconds const INITIAL_SYNC_INTERVAL_DURATION = 3600000; // 1 hour const MAX_QUEUE_TIME = 3.6e6; // 1 hour -const fetchWithRetry = fetchRetry(fetch, { - retries: 3, - retryDelay: 1000, - retryOn: [408, 429, 500, 502, 503, 504], -}); - class HTTPError extends Error { public response: Response; @@ -107,6 +101,11 @@ export class ApitallyClient { } private async makeHubRequest(url: string, payload: any) { + const fetchWithRetry = fetchRetry(fetch, { + retries: 3, + retryDelay: 1000, + retryOn: [408, 429, 500, 502, 503, 504], + }); const response = await fetchWithRetry(this.getHubUrlPrefix() + url, { method: "POST", body: JSON.stringify(payload), diff --git a/tests/express/app.test.ts b/tests/express/app.test.ts index 1783101..6683ec3 100644 --- a/tests/express/app.test.ts +++ b/tests/express/app.test.ts @@ -20,7 +20,7 @@ const testCases = [ testCases.forEach(({ name, getApp }) => { describe(name, () => { let app: Express; - let appTest: request.SuperTest; + let appTest: request.Agent; let client: ApitallyClient; beforeEach(async () => { diff --git a/tests/fastify/app.test.ts b/tests/fastify/app.test.ts index ee586f7..41bbf85 100644 --- a/tests/fastify/app.test.ts +++ b/tests/fastify/app.test.ts @@ -8,13 +8,12 @@ import { getApp } from "./app.js"; describe("Plugin for Fastify", () => { let app: FastifyInstance; - let appTest: request.SuperTest; + let appTest: request.Agent; let client: ApitallyClient; beforeEach(async () => { mockApitallyHub(); app = await getApp(); - app.printRoutes; appTest = request(app.server); client = ApitallyClient.getInstance(); await app.ready(); diff --git a/tests/koa/app.test.ts b/tests/koa/app.test.ts index e7daab0..aa49eb6 100644 --- a/tests/koa/app.test.ts +++ b/tests/koa/app.test.ts @@ -23,7 +23,7 @@ const testCases = [ testCases.forEach(({ name, router, getApp }) => { describe(name, () => { let app: Koa; - let appTest: request.SuperTest; + let appTest: request.Agent; let client: ApitallyClient; beforeEach(async () => { diff --git a/tests/nestjs/app.test.ts b/tests/nestjs/app.test.ts index e775220..8e2d0a9 100644 --- a/tests/nestjs/app.test.ts +++ b/tests/nestjs/app.test.ts @@ -9,7 +9,7 @@ import { getApp } from "./app.js"; describe("Middleware for NestJS", () => { let app: INestApplication; - let appTest: request.SuperTest; + let appTest: request.Agent; let client: ApitallyClient; beforeEach(async () => {