From 68cdc633d99a43536392db4375a76fbb68cf93e1 Mon Sep 17 00:00:00 2001 From: Ian Lucas Date: Sun, 16 Jun 2024 12:04:03 -0400 Subject: [PATCH] Revert retry in helpers --- packages/ops/package.json | 3 --- packages/ops/src/utils/helpers.ts | 27 +++++---------------------- yarn.lock | 30 +----------------------------- 3 files changed, 6 insertions(+), 54 deletions(-) diff --git a/packages/ops/package.json b/packages/ops/package.json index cc0f88657..a8ce70153 100644 --- a/packages/ops/package.json +++ b/packages/ops/package.json @@ -9,9 +9,6 @@ "@credbull/api": "workspace:^", "@credbull/contracts": "workspace:^", "@supabase/supabase-js": "^2.39.1", - "axios": "^1.7.2", - "axios-retry": "^4.4.0", - "axis": "^1.0.0", "bottleneck": "^2.19.5", "compression": "^1.7.4", "crypto": "^1.0.1", diff --git a/packages/ops/src/utils/helpers.ts b/packages/ops/src/utils/helpers.ts index ea840b9e3..68609db05 100644 --- a/packages/ops/src/utils/helpers.ts +++ b/packages/ops/src/utils/helpers.ts @@ -1,7 +1,5 @@ import { Database } from '@credbull/api'; import { SupabaseClient, createClient } from '@supabase/supabase-js'; -import axios from 'axios'; -import axiosRetry from 'axios-retry'; import crypto from 'crypto'; import { Wallet, providers } from 'ethers'; import { SiweMessage, generateNonce } from 'siwe'; @@ -12,19 +10,6 @@ export const emailSchemaOptional = z.string().email().nullish().or(z.literal('') export const addressSchema = z.string().regex(/^(0x)?[0-9a-fA-F]{40,40}$/); export const upsideVaultSchema = z.union([addressSchema, z.string().regex(/^self$/)]).optional(); -// Configure axios to use axios-retry -axiosRetry(axios, { - retries: 3, // Number of retries - retryDelay: (retryCount) => { - console.log(`Retry attempt: ${retryCount}`); - return retryCount * 300; // Time in ms between retries - }, - retryCondition: (error) => { - // Retry on network errors or 5xx status codes - return axiosRetry.isNetworkOrIdempotentRequestError(error) || error.response.status >= 500; - }, -}); - const supabaseConfigSchema = z.object({ services: z.object({ supabase: z.object({ url: z.string().url() }) }), secret: z.object({ @@ -106,26 +91,24 @@ export const login = async ( _password = config.secret!.BOB_PASSWORD!; } - const body = { email: _email, password: _password }; - console.log(JSON.stringify(body)); + const body = JSON.stringify({ email: _email, password: _password }); let signIn; try { - signIn = await axios.post(`${config.api.url}/auth/api/sign-in`, body, headers()); + signIn = await fetch(`${config.api.url}/auth/api/sign-in`, { method: 'POST', body, ...headers() }); } catch (error) { console.error('Network error or server is down:', error); throw error; } - if (signIn.status < 200 || signIn.status >= 300) { + if (!signIn.ok) { console.error(`HTTP error! status: ${signIn.status}`); throw new Error(`Failed to login: ${signIn.statusText}`); } - const data = await signIn.data; + const data = await signIn.json(); console.log(`sign in response: ${JSON.stringify(data)}`); - return data; }; @@ -134,7 +117,7 @@ const linkWalletConfigSchema = z.object({ app: z.object({ url: z.string().url() export const linkWalletMessage = async (config: any, signer: Wallet) => { linkWalletConfigSchema.parse(config); - const appUrl = new URL(config.app.url); + let appUrl = new URL(config.app.url); const chainId = await signer.getChainId(); const preMessage = new SiweMessage({ domain: appUrl.host, diff --git a/yarn.lock b/yarn.lock index 5ace3e9c7..db1cb8d56 100644 --- a/yarn.lock +++ b/yarn.lock @@ -660,9 +660,6 @@ __metadata: "@types/node": ^20.10.5 "@typescript-eslint/eslint-plugin": ^6.16.0 "@typescript-eslint/parser": ^6.16.0 - axios: ^1.7.2 - axios-retry: ^4.4.0 - axis: ^1.0.0 bottleneck: ^2.19.5 compression: ^1.7.4 crypto: ^1.0.1 @@ -7249,18 +7246,7 @@ __metadata: languageName: node linkType: hard -"axios-retry@npm:^4.4.0": - version: 4.4.0 - resolution: "axios-retry@npm:4.4.0" - dependencies: - is-retry-allowed: ^2.2.0 - peerDependencies: - axios: 0.x || 1.x - checksum: 19b005bbd3e956080b27ee54fad658dbf7663fa6e884110a638b9f53db50a34c4870648143c8d9397354fedd0ede920693caa1e7c6a762d9477b4cbb48ca22f2 - languageName: node - linkType: hard - -"axios@npm:^1.5.1, axios@npm:^1.6.1, axios@npm:^1.6.5, axios@npm:^1.7.2": +"axios@npm:^1.5.1, axios@npm:^1.6.1, axios@npm:^1.6.5": version: 1.7.2 resolution: "axios@npm:1.7.2" dependencies: @@ -7271,13 +7257,6 @@ __metadata: languageName: node linkType: hard -"axis@npm:^1.0.0": - version: 1.0.0 - resolution: "axis@npm:1.0.0" - checksum: 6c1d151252a33ff12c7f390ff9168a44c95e5caa55e6f0441e8f4be8b90990903e511dbb4e0e26dda905def56111dac22df4f1023904447cbdfc4d27ff48b1cf - languageName: node - linkType: hard - "axobject-query@npm:^3.2.1": version: 3.2.1 resolution: "axobject-query@npm:3.2.1" @@ -12875,13 +12854,6 @@ __metadata: languageName: node linkType: hard -"is-retry-allowed@npm:^2.2.0": - version: 2.2.0 - resolution: "is-retry-allowed@npm:2.2.0" - checksum: 3d1103a9290b5d03626756a41054844633eac78bc5d3e3a95b13afeae94fa3cfbcf7f0b5520d83f75f48a25ce7b142fdbac4217dc4b0630f3ea55e866ec3a029 - languageName: node - linkType: hard - "is-set@npm:^2.0.2, is-set@npm:^2.0.3": version: 2.0.3 resolution: "is-set@npm:2.0.3"